]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kconfig: change sym_change_count to a boolean flag
authorMasahiro Yamada <masahiroy@kernel.org>
Sat, 10 Apr 2021 06:57:22 +0000 (15:57 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Wed, 14 Apr 2021 06:22:49 +0000 (15:22 +0900)
sym_change_count has no good reason to be 'int' type.

sym_set_change_count() compares the old and new values after casting
both of them to (bool). I do not see any practical diffrence between
sym_set_change_count(1) and sym_add_change_count(1).

Use the boolean flag, conf_changed.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/confdata.c
scripts/kconfig/lkc.h
scripts/kconfig/lkc_proto.h
scripts/kconfig/mconf.c
scripts/kconfig/nconf.c
scripts/kconfig/parser.y
scripts/kconfig/symbol.c

index c796d402665e4d71c4a65d7f26c83a02eb15d881..a8339871ef792317db26a0f1caded5335a5bee5f 100644 (file)
@@ -366,7 +366,7 @@ int conf_read_simple(const char *name, int def)
                in = zconf_fopen(name);
                if (in)
                        goto load;
-               sym_add_change_count(1);
+               conf_set_changed(true);
 
                env = getenv("KCONFIG_DEFCONFIG_LIST");
                if (!env)
@@ -444,7 +444,7 @@ load:
                        if (def == S_DEF_USER) {
                                sym = sym_find(line + 2 + strlen(CONFIG_));
                                if (!sym) {
-                                       sym_add_change_count(1);
+                                       conf_set_changed(true);
                                        continue;
                                }
                        } else {
@@ -487,7 +487,7 @@ load:
                                         */
                                        conf_touch_dep(line + strlen(CONFIG_));
                                else
-                                       sym_add_change_count(1);
+                                       conf_set_changed(true);
                                continue;
                        }
 
@@ -535,7 +535,7 @@ int conf_read(const char *name)
        int conf_unsaved = 0;
        int i;
 
-       sym_set_change_count(0);
+       conf_set_changed(false);
 
        if (conf_read_simple(name, S_DEF_USER)) {
                sym_calc_value(modules_sym);
@@ -593,7 +593,8 @@ int conf_read(const char *name)
                }
        }
 
-       sym_add_change_count(conf_warnings || conf_unsaved);
+       if (conf_warnings || conf_unsaved)
+               conf_set_changed(true);
 
        return 0;
 }
@@ -938,7 +939,7 @@ next:
                if (is_same(name, tmpname)) {
                        conf_message("No change to %s", name);
                        unlink(tmpname);
-                       sym_set_change_count(0);
+                       conf_set_changed(false);
                        return 0;
                }
 
@@ -950,7 +951,7 @@ next:
 
        conf_message("configuration written to %s", name);
 
-       sym_set_change_count(0);
+       conf_set_changed(false);
 
        return 0;
 }
@@ -1118,26 +1119,20 @@ int conf_write_autoconf(int overwrite)
        return 0;
 }
 
-static int sym_change_count;
+static bool conf_changed;
 static void (*conf_changed_callback)(void);
 
-void sym_set_change_count(int count)
+void conf_set_changed(bool val)
 {
-       int _sym_change_count = sym_change_count;
-       sym_change_count = count;
-       if (conf_changed_callback &&
-           (bool)_sym_change_count != (bool)count)
+       if (conf_changed_callback && conf_changed != val)
                conf_changed_callback();
-}
 
-void sym_add_change_count(int count)
-{
-       sym_set_change_count(count + sym_change_count);
+       conf_changed = val;
 }
 
 bool conf_get_changed(void)
 {
-       return sym_change_count;
+       return conf_changed;
 }
 
 void conf_set_changed_callback(void (*fn)(void))
index 01666f558fe9cc505b7490ed1f403f3ae3adae00..45599c52478d0203c5fdcf7a3c87d001e6bdd0f9 100644 (file)
@@ -45,8 +45,6 @@ const char *zconf_curname(void);
 
 /* confdata.c */
 const char *conf_get_configname(void);
-void sym_set_change_count(int count);
-void sym_add_change_count(int count);
 void set_all_choice_values(struct symbol *csym);
 
 /* confdata.c and expr.c */
index 9e81be33c40fa02882ed67917a33549d9eb862ea..a11626bdc421c4ef215525439300f4a70008c15a 100644 (file)
@@ -8,6 +8,7 @@ int conf_read_simple(const char *name, int);
 int conf_write_defconfig(const char *name);
 int conf_write(const char *name);
 int conf_write_autoconf(int overwrite);
+void conf_set_changed(bool val);
 bool conf_get_changed(void);
 void conf_set_changed_callback(void (*fn)(void));
 void conf_set_message_callback(void (*fn)(const char *s));
index 01b6c27224e279dce9a934fc0a7355244d47567b..4cfbe62938cd63c4fb3fa2b3ce60b694d6e8f131 100644 (file)
@@ -910,7 +910,7 @@ static void conf_load(void)
                                return;
                        if (!conf_read(dialog_input_result)) {
                                set_config_filename(dialog_input_result);
-                               sym_set_change_count(1);
+                               conf_set_changed(true);
                                return;
                        }
                        show_textbox(NULL, "File does not exist!", 5, 38);
index 0fb48f171b66e2e3ed4fff95619b68f76e7821bb..0cce69ccb611c415c28bb72553ce049f1a0e4fa9 100644 (file)
@@ -1408,7 +1408,7 @@ static void conf_load(void)
                                return;
                        if (!conf_read(dialog_input_result)) {
                                set_config_filename(dialog_input_result);
-                               sym_set_change_count(1);
+                               conf_set_changed(true);
                                return;
                        }
                        btn_dialog(main_window, "File does not exist!", 0);
index e46ce21a2fc4959568d44c298d94a5775c313beb..e90889edf5b35ddef0c6c591e10b969d556d6a9d 100644 (file)
@@ -507,7 +507,7 @@ void conf_parse(const char *name)
        }
        if (yynerrs)
                exit(1);
-       sym_set_change_count(1);
+       conf_set_changed(true);
 }
 
 static bool zconf_endtoken(const char *tokenname,
index 36b0fcb18117aa8e6ac93805cfdd2bcbbfb2c3c0..5844d636d38f474e2571c0a9f8bd3a734edd7928 100644 (file)
@@ -472,7 +472,7 @@ void sym_clear_all_valid(void)
 
        for_all_symbols(i, sym)
                sym->flags &= ~SYMBOL_VALID;
-       sym_add_change_count(1);
+       conf_set_changed(true);
        sym_calc_value(modules_sym);
 }