From 255bb3c915e4db994bc4ebce6a57dc846a71fec4 Mon Sep 17 00:00:00 2001 From: Anders Roxell Date: Thu, 22 Apr 2021 10:33:12 +0200 Subject: [PATCH 1/2] net-test: packetdrill: run_system_call: splice expects a pointer to the offset It appears that the previous code cannot possibly work correctly, but I could not produce any failure without this patch. However, when building for arm32 bit, the following error shows up: run_system_call.c: In function 'syscall_splice': run_system_call.c:3250:31: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 3250 | result = splice(fd_in_live, (loff_t *) off_in, fd_out_live, | ^ run_system_call.c:3251:5: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] 3251 | (loff_t *) off_out, len, flags); | ^ cc1: all warnings being treated as errors make: *** [: run_system_call.o] Error 1 The man pages for splice says that splice expects a pointer to the offset. This is done for ifc.splice. Doing the same for splice. Reported-by: Naresh Kamboju Signed-off-by: Anders Roxell --- gtests/net/packetdrill/run_system_call.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index 7070fe56..549efe1c 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -3246,8 +3246,8 @@ static int syscall_splice(struct state *state, struct syscall_spec *syscall, fd_out_live, (loff_t *) &off_out, len, flags); } else { - result = splice(fd_in_live, (loff_t *) off_in, fd_out_live, - (loff_t *) off_out, len, flags); + result = splice(fd_in_live, (loff_t *) &off_in, fd_out_live, + (loff_t *) &off_out, len, flags); } if (end_syscall(state, syscall, CHECK_EXACT, result, error)) return STATUS_ERR; From 0ff87ddd15ac4b9c40a65d8d33cba07582805798 Mon Sep 17 00:00:00 2001 From: Anders Roxell Date: Thu, 22 Apr 2021 10:39:37 +0200 Subject: [PATCH 2/2] net-test: packetdrill: run_system_call: fix 32 bit builds When building for arm32 the following error shows up: run_system_call.c: In function 'cmsg_expect_eq': run_system_call.c:860:38: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned in t'} [-Werror=format=] 860 | "Bad len in cmsg %d: expected=%lu actual=%lu", | ~~^ | | | long unsigned int | %u 861 | i, ecm->cmsg_len, acm->cmsg_len); | ~~~~~~~~~~~~~ run_system_call.c:3129:6: error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=] 3129 | "epoll_event->data does not match script: " | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...... 3133 | event_live->data.u64); | ~~~~~~~~~~~~~~~~~~~~ To fix these use %zu instead of %lu for size_t, and for the uint64_t use %PRIu64 instad of %lu. Reported-by: Naresh Kamboju Signed-off-by: Anders Roxell --- gtests/net/packetdrill/run_system_call.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index 549efe1c..712a9d57 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -857,7 +858,7 @@ static bool cmsg_expect_eq(struct state *state, struct msghdr *expect, } if (acm->cmsg_len != ecm->cmsg_len) { asprintf(error, - "Bad len in cmsg %d: expected=%lu actual=%lu", + "Bad len in cmsg %d: expected=%zu actual=%zu", i, ecm->cmsg_len, acm->cmsg_len); return false; } @@ -2921,7 +2922,7 @@ static int get_epoll_event_from_expr(struct state *state, if (epollev_expr->ptr) { if (check_type(epollev_expr->ptr, EXPR_INTEGER, error)) return STATUS_ERR; - event->data.ptr = (void *)epollev_expr->ptr->value.num; + event->data.ptr = (void *)((intptr_t)epollev_expr->ptr->value.num); *epoll_data = EPOLL_DATA_PTR; } else if (epollev_expr->fd) { if (check_type(epollev_expr->fd, EXPR_INTEGER, error)) @@ -3127,8 +3128,8 @@ static int syscall_epoll_wait(struct state *state, struct syscall_spec *syscall, if (event_script.data.u64 != event_live->data.u64) { asprintf(error, "epoll_event->data does not match script: " - "expected: %lu " - "actual: %lu\n", + "expected: %"PRIu64" " + "actual: %"PRIu64"\n", event_script.data.u64, event_live->data.u64); goto error_out;