* compiler warnings and syscall macros
@ 2003-09-22 21:35 Chris Friesen
2003-09-22 21:51 ` Tommy Reynolds
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Chris Friesen @ 2003-09-22 21:35 UTC (permalink / raw)
To: linux-kernel
I'm trying to figure something out. For ppc, in asm/unistd.h,
__syscall_nr is defined as:
#define __syscall_nr(nr, type, name, args...) \
unsigned long __sc_ret, __sc_err; \
{ \
<snipped for brevity>
} \
if (__sc_err & 0x10000000) \
{ \
errno = __sc_ret; \
__sc_ret = -1; \
} \
return (type) __sc_ret
Whenever I use this in my code, I get compiler warnings about the
statment "__sc_ret = -1" since it is assigning a negative value to an
unsigned int.
Would it hurt anything if I put in an explicit cast, like this?
__sc_ret = (unsigned long) -1;
This seems to get rid of the warnings, and I can't imagine it hurting
anything.
Am I missing something bad here?
Chris
--
Chris Friesen | MailStop: 043/33/F10
Nortel Networks | work: (613) 765-0557
3500 Carling Avenue | fax: (613) 765-2986
Nepean, ON K2H 8E9 Canada | email: cfriesen@nortelnetworks.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: compiler warnings and syscall macros
2003-09-22 21:35 compiler warnings and syscall macros Chris Friesen
@ 2003-09-22 21:51 ` Tommy Reynolds
2003-09-23 14:23 ` Chris Friesen
2003-09-22 22:49 ` H. Peter Anvin
2003-09-22 22:49 ` H. Peter Anvin
2 siblings, 1 reply; 6+ messages in thread
From: Tommy Reynolds @ 2003-09-22 21:51 UTC (permalink / raw)
To: Chris Friesen; +Cc: linux-kernel
Uttered Chris Friesen <cfriesen@nortelnetworks.com>, spoke thus:
> Would it hurt anything if I put in an explicit cast, like this?
>
> __sc_ret = (unsigned long) -1;
Why not do the obvious:
__sc_ret = -1UL;
and use a proper constant?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: compiler warnings and syscall macros
2003-09-22 21:35 compiler warnings and syscall macros Chris Friesen
2003-09-22 21:51 ` Tommy Reynolds
@ 2003-09-22 22:49 ` H. Peter Anvin
2003-09-22 23:08 ` H. Peter Anvin
2003-09-22 22:49 ` H. Peter Anvin
2 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2003-09-22 22:49 UTC (permalink / raw)
To: linux-kernel, cfriesen
Followup to: <3F6F6B1B.9040609@nortelnetworks.com>
By author: Chris Friesen <cfriesen@nortelnetworks.com>
In newsgroup: linux.dev.kernel
>
>
> I'm trying to figure something out. For ppc, in asm/unistd.h,
> __syscall_nr is defined as:
>
>
> #define __syscall_nr(nr, type, name, args...) \
> unsigned long __sc_ret, __sc_err; \
> { \
> <snipped for brevity>
> } \
> if (__sc_err & 0x10000000) \
> { \
> errno = __sc_ret; \
> __sc_ret = -1; \
> } \
> return (type) __sc_ret
>
>
> Whenever I use this in my code, I get compiler warnings about the
> statment "__sc_ret = -1" since it is assigning a negative value to an
> unsigned int.
Just do:
__sc_ret = -1UL;
-hpa
--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: compiler warnings and syscall macros
2003-09-22 22:49 ` H. Peter Anvin
@ 2003-09-22 23:08 ` H. Peter Anvin
0 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2003-09-22 23:08 UTC (permalink / raw)
To: linux-kernel
Followup to: <200309222253.PAA21087@cesium.transmeta.com>
By author: "H. Peter Anvin" <hpa@zytor.com>
In newsgroup: linux.dev.kernel
>
> Just do:
>
> __sc_ret = -1UL;
>
> -hpa
... sorry for the dupes; client said post hadn't happened when in fact
it had.
-hpa
--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: compiler warnings and syscall macros
2003-09-22 21:35 compiler warnings and syscall macros Chris Friesen
2003-09-22 21:51 ` Tommy Reynolds
2003-09-22 22:49 ` H. Peter Anvin
@ 2003-09-22 22:49 ` H. Peter Anvin
2 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2003-09-22 22:49 UTC (permalink / raw)
To: linux-kernel, cfriesen
Followup to: <3F6F6B1B.9040609@nortelnetworks.com>
By author: Chris Friesen <cfriesen@nortelnetworks.com>
In newsgroup: linux.dev.kernel
>
>
> I'm trying to figure something out. For ppc, in asm/unistd.h,
> __syscall_nr is defined as:
>
>
> #define __syscall_nr(nr, type, name, args...) \
> unsigned long __sc_ret, __sc_err; \
> { \
> <snipped for brevity>
> } \
> if (__sc_err & 0x10000000) \
> { \
> errno = __sc_ret; \
> __sc_ret = -1; \
> } \
> return (type) __sc_ret
>
>
> Whenever I use this in my code, I get compiler warnings about the
> statment "__sc_ret = -1" since it is assigning a negative value to an
> unsigned int.
Just do:
__sc_ret = -1UL;
-hpa
--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
If you send me mail in HTML format I will assume it's spam.
"Unix gives you enough rope to shoot yourself in the foot."
Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-09-23 14:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-22 21:35 compiler warnings and syscall macros Chris Friesen
2003-09-22 21:51 ` Tommy Reynolds
2003-09-23 14:23 ` Chris Friesen
2003-09-22 22:49 ` H. Peter Anvin
2003-09-22 23:08 ` H. Peter Anvin
2003-09-22 22:49 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox