[LTP] [PATCH] clnt_create: Determine the return value of clnt_create()
Petr Vorel
pvorel@suse.cz
Tue Oct 22 09:50:06 CEST 2024
Hi Ma,
Thanks a lot, merged!
BTW I see some of the tests already had error control and they just printed 1
instead of rpc_createerr.cf_stat (rpc_clnt_call_dataint.c). Some other report
5 (e.g. rpc_clnt_call_performance.c).
> Determine the return value of clnt_create() to avoid segmentation fault
> when executing clnt_destroy() when the return value of create is NULL.
...
> +++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnt_create/rpc_clnt_create_stress.c
> @@ -59,6 +59,12 @@ int main(int argn, char *argc[])
> if (clnt != NULL)
> nbOk++;
> + else {
> + clnt_pcreateerror("err");
> + printf("%d\n", rpc_createerr.cf_stat);
> +
> + return 1;
> + }
> }
I reversed the condition of the check (more readable code):
if (clnt == NULL) {
clnt_pcreateerror("err");
printf("%d\n", rpc_createerr.cf_stat);
return 1;
}
nbOk++;
The testsuite contains a lot of duplicity and useless code. It could be
rewritten to use simple macro to remove most of the redundancy.
Kind regards,
Petr
More information about the ltp
mailing list