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.