Re: 0xdeadbeef vs 0xdeadbeefL
From: tom st denis (tomstdenis_at_yahoo.com)
Date: 07/07/04
- Previous message: David S. Miller: "Re: 2.6.7-mm6"
- In reply to: David Eger: "0xdeadbeef vs 0xdeadbeefL"
- Next in thread: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: 0xdeadbeef vs 0xdeadbeefL"
- Reply: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: 0xdeadbeef vs 0xdeadbeefL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 6 Jul 2004 17:06:12 -0700 (PDT) To: linux-kernel@vger.kernel.org
--- David Eger <eger@havoc.gtf.org> wrote:
> Is there a reason to add the 'L' to such a 32-bit constant like this?
> There doesn't seem a great rhyme to it in the headers...
IIRC it should have the L [probably UL instead] since numerical
constants are of type ``int'' by default.
Normally this isn't a problem since int == long on most platforms that
run Linux. However, by the standard 0xdeadbeef is not a valid unsigned
long constant.
Consider the following...
#include <stdio.h>
int main(void)
{
unsigned int x;
x = 4;
if (x < 0xdeadbeef) printf("hello");
return 0;
}
If you run splint on that you get
---
Splint 3.1.1 --- 13 Jun 2004
test2.c: (in function main)
test2.c:7:7: Operands of < have incompatible types (unsigned int, int):
x < 0xdeadbeef
To ignore signs in type comparisons use +ignoresigns
Finished checking --- 1 code warning
---
As far as I know splint follows C99 which means that it thinks the
constant is "int".
Tom
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Previous message: David S. Miller: "Re: 2.6.7-mm6"
- In reply to: David Eger: "0xdeadbeef vs 0xdeadbeefL"
- Next in thread: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: 0xdeadbeef vs 0xdeadbeefL"
- Reply: viro_at_parcelfarce.linux.theplanet.co.uk: "Re: 0xdeadbeef vs 0xdeadbeefL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|