linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Remove 'strchr' warning from reiserfs
@ 2003-05-17 19:16 Sam Ravnborg
  2003-05-19 19:47 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2003-05-17 19:16 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: reiserfs-dev, linux-kernel

Hi Linus, please apply - maintainer cc:ed for info.

Reiserfs emits a warning about strchr being defined but not
used. I finally tracked down the reason for this.
gcc - when seeing strstr(x, "%") recognized that the second parameter
is a char, and therefore uses strchr instead of strstr.
The workaround to avoid the warning is to replace the call
to strstr with strchr - which is OK.

This hides the warning, and brings us down to 6 warnings for a
make defconfig bzImage.

	Sam

===== fs/reiserfs/prints.c 1.21 vs edited =====
--- 1.21/fs/reiserfs/prints.c	Sun Mar 23 07:14:13 2003
+++ edited/fs/reiserfs/prints.c	Sat May 17 21:08:16 2003
@@ -164,7 +164,7 @@
 
   *skip = 0;
   
-  while ((k = strstr (k, "%")) != NULL)
+  while ((k = strchr (k, '%')) != NULL)
   {
     if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' ||
 	      k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a' ) {

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

* Re: [PATCH] Remove 'strchr' warning from reiserfs
  2003-05-17 19:16 [PATCH] Remove 'strchr' warning from reiserfs Sam Ravnborg
@ 2003-05-19 19:47 ` Stephen Hemminger
  2003-05-19 21:33   ` Sam Ravnborg
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2003-05-19 19:47 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: torvalds, reiserfs-dev, linux-kernel

On Sat, 17 May 2003 21:16:11 +0200
Sam Ravnborg <sam@ravnborg.org> wrote:

> Hi Linus, please apply - maintainer cc:ed for info.
> 
> Reiserfs emits a warning about strchr being defined but not
> used. I finally tracked down the reason for this.
> gcc - when seeing strstr(x, "%") recognized that the second parameter
> is a char, and therefore uses strchr instead of strstr.
> The workaround to avoid the warning is to replace the call
> to strstr with strchr - which is OK.
> 
> This hides the warning, and brings us down to 6 warnings for a
> make defconfig bzImage.
> 
> 	Sam

Good job finding this, several others have looked and never found what
was causing it.  Is this gcc behaviour documented anywhere?  What other
surprises are there?

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

* Re: [PATCH] Remove 'strchr' warning from reiserfs
  2003-05-19 19:47 ` Stephen Hemminger
@ 2003-05-19 21:33   ` Sam Ravnborg
  2003-05-20  0:26     ` Kurt Wall
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Ravnborg @ 2003-05-19 21:33 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Sam Ravnborg, torvalds, reiserfs-dev, linux-kernel

On Mon, May 19, 2003 at 12:47:12PM -0700, Stephen Hemminger wrote:
> 
> Is this gcc behaviour documented anywhere?

I dropped a mail to gcc-bugs - the reply was:

=======
The kernel is a special case; GCC is entitled to assume the existence of
standard C library functions.
=======

So when messing with standard functions we may expect a few suprises,
which I think is fair enough.

	Sam

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

* Re: [PATCH] Remove 'strchr' warning from reiserfs
  2003-05-19 21:33   ` Sam Ravnborg
@ 2003-05-20  0:26     ` Kurt Wall
  0 siblings, 0 replies; 4+ messages in thread
From: Kurt Wall @ 2003-05-20  0:26 UTC (permalink / raw)
  To: reiserfs-dev, linux-kernel

An unnamed Administration source, Sam Ravnborg, wrote:
% On Mon, May 19, 2003 at 12:47:12PM -0700, Stephen Hemminger wrote:
% > 
% > Is this gcc behaviour documented anywhere?
% 
% I dropped a mail to gcc-bugs - the reply was:
% 
% =======
% The kernel is a special case; GCC is entitled to assume the existence of
% standard C library functions.
% =======
% 
% So when messing with standard functions we may expect a few suprises,
% which I think is fair enough.

Hmm. And -nostdlib (or -nodefaultlibs) doesn't catch it?

K
-- 
According to Kentucky state law, every person must take a bath at least
once a year.

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

end of thread, other threads:[~2003-05-20  0:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-17 19:16 [PATCH] Remove 'strchr' warning from reiserfs Sam Ravnborg
2003-05-19 19:47 ` Stephen Hemminger
2003-05-19 21:33   ` Sam Ravnborg
2003-05-20  0:26     ` Kurt Wall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).