Skip to content

Commit f578ff4

Browse files
Carlos Llamaskuba-moo
authored andcommitted
selftests/net: io_uring: fix unknown errnum values
The io_uring functions return negative error values, but error() expects these to be positive to properly match them to an errno string. Fix this to make sure the correct error descriptions are displayed upon failure. Signed-off-by: Carlos Llamas <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3dc2a17 commit f578ff4

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tools/testing/selftests/net/io_uring_zerocopy_tx.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ static void do_tx(int domain, int type, int protocol)
106106

107107
ret = io_uring_queue_init(512, &ring, 0);
108108
if (ret)
109-
error(1, ret, "io_uring: queue init");
109+
error(1, -ret, "io_uring: queue init");
110110

111111
iov.iov_base = payload;
112112
iov.iov_len = cfg_payload_len;
113113

114114
ret = io_uring_register_buffers(&ring, &iov, 1);
115115
if (ret)
116-
error(1, ret, "io_uring: buffer registration");
116+
error(1, -ret, "io_uring: buffer registration");
117117

118118
tstop = gettimeofday_ms() + cfg_runtime_ms;
119119
do {
@@ -149,39 +149,39 @@ static void do_tx(int domain, int type, int protocol)
149149

150150
ret = io_uring_submit(&ring);
151151
if (ret != cfg_nr_reqs)
152-
error(1, ret, "submit");
152+
error(1, -ret, "submit");
153153

154154
if (cfg_cork)
155155
do_setsockopt(fd, IPPROTO_UDP, UDP_CORK, 0);
156156
for (i = 0; i < cfg_nr_reqs; i++) {
157157
ret = io_uring_wait_cqe(&ring, &cqe);
158158
if (ret)
159-
error(1, ret, "wait cqe");
159+
error(1, -ret, "wait cqe");
160160

161161
if (cqe->user_data != NONZC_TAG &&
162162
cqe->user_data != ZC_TAG)
163-
error(1, -EINVAL, "invalid cqe->user_data");
163+
error(1, EINVAL, "invalid cqe->user_data");
164164

165165
if (cqe->flags & IORING_CQE_F_NOTIF) {
166166
if (cqe->flags & IORING_CQE_F_MORE)
167-
error(1, -EINVAL, "invalid notif flags");
167+
error(1, EINVAL, "invalid notif flags");
168168
if (compl_cqes <= 0)
169-
error(1, -EINVAL, "notification mismatch");
169+
error(1, EINVAL, "notification mismatch");
170170
compl_cqes--;
171171
i--;
172172
io_uring_cqe_seen(&ring);
173173
continue;
174174
}
175175
if (cqe->flags & IORING_CQE_F_MORE) {
176176
if (cqe->user_data != ZC_TAG)
177-
error(1, cqe->res, "unexpected F_MORE");
177+
error(1, -cqe->res, "unexpected F_MORE");
178178
compl_cqes++;
179179
}
180180
if (cqe->res >= 0) {
181181
packets++;
182182
bytes += cqe->res;
183183
} else if (cqe->res != -EAGAIN) {
184-
error(1, cqe->res, "send failed");
184+
error(1, -cqe->res, "send failed");
185185
}
186186
io_uring_cqe_seen(&ring);
187187
}
@@ -190,11 +190,11 @@ static void do_tx(int domain, int type, int protocol)
190190
while (compl_cqes) {
191191
ret = io_uring_wait_cqe(&ring, &cqe);
192192
if (ret)
193-
error(1, ret, "wait cqe");
193+
error(1, -ret, "wait cqe");
194194
if (cqe->flags & IORING_CQE_F_MORE)
195-
error(1, -EINVAL, "invalid notif flags");
195+
error(1, EINVAL, "invalid notif flags");
196196
if (!(cqe->flags & IORING_CQE_F_NOTIF))
197-
error(1, -EINVAL, "missing notif flag");
197+
error(1, EINVAL, "missing notif flag");
198198

199199
io_uring_cqe_seen(&ring);
200200
compl_cqes--;

0 commit comments

Comments
 (0)