mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X
I'm cross-compiling the kernel on an OS X system, and when I run "make menuconfig", I get this warning:
HOSTCC scripts/kconfig/mconf.oscripts/kconfig/mconf.c: In function ‘main’:scripts/kconfig/mconf.c:871: warning: statement with no effect scripts/kconfig/mconf.c:872: warning: statement with no effect
Here is the code in question:
int main(int ac, char **av)
{
int saved_x, saved_y;
char *mode;
int res;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR); <--- line 871
textdomain(PACKAGE);I believe the warnings are from this code in lkc.h:
#ifndef KBUILD_NO_NLS
# include <libintl.h> #else # define gettext(Msgid) ((const char *) (Msgid)) # define textdomain(Domainname) ((const char *) (Domainname)) # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) #endif
Can someone explain to me why this macros are defined in this way? Every place where textdomain() and bindtext() are used, they are used like this:
bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE);
In other words, the return value from these macros is never used, so the warning is inevitable.
I think the code in lkc.h should be changed to:
# define textdomain(Domainname) do {} while(0)
# define bindtextdomain(Domainname, Dirname) do {} while(0)I can't say for certain whether this is a good idea, though, because I'm not at all familiar with this code.
Quoted 39 lines · Timur Tabi
I'm cross-compiling the kernel on an OS X system, and when I run "make menuconfig", I get this warning:
HOSTCC
scripts/kconfig/mconf.oscripts/kconfig/mconf.c: In function ‘main’:scripts/kconfig/mconf.c:871: warning: statement with no effectscripts/kconfig/mconf.c:872: warning: statement with no effectHere is the code in question:
int
main(int ac, char **av){ int saved_x, saved_y; char *mode; int res; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); <--- line 871 textdomain(PACKAGE);I believe the warnings are from this code in
lkc.h:#ifndef
KBUILD_NO_NLS# include <libintl.h> #else # define gettext(Msgid) ((const char *) (Msgid)) # define textdomain(Domainname) ((const char *) (Domainname)) # define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) #endifCan someone explain to me why this macros are defined in this way? Every place where
textdomain()andbindtext()are used, they are used like this:bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE);In other words, the return value from these macros is never used, so the warning is inevitable.
Quoted 7 lines
I think the code in
lkc.hshould be changed to:# define textdomain(Domainname) do {} while(0) # define bindtextdomain(Domainname, Dirname) do {} while(0)I can't say for certain whether this is a good idea, though, because I'm not at all familiar with this code.
I have queued up following patch. It is obviously correct and builds without warnings here. Can you give it a try on your box.
Sam
scripts/kconfig/lkc.h +3 -3
@@ -11,9 +11,9 @@#ifndef KBUILD_NO_NLS # include <libintl.h> #else -# define gettext (Msgid) ((const char *) (Msgid)) -# define textdomain (Domainname) ((const char *) (Domainname)) -# define bindtextdomain (Domainname, Dirname) ((const char *) (Dirname)) +static inline void const char *gettext(const char *txt) { return txt; } +static inline void textdomain (const char *domainname) {} +static inline void bindtextdomain (const char *name,const char *dir) {}#endif #ifdef __cplusplus
Quoted 2 lines · Sam Ravnborg
I have queued up following patch. It is obviously correct and builds without warnings here. Can you give it a try on your box.
...
Quoted 1 line
+static inline void const char *gettext(const char *txt) { return txt; }
Drop the "void" on this line and this patch works.
While you're at it, you'll also need this change:
scripts/kconfig/mconf.c +1 -1
@@ -773,7 +773,7 @@ static void conf_string(struct menu *menu)while (1 ) {int res; -char *heading; +const char *heading;
On a side note, git-diff gives me this error in mconf.c:
@@ -924,4 +924,4 @@ int main(int ac, char **av)
}
return 0;-}
+}
\ No newline at end of file
I've never seen it before so I don't know if this is specific to OS X or maybe it's my editor.
Quoted 33 lines · Timur Tabi
Quoted 3 lines · Sam Ravnborg
I have queued up following patch. It is obviously correct and builds without
warnings here. Can you give it a try on your box....
Quoted 1 line
+static inline void const char *gettext(const char *txt) { return txt; }
Drop the "void" on this line and this patch works.
While you're at it, you'll also need this change:
scripts/kconfig/mconf.c +1
-1@@ -773,7 +773,7 @@ static void conf_string(struct menu *menu)while (1 ) {int res; -char *heading; +const char *heading;On a side note, git-diff gives me this error in
mconf.c:scripts/kconfig/mconf.c +1
-1@@ -924,4 +924,4 @@ int main(int ac, char **av) }return 0 ; -} +}
Quoted 2 lines
I've never seen it before so I don't know if this is specific to OS X or maybe it's my editor.
I did your suggested changes and applied the patch. Will be pushed out in a minute.
Sam