[LTP] [PATCH 02/12] posix/mq_(timed)send/5-1: Fix error reporting

Joerg Vehlow lkml@jv-coder.de
Mon Nov 22 07:45:21 CET 2021


Hi Cyril,

On 11/19/2021 3:44 PM, Cyril Hrubis wrote:
> Hi!
> Applied, thanks.
>
>> --- a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> +++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c
>> @@ -58,7 +58,6 @@ int main(void)
>>   	char msgrcd[BUFFER];
>>   	const char *msgptr = MSGSTR;
>>   	struct mq_attr attr;
>> -	int unresolved = 0;
>>   	unsigned pri;
>>   
>>   	sprintf(gqname, "/mq_timedsend_5-1_%d", getpid());
>> @@ -119,7 +118,10 @@ int main(void)
>>   		/* receive message and allow blocked send to complete */
>>   		if (mq_receive(gqueue, msgrcd, BUFFER, &pri) == -1) {
>>   			perror("mq_receive() did not return success");
>> -			unresolved = 1;
>> +			kill(pid, SIGKILL);	//kill child
>> +			mq_close(gqueue);
>> +			mq_unlink(gqname);
>> +			return PTS_UNRESOLVED;
>>   		}
> There is another place where it does not clean up the queue in the code
> under the if (j == MAXMSG+1) condition, that should be fixed as well.
>
> Also I guess the cleanest way how to write this test would be a kernel
> style goto cleanup. E.g.:
>
> 	int rval = PTS_UNRESOLVED;
>
>
> 	if (foo) {
> 		rval = PTS_FAIL;
> 		goto ret;
> 	}
>
> 	if (bar)
> 		goto ret;
>
> 	...
>
> 	pid = 0;
> ret:
> 	if (pid)
> 		kill(pid, SIGKILL);
> 	mq_close(queue);
> 	mq_unlink(queue);
> 	return rval;
You are right, but I wanted to keep changes minimal. I think there are 
lots of small bug in the posix tests,
but fixing all of them while trying to just get rid of warnings, would 
have made this patchset even bigger and
I would have never finished. So I had to stop somewhere.

Joerg


More information about the ltp mailing list