All of lore.kernel.org
 help / color / mirror / Atom feed
* mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X
@ 2008-05-04  3:58 Timur Tabi
  2008-05-04  7:33 ` Sam Ravnborg
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2008-05-04  3:58 UTC (permalink / raw)
  To: linux-kernel

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.o
scripts/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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X
  2008-05-04  3:58 mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X Timur Tabi
@ 2008-05-04  7:33 ` Sam Ravnborg
  2008-05-04 18:42   ` Timur Tabi
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2008-05-04  7:33 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linux-kernel

On Sat, May 03, 2008 at 10:58:04PM -0500, Timur Tabi wrote:
> 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.o
> scripts/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.

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

diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 4bc68f2..1a728fc 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X
  2008-05-04  7:33 ` Sam Ravnborg
@ 2008-05-04 18:42   ` Timur Tabi
  2008-05-04 19:08     ` Sam Ravnborg
  0 siblings, 1 reply; 4+ messages in thread
From: Timur Tabi @ 2008-05-04 18:42 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kernel

Sam Ravnborg wrote:

> I have queued up following patch. It is obviously correct and builds without
> warnings here. Can you give it a try on your box.

...

> +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:

--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X
  2008-05-04 18:42   ` Timur Tabi
@ 2008-05-04 19:08     ` Sam Ravnborg
  0 siblings, 0 replies; 4+ messages in thread
From: Sam Ravnborg @ 2008-05-04 19:08 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linux-kernel

On Sun, May 04, 2008 at 01:42:34PM -0500, Timur Tabi wrote:
> Sam Ravnborg wrote:
> 
> >I have queued up following patch. It is obviously correct and builds 
> >without
> >warnings here. Can you give it a try on your box.
> 
> ...
> 
> >+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:
> 
> --- a/scripts/kconfig/mconf.c
> +++ b/scripts/kconfig/mconf.c
> @@ -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.

I did your suggested changes and applied the patch.
Will be pushed out in a minute.

	Sam



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-04 19:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-04  3:58 mconf.c and bindtextdomain() -- warnings while cross-compiling on OS X Timur Tabi
2008-05-04  7:33 ` Sam Ravnborg
2008-05-04 18:42   ` Timur Tabi
2008-05-04 19:08     ` Sam Ravnborg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.