[LTP] [PATCH 1/2] rpc/rpc-tirpc: Fix compile error on clang when using clnt_broadcast

Yang Xu xuyang2018.jy@fujitsu.com
Tue Apr 25 11:12:09 CEST 2023


When clang upgrade to 16.0.0-2.fc38, these case will report
incompatible-function-pointer-types  error as below:

rpc_clnt_broadcast_complex.c:81:46: error: incompatible function pointer types passing
'bool_t (char *, struct sockaddr_in *)' (aka 'int (char *, struct sockaddr_in *)') to
parameter of type 'resultproc_t' (aka 'int (*)(char *, ...)') [-Wincompatible-function-pointer-types]
(xdrproc_t) xdr_int, (char *)&varRec, eachResult);

the clnt_broadcase declare as below:
extern enum clnt_stat   clnt_broadcast(u_long, u_long, u_long,
                                         xdrproc_t, void *,
                                         xdrproc_t, void *,
                                         resultproc_t);

so we should add resultproc_t cast like tirpc_simple_rpc_broadcast[1] does.

[1]https://github.com/linux-test-project/ltp/blob/master/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_simple_rpc_broadcast/tirpc_rpc_broadcast_complex.c#L84

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 .../rpc_clnt_broadcast.c                          |  3 ++-
 .../rpc_clnt_broadcast_complex.c                  |  3 ++-
 .../rpc_clnt_broadcast_dataint.c                  | 15 ++++++++++-----
 .../rpc_clnt_broadcast_performance.c              |  2 +-
 .../rpc_clnt_broadcast_scalability.c              |  2 +-
 .../rpc_clnt_broadcast_stress.c                   |  2 +-
 6 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast.c
index 5f024f113..80d5f045a 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast.c
@@ -59,7 +59,8 @@ int main(int argn, char *argc[])
 	//Call broadcast routine
 	cs = clnt_broadcast(progNum, VERSNUM, PROCNUM,
 			    (xdrproc_t) xdr_int, (char *)&varSnd,
-			    (xdrproc_t) xdr_int, (char *)&varRec, eachResult);
+			    (xdrproc_t) xdr_int, (char *)&varRec,
+			    (resultproc_t) eachResult);
 
 	test_status = (cs == RPC_SUCCESS) ? 0 : 1;
 
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_complex.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_complex.c
index c6e55cd81..e1bb8fcc5 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_complex.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_complex.c
@@ -78,7 +78,8 @@ int main(int argn, char *argc[])
 	//Call broadcast routine
 	cs = clnt_broadcast(progNum, VERSNUM, PROCNUM,
 			    (xdrproc_t) xdr_int, (char *)&varSnd,
-			    (xdrproc_t) xdr_int, (char *)&varRec, eachResult);
+			    (xdrproc_t) xdr_int, (char *)&varRec,
+			    (resultproc_t) eachResult);
 
 	if (currentAnswer == maxAnswer)
 		test_status = 0;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_dataint.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_dataint.c
index fdf1e31a2..e1f7bcb6a 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_dataint.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_dataint.c
@@ -72,7 +72,8 @@ int main(int argn, char *argc[])
 
 	clnt_broadcast(progNum, VERSNUM, INTPROCNUM,
 		       (xdrproc_t) xdr_int, (char *)&intSnd,
-		       (xdrproc_t) xdr_int, (char *)&intRec, eachResult);
+		       (xdrproc_t) xdr_int, (char *)&intRec,
+		       (resultproc_t) eachResult);
 
 	if (intSnd != intRec)
 		test_status = 1;
@@ -84,7 +85,8 @@ int main(int argn, char *argc[])
 
 	clnt_broadcast(progNum, VERSNUM, INTPROCNUM,
 		       (xdrproc_t) xdr_int, (char *)&intSnd,
-		       (xdrproc_t) xdr_int, (char *)&intRec, eachResult);
+		       (xdrproc_t) xdr_int, (char *)&intRec,
+		       (resultproc_t) eachResult);
 
 	if (intSnd != intRec)
 		test_status = 1;
@@ -96,7 +98,8 @@ int main(int argn, char *argc[])
 
 	clnt_broadcast(progNum, VERSNUM, LNGPROCNUM,
 		       (xdrproc_t) xdr_long, (char *)&lngSnd,
-		       (xdrproc_t) xdr_long, (char *)&lngRec, eachResult);
+		       (xdrproc_t) xdr_long, (char *)&lngRec,
+		       (resultproc_t) eachResult);
 
 	if (lngSnd != lngRec)
 		test_status = 1;
@@ -108,7 +111,8 @@ int main(int argn, char *argc[])
 
 	clnt_broadcast(progNum, VERSNUM, LNGPROCNUM,
 		       (xdrproc_t) xdr_double, (char *)&dblSnd,
-		       (xdrproc_t) xdr_double, (char *)&dblRec, eachResult);
+		       (xdrproc_t) xdr_double, (char *)&dblRec,
+		       (resultproc_t) eachResult);
 
 	if (dblSnd != dblRec)
 		test_status = 1;
@@ -121,7 +125,8 @@ int main(int argn, char *argc[])
 
 	clnt_broadcast(progNum, VERSNUM, LNGPROCNUM,
 		       (xdrproc_t) xdr_wrapstring, (char *)&strSnd,
-		       (xdrproc_t) xdr_wrapstring, (char *)&strRec, eachResult);
+		       (xdrproc_t) xdr_wrapstring, (char *)&strRec,
+		       (resultproc_t) eachResult);
 
 	if (strcmp(strSnd, strRec))
 		test_status = 1;
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_performance.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_performance.c
index 11ba64fab..d733e72ef 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_performance.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_performance.c
@@ -114,7 +114,7 @@ int main(int argn, char *argc[])
 		cs = clnt_broadcast(progNum, VERSNUM, PROCNUM,
 				    (xdrproc_t) xdr_int, (char *)&varSnd,
 				    (xdrproc_t) xdr_int, (char *)&varRec,
-				    eachResult);
+				    (resultproc_t) eachResult);
 
 		if (cs != RPC_SUCCESS)
 			clnt_perrno(cs);
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_scalability.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_scalability.c
index 57ea25349..4455c1173 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_scalability.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_scalability.c
@@ -114,7 +114,7 @@ int main(int argn, char *argc[])
 		cs = clnt_broadcast(progNum, VERSNUM, PROCNUM,
 				    (xdrproc_t) xdr_int, (char *)&varSnd,
 				    (xdrproc_t) xdr_int, (char *)&varRec,
-				    eachResult);
+				    (resultproc_t) eachResult);
 
 		if (cs != RPC_SUCCESS)
 			clnt_perrno(cs);
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_stress.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_stress.c
index d5d7d85d1..933305482 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_stress.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_broadc_clnt_broadcast/rpc_clnt_broadcast_stress.c
@@ -65,7 +65,7 @@ int main(int argn, char *argc[])
 		cs = clnt_broadcast(progNum, VERSNUM, PROCNUM,
 				    (xdrproc_t) xdr_int, (char *)&varSnd,
 				    (xdrproc_t) xdr_int, (char *)&varRec,
-				    eachResult);
+				    (resultproc_t) eachResult);
 		if (cs == RPC_SUCCESS)
 			nbOk++;
 	}
-- 
2.39.1



More information about the ltp mailing list