Re: [Powertop] [Warning fixes 5/6] Fix warning: warning: this decimal constant is unsigned only in ISO C90 [enabled by default] by explicitely declaring the value as UL
Joerg Mayer <jmpt at loplof.de> Sat, 25 Aug 2012 00:01:34 +0200
| Newsgroups | dev.linux.lists.powertop |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Aug 24, 2012 at 11:54:33PM +0200, Joerg Mayer wrote:
> On Fri, Aug 24, 2012 at 08:18:58PM +0000, Howard, James D wrote:
> > A change was suggested in .../cpu.cpp at or near line 975, explicitly adding the "UL" suffix to the decimal integer literal:
> > 4294967295 --> 4294967295UL
> > Is that the right thing to do? This is "ULONG_MAX" (for machines with 32-bit "word" size). Would it be more correct to use the identifier ULONG_MAX? In modern #include files, <limits.h> (for example) correctly provides the "UL" suffix.
>
> If __WORDSIZE is 32 on all architectures that powertop will run on,
> then yes, we should use ULONG_MAX instead. I will have to find out about
> WORDSIZE on 64 bit architectures, as I'm still on a 32 bit system.
>
> On sytems with __WORDSIZE of 64 bits ULONG_MAX is 18446744073709551615UL.
>
> But that's something I will look at after a night's sleep.
OK, this was much less work than I thought:
On a 64 bit system that I have access to, /usr/include/bits/wordsize.h:
#if defined __x86_64__
# define __WORDSIZE 64
# define __WORDSIZE_COMPAT32 1
#else
# define __WORDSIZE 32
#endif
So I think the answer to your question should be "no", we should not use
ULONG_MAX.
Ciao
Jaƶrg
--
Joerg Mayer <jmayer(a)loplof.de>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.