aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-07-04 22:46:12 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-07-25 10:24:35 -0400
commit5accd7f3360e891bd552312515387dbaa2bb4bf3 (patch)
treed0bc381ad96ae3a69fa211fb2e9053f9d6de421e /scripts/kconfig
parent693359f7ac9012778590a370d076b13db704255e (diff)
kconfig: handle format string before calling conf_message_callback()
As you see in mconf.c and nconf.c, conf_message_callback() hooks are likely to end up with the boilerplate of vsnprintf(). Process the string format before calling conf_message_callback() so that it receives a simple string. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Dirk Gouders <dirk@gouders.net>
Diffstat (limited to 'scripts/kconfig')
-rw-r--r--scripts/kconfig/confdata.c17
-rw-r--r--scripts/kconfig/lkc_proto.h2
-rw-r--r--scripts/kconfig/mconf.c9
-rw-r--r--scripts/kconfig/nconf.c7
4 files changed, 17 insertions, 18 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index d1216e4ade2f..629ad32d4708 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -43,16 +43,16 @@ static void conf_warning(const char *fmt, ...)
43 conf_warnings++; 43 conf_warnings++;
44} 44}
45 45
46static void conf_default_message_callback(const char *fmt, va_list ap) 46static void conf_default_message_callback(const char *s)
47{ 47{
48 printf("#\n# "); 48 printf("#\n# ");
49 vprintf(fmt, ap); 49 printf("%s", s);
50 printf("\n#\n"); 50 printf("\n#\n");
51} 51}
52 52
53static void (*conf_message_callback) (const char *fmt, va_list ap) = 53static void (*conf_message_callback)(const char *s) =
54 conf_default_message_callback; 54 conf_default_message_callback;
55void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) 55void conf_set_message_callback(void (*fn)(const char *s))
56{ 56{
57 conf_message_callback = fn; 57 conf_message_callback = fn;
58} 58}
@@ -60,10 +60,15 @@ void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
60static void conf_message(const char *fmt, ...) 60static void conf_message(const char *fmt, ...)
61{ 61{
62 va_list ap; 62 va_list ap;
63 char buf[4096];
64
65 if (!conf_message_callback)
66 return;
63 67
64 va_start(ap, fmt); 68 va_start(ap, fmt);
65 if (conf_message_callback) 69
66 conf_message_callback(fmt, ap); 70 vsnprintf(buf, sizeof(buf), fmt, ap);
71 conf_message_callback(buf);
67 va_end(ap); 72 va_end(ap);
68} 73}
69 74
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index a8b7a330587e..cf4510a2bdc7 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -10,7 +10,7 @@ int conf_write(const char *name);
10int conf_write_autoconf(void); 10int conf_write_autoconf(void);
11bool conf_get_changed(void); 11bool conf_get_changed(void);
12void conf_set_changed_callback(void (*fn)(void)); 12void conf_set_changed_callback(void (*fn)(void));
13void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); 13void conf_set_message_callback(void (*fn)(const char *s));
14 14
15/* menu.c */ 15/* menu.c */
16extern struct menu rootmenu; 16extern struct menu rootmenu;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 5294ed159b98..b8f3b607962a 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -772,16 +772,13 @@ static void show_helptext(const char *title, const char *text)
772 show_textbox(title, text, 0, 0); 772 show_textbox(title, text, 0, 0);
773} 773}
774 774
775static void conf_message_callback(const char *fmt, va_list ap) 775static void conf_message_callback(const char *s)
776{ 776{
777 char buf[PATH_MAX+1];
778
779 vsnprintf(buf, sizeof(buf), fmt, ap);
780 if (save_and_exit) { 777 if (save_and_exit) {
781 if (!silent) 778 if (!silent)
782 printf("%s", buf); 779 printf("%s", s);
783 } else { 780 } else {
784 show_textbox(NULL, buf, 6, 60); 781 show_textbox(NULL, s, 6, 60);
785 } 782 }
786} 783}
787 784
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 97b78445584b..5cbdb92e11b3 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -1210,12 +1210,9 @@ static void conf(struct menu *menu)
1210 } 1210 }
1211} 1211}
1212 1212
1213static void conf_message_callback(const char *fmt, va_list ap) 1213static void conf_message_callback(const char *s)
1214{ 1214{
1215 char buf[1024]; 1215 btn_dialog(main_window, s, 1, "<OK>");
1216
1217 vsnprintf(buf, sizeof(buf), fmt, ap);
1218 btn_dialog(main_window, buf, 1, "<OK>");
1219} 1216}
1220 1217
1221static void show_help(struct menu *menu) 1218static void show_help(struct menu *menu)