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

Cyril Hrubis chrubis@suse.cz
Fri Nov 19 15:44:39 CET 2021


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;
-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list