Skip to contentSkip to conversation

compiler warnings and syscall macros

DISCUSSION Chris Friesen 3 participants 6 messages Sep 22, 2003 – Sep 23, 2003

lore
Share & tools
lore
#0 lore raw

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

Signature · 4 lines
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: [email protected]
#1 lore raw

Uttered Chris Friesen <[email protected]>, spoke thus:

Quoted 3 lines

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?

#3 lore raw
In reply to Chris Friesen
Followup to:  <[email protected]>
By author:    Chris Friesen <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 19 lines

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
Quoted 3 lines

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

Signature · 4 lines
<[email protected]> at work, <[email protected]> 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
#5 lore raw
In reply to Chris Friesen
Followup to:  <[email protected]>
By author:    Chris Friesen <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 19 lines

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
Quoted 3 lines

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

Signature · 4 lines
<[email protected]> at work, <[email protected]> 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
#4 lore raw
In reply to H. Peter Anvin
Followup to:  <[email protected]>
By author:    "H. Peter Anvin" <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 6 lines

Just do:

__sc_ret = -1UL;

-hpa

... sorry for the dupes; client said post hadn't happened when in fact it had.

-hpa

Signature · 4 lines
<[email protected]> at work, <[email protected]> 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
#2 lore raw
In reply to Tommy Reynolds
Quoted 5 lines · Tommy Reynolds

Why not do the obvious:

	__sc_ret = -1UL;

and use a proper constant?

Cause I'm not thinking straight?

Chris

Signature · 4 lines
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: [email protected]