* Warning with asm-generic/div64.h
@ 2011-03-25 10:19 Guan Xuetao
2011-03-25 13:39 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Guan Xuetao @ 2011-03-25 10:19 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: linux-kernel, linux-arch
Hi, Arnd:
Following warning is generated when using <asm-generic/div64.h>
kernel/power/hibernate.c: In function 'swsusp_show_speed':
kernel/power/hibernate.c:227: warning: comparison of distinct pointer types lacks a cast
After expanding the do_div() macro, the problem line is:
(void)(((typeof((n)) *)0) == ((uint64_t *)0));
while the type of n is s64.
I am puzzled with the usage of the problem line.
And how to correct it?
Guan Xuetao
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning with asm-generic/div64.h
2011-03-25 10:19 Warning with asm-generic/div64.h Guan Xuetao
@ 2011-03-25 13:39 ` Arnd Bergmann
2011-03-29 11:41 ` Guan Xuetao
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2011-03-25 13:39 UTC (permalink / raw)
To: Guan Xuetao; +Cc: linux-kernel, linux-arch
On Friday 25 March 2011, Guan Xuetao wrote:
> Following warning is generated when using <asm-generic/div64.h>
>
> kernel/power/hibernate.c: In function 'swsusp_show_speed':
> kernel/power/hibernate.c:227: warning: comparison of distinct pointer types lacks a cast
>
> After expanding the do_div() macro, the problem line is:
>
> (void)(((typeof((n)) *)0) == ((uint64_t *)0));
>
> while the type of n is s64.
>
> I am puzzled with the usage of the problem line.
>
> And how to correct it?
The purpose of this line is to generate a warning when the input is the
wrong type, as the comment says:
/* The unnecessary pointer compare is there
* to check for type safety (n must be 64bit)
The macro doesn't work for signed input or for 32 bit input. I'd suggest
fixing the caller to use an unsigned type.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Warning with asm-generic/div64.h
2011-03-25 13:39 ` Arnd Bergmann
@ 2011-03-29 11:41 ` Guan Xuetao
2011-03-29 11:58 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Guan Xuetao @ 2011-03-29 11:41 UTC (permalink / raw)
To: 'Arnd Bergmann'
Cc: linux-kernel, linux-arch, 'Len Brown',
'Pavel Machek', 'Rafael J. Wysocki', linux-pm
> -----Original Message-----
> From: Arnd Bergmann [mailto:arnd@arndb.de]
> Sent: Friday, March 25, 2011 9:40 PM
> To: Guan Xuetao
> Cc: linux-kernel@vger.kernel.org; linux-arch@vger.kernel.org
> Subject: Re: Warning with asm-generic/div64.h
>
> On Friday 25 March 2011, Guan Xuetao wrote:
> > Following warning is generated when using <asm-generic/div64.h>
> >
> > kernel/power/hibernate.c: In function 'swsusp_show_speed':
> > kernel/power/hibernate.c:227: warning: comparison of distinct pointer types lacks a cast
> >
> > After expanding the do_div() macro, the problem line is:
> >
> > (void)(((typeof((n)) *)0) == ((uint64_t *)0));
> >
> > while the type of n is s64.
> >
> > I am puzzled with the usage of the problem line.
> >
> > And how to correct it?
>
> The purpose of this line is to generate a warning when the input is the
> wrong type, as the comment says:
> /* The unnecessary pointer compare is there
> * to check for type safety (n must be 64bit)
Yes, it works. And, I think type s64 should be ok also.
>
> The macro doesn't work for signed input or for 32 bit input. I'd suggest
> fixing the caller to use an unsigned type.
Then,
Cc: Len Brown <len.brown@intel.com> (supporter:SUSPEND TO RAM)
Cc: Pavel Machek <pavel@ucw.cz> (supporter:SUSPEND TO RAM)
Cc: "Rafael J. Wysocki" <rjw@sisk.pl> (supporter:SUSPEND TO RAM)
Cc: linux-pm@lists.linux-foundation.org (open list:SUSPEND TO RAM)
>
> Arnd
Thanks, and sorry for replying late.
Guan Xuetao
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning with asm-generic/div64.h
2011-03-29 11:41 ` Guan Xuetao
@ 2011-03-29 11:58 ` Arnd Bergmann
2011-03-29 11:58 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2011-03-29 11:58 UTC (permalink / raw)
To: Guan Xuetao
Cc: linux-kernel, linux-arch, 'Len Brown',
'Pavel Machek', 'Rafael J. Wysocki', linux-pm
On Tuesday 29 March 2011, Guan Xuetao wrote:
> > The macro doesn't work for signed input or for 32 bit input. I'd suggest
> > fixing the caller to use an unsigned type.
>
> Then,
> Cc: Len Brown <len.brown@intel.com> (supporter:SUSPEND TO RAM)
> Cc: Pavel Machek <pavel@ucw.cz> (supporter:SUSPEND TO RAM)
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> (supporter:SUSPEND TO RAM)
> Cc: linux-pm@lists.linux-foundation.org (open list:SUSPEND TO RAM)
Yes, that sounds right.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Warning with asm-generic/div64.h
2011-03-29 11:58 ` Arnd Bergmann
@ 2011-03-29 11:58 ` Arnd Bergmann
0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2011-03-29 11:58 UTC (permalink / raw)
To: Guan Xuetao
Cc: linux-kernel, linux-arch, 'Len Brown',
'Pavel Machek', 'Rafael J. Wysocki', linux-pm
On Tuesday 29 March 2011, Guan Xuetao wrote:
> > The macro doesn't work for signed input or for 32 bit input. I'd suggest
> > fixing the caller to use an unsigned type.
>
> Then,
> Cc: Len Brown <len.brown@intel.com> (supporter:SUSPEND TO RAM)
> Cc: Pavel Machek <pavel@ucw.cz> (supporter:SUSPEND TO RAM)
> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> (supporter:SUSPEND TO RAM)
> Cc: linux-pm@lists.linux-foundation.org (open list:SUSPEND TO RAM)
Yes, that sounds right.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-29 11:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-25 10:19 Warning with asm-generic/div64.h Guan Xuetao
2011-03-25 13:39 ` Arnd Bergmann
2011-03-29 11:41 ` Guan Xuetao
2011-03-29 11:58 ` Arnd Bergmann
2011-03-29 11:58 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox