Re: shmat() return values?
- From: Marc Olzheim <marcolz@xxxxxxxx>
- Date: Tue, 27 May 2008 09:45:18 +0200
On Mon, May 26, 2008 at 08:14:38PM +0300, Krassimir Slavchev wrote:
Hello,
When I try:
if ((*shm = shmat(shmid, NULL, 0)) == -1)
The gcc complains with:
warning: comparison between pointer and integer
shmat() is declared in shm.h as:
void *shmat(int, const void *, int);
but 'man 4 shmat;
RETURN VALUES
Upon success, shmat() returns the address where the segment is
attached;
otherwise, -1 is returned and errno is set to indicate the error.
What is the correct return value on failure, -1 or NULL?
I think it should be NULL?
The return value is a void pointer, with value equivalent to -1,
so (void *)-1
So you can replace it with:
if ((*shm = shmat(shmid, NULL, 0)) == (void*)-1)
Marc
_______________________________________________
freebsd-stable@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@xxxxxxxxxxx"
- References:
- shmat() return values?
- From: Krassimir Slavchev
- shmat() return values?
- Prev by Date: ath network (wifi) driver (Fujitsu Siemens Amilo Pro V3515 laptop)
- Next by Date: Re: sched_ule performance on single CPU
- Previous by thread: shmat() return values?
- Next by thread: ath network (wifi) driver (Fujitsu Siemens Amilo Pro V3515 laptop)
- Index(es):
Relevant Pages
|
|