Menu

#13 get_semaphore shouldn't work at all

open
nobody
None
5
2003-12-06
2003-12-06
No

in
http://cvs.sourceforge.net/viewcvs.py/autoopencas/OCC/OCC/src/OSD/OSD_Csemaphore.c?rev=1.10&view=auto

int
get_semaphore(int *semid, int *event, int *value)
/*=================================================

GET semaphore counter value

==========================================================================*/
{
int status;

#ifdef SEMCTL_NO_REFERENCE
status = semctl((*semid),*event,GETVAL,value);
#else
status = semctl((*semid),*event,GETVAL,&value);
#endif

if (status < 0) return(0);
else return(1);

}

I suppose that the intended contract is that value
points to a valid integer representing the value of the
semaphore and the function returns a boolean denoting
success.

unfortunaly, semctl(2) used with the GETVAL argument
*returns* the counter value and don't take any useful
fourth arguent. Error is detected by a negative value.

It seems that this function is never used, that's why
this remainded undetected.

Discussion


Log in to post a comment.