public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Kbuild, lto: Avoid reported warning with strtoul
@ 2014-04-18  4:35 Andi Kleen
  2014-04-18  4:49 ` Al Viro
  2014-04-21  4:55 ` Viresh Kumar
  0 siblings, 2 replies; 6+ messages in thread
From: Andi Kleen @ 2014-04-18  4:35 UTC (permalink / raw)
  To: mmarek; +Cc: hpa, linux-kernel, Andi Kleen, Viresh Kumar

From: Andi Kleen <ak@linux.intel.com>

Apparently someone's C library declares strtoul with warn_unused_result.
Cast to void to avoid the warning. Error handling is not useful here.

Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 scripts/mod/modpost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0663556..b9cf439 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1707,7 +1707,7 @@ static char *remove_dot(char *s)
 	int n = strcspn(s, ".");
 
 	if (n > 0 && s[n] != 0) {
-		strtoul(s + n + 1, &end, 10);
+		(void)strtoul(s + n + 1, &end, 10);
 		if  (end > s + n + 1 && (*end == '.' || *end == 0))
 			s[n] = 0;
 	}
-- 
1.8.5.2


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

* Re: [PATCH] Kbuild, lto: Avoid reported warning with strtoul
  2014-04-18  4:35 [PATCH] Kbuild, lto: Avoid reported warning with strtoul Andi Kleen
@ 2014-04-18  4:49 ` Al Viro
  2014-04-18 13:38   ` Andi Kleen
  2014-04-21  4:55 ` Viresh Kumar
  1 sibling, 1 reply; 6+ messages in thread
From: Al Viro @ 2014-04-18  4:49 UTC (permalink / raw)
  To: Andi Kleen; +Cc: mmarek, hpa, linux-kernel, Andi Kleen, Viresh Kumar

On Fri, Apr 18, 2014 at 06:35:56AM +0200, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
> 
> Apparently someone's C library declares strtoul with warn_unused_result.
> Cast to void to avoid the warning. Error handling is not useful here.

Umm...  Since we don't give a fsck for the value, isn't that simply
	
	char *p = strchr(s, '.');
	if (p) {
		size_t m = strspn(p + 1, "0123456789");
		if (m > 0 && (p[m + 1] == '.' || p[m + 1] == '\0'))
			*p = '\0';
	}

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

* Re: [PATCH] Kbuild, lto: Avoid reported warning with strtoul
  2014-04-18  4:49 ` Al Viro
@ 2014-04-18 13:38   ` Andi Kleen
  0 siblings, 0 replies; 6+ messages in thread
From: Andi Kleen @ 2014-04-18 13:38 UTC (permalink / raw)
  To: Al Viro; +Cc: Andi Kleen, mmarek, hpa, linux-kernel, Viresh Kumar

On Fri, Apr 18, 2014 at 05:49:04AM +0100, Al Viro wrote: 
> On Fri, Apr 18, 2014 at 06:35:56AM +0200, Andi Kleen wrote:
> > From: Andi Kleen <ak@linux.intel.com>
> > 
> > Apparently someone's C library declares strtoul with warn_unused_result.
> > Cast to void to avoid the warning. Error handling is not useful here.
> 
> Umm...  Since we don't give a fsck for the value, isn't that simply

Yes your code is equivalent to mine.

-Andi

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

* Re: [PATCH] Kbuild, lto: Avoid reported warning with strtoul
  2014-04-18  4:35 [PATCH] Kbuild, lto: Avoid reported warning with strtoul Andi Kleen
  2014-04-18  4:49 ` Al Viro
@ 2014-04-21  4:55 ` Viresh Kumar
  2014-04-21 16:50   ` Andi Kleen
  1 sibling, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2014-04-21  4:55 UTC (permalink / raw)
  To: Andi Kleen; +Cc: mmarek, H. Peter Anvin, Linux Kernel Mailing List, Andi Kleen

On 18 April 2014 10:05, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> Apparently someone's C library declares strtoul with warn_unused_result.
> Cast to void to avoid the warning. Error handling is not useful here.

I just did a x86_64 compilation without a CROSS_COMPILE= option
(My .config also had a empty string) and so gcc must be used for it?

$ gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
>  scripts/mod/modpost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 0663556..b9cf439 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1707,7 +1707,7 @@ static char *remove_dot(char *s)
>         int n = strcspn(s, ".");
>
>         if (n > 0 && s[n] != 0) {
> -               strtoul(s + n + 1, &end, 10);
> +               (void)strtoul(s + n + 1, &end, 10);

I tried this earlier before reporting and it still had the same problem :(
I tried it again just to cross check and still getting this:

scripts/mod/modpost.c: In function ‘remove_dot’:
scripts/mod/modpost.c:1710:3: warning: ignoring return value of
‘strtoul’, declared with attribute warn_unused_result
[-Wunused-result]

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

* Re: [PATCH] Kbuild, lto: Avoid reported warning with strtoul
  2014-04-21  4:55 ` Viresh Kumar
@ 2014-04-21 16:50   ` Andi Kleen
  2014-04-22  4:19     ` Viresh Kumar
  0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2014-04-21 16:50 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Andi Kleen, mmarek, H. Peter Anvin, Linux Kernel Mailing List

On Mon, Apr 21, 2014 at 10:25:18AM +0530, Viresh Kumar wrote:
> > --- a/scripts/mod/modpost.c
> > +++ b/scripts/mod/modpost.c
> > @@ -1707,7 +1707,7 @@ static char *remove_dot(char *s)
> >         int n = strcspn(s, ".");
> >
> >         if (n > 0 && s[n] != 0) {
> > -               strtoul(s + n + 1, &end, 10);
> > +               (void)strtoul(s + n + 1, &end, 10);
> 
> I tried this earlier before reporting and it still had the same problem :(
> I tried it again just to cross check and still getting this:
> 
> scripts/mod/modpost.c: In function ‘remove_dot’:
> scripts/mod/modpost.c:1710:3: warning: ignoring return value of
> ‘strtoul’, declared with attribute warn_unused_result
> [-Wunused-result]

Hmm that's odd. I guess could assign it to a dummy variable or use
viro's variant.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

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

* Re: [PATCH] Kbuild, lto: Avoid reported warning with strtoul
  2014-04-21 16:50   ` Andi Kleen
@ 2014-04-22  4:19     ` Viresh Kumar
  0 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2014-04-22  4:19 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Andi Kleen, mmarek, H. Peter Anvin, Linux Kernel Mailing List

On 21 April 2014 22:20, Andi Kleen <ak@linux.intel.com> wrote:
> Hmm that's odd. I guess could assign it to a dummy variable

That produces this:

scripts/mod/modpost.c: In function ‘remove_dot’:
scripts/mod/modpost.c:1708:16: warning: variable ‘ignore’ set but not
used [-Wunused-but-set-variable]

> or use viro's variant.

It looks fine but can't test if works exactly the same way as current
implementation.

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

end of thread, other threads:[~2014-04-22  4:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-18  4:35 [PATCH] Kbuild, lto: Avoid reported warning with strtoul Andi Kleen
2014-04-18  4:49 ` Al Viro
2014-04-18 13:38   ` Andi Kleen
2014-04-21  4:55 ` Viresh Kumar
2014-04-21 16:50   ` Andi Kleen
2014-04-22  4:19     ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox