[LTP] [PATCH 2/2] sctputil.h: TCONF on EAFNOSUPPORT

Cyril Hrubis chrubis@suse.cz
Thu Feb 17 10:56:07 CET 2022


Hi!
> diff --git a/utils/sctp/testlib/sctputil.h b/utils/sctp/testlib/sctputil.h
> index 1e21760bec..c4bedb47cf 100644
> --- a/utils/sctp/testlib/sctputil.h
> +++ b/utils/sctp/testlib/sctputil.h
> @@ -133,9 +133,14 @@ extern int TST_CNT;
>  static inline int test_socket(int domain, int type, int protocol)
>  {
>  	int sk = socket(domain, type, protocol);
> +	int res = TBROK;
>  
> -	if (sk == -1)
> -		tst_brkm(TBROK, tst_exit, "socket: %s", strerror(errno));
> +	if (sk == -1) {
> +		if (errno == EAFNOSUPPORT)
> +			res = TCONF;
> +
> +		tst_brkm(res, tst_exit, "socket: %s", strerror(errno));
> +	}

I would keep the messages separated here, i.e. do something as:

	if (errno == EAFNOSUPPORT)
		tst_brkm(TBROK | TERRNO, "socket(%i, %i, %i) not supported",
			 domain, type, protocol);

	tst_brkm(TBROK | TERRNO, "socket()");


Btw this code actually duplicates the safe_socket() function we do have
already, so it may as well be easier to just replace the test_socket()
with SAFE_SOCKET() in the tests...

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list