LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] time: Fix constant size in kernel/timeconst.h
@ 2008-02-09 13:20 Johann Felix Soden
  2008-02-09 21:33 ` H. Peter Anvin
  0 siblings, 1 reply; 3+ messages in thread
From: Johann Felix Soden @ 2008-02-09 13:20 UTC (permalink / raw)
  To: Andrew Morton; +Cc: H. Peter Anvin, linux-kernel

From: Johann Felix Soden <johfel@users.sourceforge.net>

kernel/timeconst.pl generates only long sized constants in timeconst.pl
which gives this warning:

kernel/time.c: In function 'msecs_to_jiffies':
kernel/time.c:472: warning: integer constant is too large for 'long' type

unsigned long long is needed.

Signed-off-by: Johann Felix Soden <johfel@users.sourceforge.net>
CC: H. Peter Anvin <hpa@zytor.com>
---
 kernel/timeconst.pl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/timeconst.pl b/kernel/timeconst.pl
index 62b1287..a645654 100644
--- a/kernel/timeconst.pl
+++ b/kernel/timeconst.pl
@@ -342,12 +342,12 @@ sub output($@)
 		      'USEC_TO_HZ','HZ_TO_USEC') {
 		foreach $bit (32, 64) {
 			foreach $suf ('MUL', 'ADJ', 'SHR') {
-				printf "#define %-23s %s\n",
+				printf "#define %-23s %sULL\n",
 					"${pfx}_$suf$bit", shift(@val);
 			}
 		}
 		foreach $suf ('NUM', 'DEN') {
-			printf "#define %-23s %s\n",
+			printf "#define %-23s %sULL\n",
 				"${pfx}_$suf", shift(@val);
 		}
 	}
-- 
1.5.4




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

* Re: [PATCH] time: Fix constant size in kernel/timeconst.h
  2008-02-09 13:20 [PATCH] time: Fix constant size in kernel/timeconst.h Johann Felix Soden
@ 2008-02-09 21:33 ` H. Peter Anvin
  2008-02-09 22:29   ` Johann Felix Soden
  0 siblings, 1 reply; 3+ messages in thread
From: H. Peter Anvin @ 2008-02-09 21:33 UTC (permalink / raw)
  To: Johann Felix Soden; +Cc: Andrew Morton, linux-kernel

Johann Felix Soden wrote:
> From: Johann Felix Soden <johfel@users.sourceforge.net>
> 
> kernel/timeconst.pl generates only long sized constants in timeconst.pl
> which gives this warning:
> 
> kernel/time.c: In function 'msecs_to_jiffies':
> kernel/time.c:472: warning: integer constant is too large for 'long' type
> 
> unsigned long long is needed.
> 

Hm, you've just taken a warning and elevated it to a bug.

According to the C standard, a constant has the shortest type (>= int) 
needed to hold the constant, and the warning above is somewhat bogus in 
that context (what version of gcc is that, anyway?)

ULL is only appropriate to 32-bit machines, or there will be other 
issues downstream.  The Right Way[TM] to do this would be to get Linux 
to have the [U]INTxx_C() macros from C99.

	-hpa


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

* Re: [PATCH] time: Fix constant size in kernel/timeconst.h
  2008-02-09 21:33 ` H. Peter Anvin
@ 2008-02-09 22:29   ` Johann Felix Soden
  0 siblings, 0 replies; 3+ messages in thread
From: Johann Felix Soden @ 2008-02-09 22:29 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: linux-kernel

H. Peter Anvin wrote:
> Johann Felix Soden wrote:
> > kernel/timeconst.pl generates only long sized constants in timeconst.pl
> > which gives this warning:
> > 
> > kernel/time.c: In function 'msecs_to_jiffies':
> > kernel/time.c:472: warning: integer constant is too large for 'long' type
> > 
> > unsigned long long is needed.
> Hm, you've just taken a warning and elevated it to a bug.
> 
> According to the C standard, a constant has the shortest type (>= int) 
> needed to hold the constant, and the warning above is somewhat bogus in 
> that context (what version of gcc is that, anyway?)
> 
> ULL is only appropriate to 32-bit machines, or there will be other 
> issues downstream.  The Right Way[TM] to do this would be to get Linux 
> to have the [U]INTxx_C() macros from C99.
> 
> 	-hpa

Sorry for this. Thanks for teaching about the C standard.
About your question: gcc 4.2.3 gave me this warning.
And I'm a little bit surprised because the kernel code is full of
constants with ULL. Is kernel/time.c a special case?

J. F. Soden



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

end of thread, other threads:[~2008-02-09 22:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-09 13:20 [PATCH] time: Fix constant size in kernel/timeconst.h Johann Felix Soden
2008-02-09 21:33 ` H. Peter Anvin
2008-02-09 22:29   ` Johann Felix Soden

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).