Skip to contentSkip to conversation

kconfig: fix an "implicit declaration of function" warning

PATCH In review Bartosz Golaszewski 2 participants 2 messages Jan 9, 2020 – Jan 11, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kconfig: fix an "implicit declaration of function" warning

From: Bartosz Golaszewski <[email protected]>

strncasecmp() & strcasecmp() functions are declared in strings.h, not string.h. On most environments the former is implicitly included by the latter but on some setups, building menuconfig results in the following warning:

HOSTCC scripts/kconfig/mconf.o
scripts/kconfig/mconf.c: In function ‘search_conf’:
scripts/kconfig/mconf.c:423:6: warning: implicit declaration of function ‘strncasecmp’ [-Wimplicit-function-declaration]
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)

      ^~~~~~~~~~~
scripts/kconfig/mconf.c: In function ‘main’:
scripts/kconfig/mconf.c:1021:8: warning: implicit declaration of function ‘strcasecmp’ [-Wimplicit-function-declaration]
   if (!strcasecmp(mode, "single_menu"))
        ^~~~~~~~~~

Fix it by explicitly including strings.h.

---
 scripts/kconfig/gconf.c | 1 +
 scripts/kconfig/mconf.c | 1 +
 scripts/kconfig/nconf.c | 1 +
 3 files changed, 3 insertions(+)
scripts/kconfig/gconf.c +1 -0
index e36b342f1065..5527482c3077 100644
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <time.h>
 
scripts/kconfig/mconf.c +1 -0
index 49c26ea9dd98..4063dbc1b927 100644
@@ -15,6 +15,7 @@
 #include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <signal.h>
 #include <unistd.h>
 
scripts/kconfig/nconf.c +1 -0
index b7c1ef757178..daf1c1506ec4 100644
@@ -8,6 +8,7 @@
 #define _GNU_SOURCE
 #endif
 #include <string.h>
+#include <strings.h>
 #include <stdlib.h>
 
 #include "lkc.h"
Signature · 1 line
2.23.0
#1 lore raw
Quoted 18 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

strncasecmp() & strcasecmp() functions are declared in strings.h, not string.h. On most environments the former is implicitly included by the latter but on some setups, building menuconfig results in the following warning:

HOSTCC scripts/kconfig/mconf.o
scripts/kconfig/mconf.c: In function ‘search_conf’:
scripts/kconfig/mconf.c:423:6: warning: implicit declaration of function ‘strncasecmp’ [-Wimplicit-function-declaration]
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)

      ^~~~~~~~~~~
scripts/kconfig/mconf.c: In function ‘main’:
scripts/kconfig/mconf.c:1021:8: warning: implicit declaration of function ‘strcasecmp’ [-Wimplicit-function-declaration]
   if (!strcasecmp(mode, "single_menu"))
        ^~~~~~~~~~
Quoted 3 lines

Fix it by explicitly including strings.h.

Applied to linux-kbuild.
Thanks.

Signature · 2 lines
Best Regards
Masahiro Yamada