Skip to content

Commit 5ee5465

Browse files
committed
kconfig: change sym_change_count to a boolean flag
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>
1 parent 1f035a5 commit 5ee5465

File tree

7 files changed

+18
-24
lines changed

7 files changed

+18
-24
lines changed

scripts/kconfig/confdata.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ int conf_read_simple(const char *name, int def)
366366
in = zconf_fopen(name);
367367
if (in)
368368
goto load;
369-
sym_add_change_count(1);
369+
conf_set_changed(true);
370370

371371
env = getenv("KCONFIG_DEFCONFIG_LIST");
372372
if (!env)
@@ -444,7 +444,7 @@ int conf_read_simple(const char *name, int def)
444444
if (def == S_DEF_USER) {
445445
sym = sym_find(line + 2 + strlen(CONFIG_));
446446
if (!sym) {
447-
sym_add_change_count(1);
447+
conf_set_changed(true);
448448
continue;
449449
}
450450
} else {
@@ -487,7 +487,7 @@ int conf_read_simple(const char *name, int def)
487487
*/
488488
conf_touch_dep(line + strlen(CONFIG_));
489489
else
490-
sym_add_change_count(1);
490+
conf_set_changed(true);
491491
continue;
492492
}
493493

@@ -535,7 +535,7 @@ int conf_read(const char *name)
535535
int conf_unsaved = 0;
536536
int i;
537537

538-
sym_set_change_count(0);
538+
conf_set_changed(false);
539539

540540
if (conf_read_simple(name, S_DEF_USER)) {
541541
sym_calc_value(modules_sym);
@@ -593,7 +593,8 @@ int conf_read(const char *name)
593593
}
594594
}
595595

596-
sym_add_change_count(conf_warnings || conf_unsaved);
596+
if (conf_warnings || conf_unsaved)
597+
conf_set_changed(true);
597598

598599
return 0;
599600
}
@@ -938,7 +939,7 @@ int conf_write(const char *name)
938939
if (is_same(name, tmpname)) {
939940
conf_message("No change to %s", name);
940941
unlink(tmpname);
941-
sym_set_change_count(0);
942+
conf_set_changed(false);
942943
return 0;
943944
}
944945

@@ -950,7 +951,7 @@ int conf_write(const char *name)
950951

951952
conf_message("configuration written to %s", name);
952953

953-
sym_set_change_count(0);
954+
conf_set_changed(false);
954955

955956
return 0;
956957
}
@@ -1118,26 +1119,20 @@ int conf_write_autoconf(int overwrite)
11181119
return 0;
11191120
}
11201121

1121-
static int sym_change_count;
1122+
static bool conf_changed;
11221123
static void (*conf_changed_callback)(void);
11231124

1124-
void sym_set_change_count(int count)
1125+
void conf_set_changed(bool val)
11251126
{
1126-
int _sym_change_count = sym_change_count;
1127-
sym_change_count = count;
1128-
if (conf_changed_callback &&
1129-
(bool)_sym_change_count != (bool)count)
1127+
if (conf_changed_callback && conf_changed != val)
11301128
conf_changed_callback();
1131-
}
11321129

1133-
void sym_add_change_count(int count)
1134-
{
1135-
sym_set_change_count(count + sym_change_count);
1130+
conf_changed = val;
11361131
}
11371132

11381133
bool conf_get_changed(void)
11391134
{
1140-
return sym_change_count;
1135+
return conf_changed;
11411136
}
11421137

11431138
void conf_set_changed_callback(void (*fn)(void))

scripts/kconfig/lkc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ const char *zconf_curname(void);
4545

4646
/* confdata.c */
4747
const char *conf_get_configname(void);
48-
void sym_set_change_count(int count);
49-
void sym_add_change_count(int count);
5048
void set_all_choice_values(struct symbol *csym);
5149

5250
/* confdata.c and expr.c */

scripts/kconfig/lkc_proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ int conf_read_simple(const char *name, int);
88
int conf_write_defconfig(const char *name);
99
int conf_write(const char *name);
1010
int conf_write_autoconf(int overwrite);
11+
void conf_set_changed(bool val);
1112
bool conf_get_changed(void);
1213
void conf_set_changed_callback(void (*fn)(void));
1314
void conf_set_message_callback(void (*fn)(const char *s));

scripts/kconfig/mconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ static void conf_load(void)
910910
return;
911911
if (!conf_read(dialog_input_result)) {
912912
set_config_filename(dialog_input_result);
913-
sym_set_change_count(1);
913+
conf_set_changed(true);
914914
return;
915915
}
916916
show_textbox(NULL, "File does not exist!", 5, 38);

scripts/kconfig/nconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ static void conf_load(void)
14081408
return;
14091409
if (!conf_read(dialog_input_result)) {
14101410
set_config_filename(dialog_input_result);
1411-
sym_set_change_count(1);
1411+
conf_set_changed(true);
14121412
return;
14131413
}
14141414
btn_dialog(main_window, "File does not exist!", 0);

scripts/kconfig/parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ void conf_parse(const char *name)
507507
}
508508
if (yynerrs)
509509
exit(1);
510-
sym_set_change_count(1);
510+
conf_set_changed(true);
511511
}
512512

513513
static bool zconf_endtoken(const char *tokenname,

scripts/kconfig/symbol.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ void sym_clear_all_valid(void)
472472

473473
for_all_symbols(i, sym)
474474
sym->flags &= ~SYMBOL_VALID;
475-
sym_add_change_count(1);
475+
conf_set_changed(true);
476476
sym_calc_value(modules_sym);
477477
}
478478

0 commit comments

Comments
 (0)