Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <cmllamas@google.com>
Link: https://patch.msgid.link/20251016182538.3790567-1-cmllamas@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Carlos Llamas and committed by
Jakub Kicinski
f578ff4c 3dc2a17e

+12 -12
+12 -12
tools/testing/selftests/net/io_uring_zerocopy_tx.c
··· 106 106 107 107 ret = io_uring_queue_init(512, &ring, 0); 108 108 if (ret) 109 - error(1, ret, "io_uring: queue init"); 109 + error(1, -ret, "io_uring: queue init"); 110 110 111 111 iov.iov_base = payload; 112 112 iov.iov_len = cfg_payload_len; 113 113 114 114 ret = io_uring_register_buffers(&ring, &iov, 1); 115 115 if (ret) 116 - error(1, ret, "io_uring: buffer registration"); 116 + error(1, -ret, "io_uring: buffer registration"); 117 117 118 118 tstop = gettimeofday_ms() + cfg_runtime_ms; 119 119 do { ··· 149 149 150 150 ret = io_uring_submit(&ring); 151 151 if (ret != cfg_nr_reqs) 152 - error(1, ret, "submit"); 152 + error(1, -ret, "submit"); 153 153 154 154 if (cfg_cork) 155 155 do_setsockopt(fd, IPPROTO_UDP, UDP_CORK, 0); 156 156 for (i = 0; i < cfg_nr_reqs; i++) { 157 157 ret = io_uring_wait_cqe(&ring, &cqe); 158 158 if (ret) 159 - error(1, ret, "wait cqe"); 159 + error(1, -ret, "wait cqe"); 160 160 161 161 if (cqe->user_data != NONZC_TAG && 162 162 cqe->user_data != ZC_TAG) 163 - error(1, -EINVAL, "invalid cqe->user_data"); 163 + error(1, EINVAL, "invalid cqe->user_data"); 164 164 165 165 if (cqe->flags & IORING_CQE_F_NOTIF) { 166 166 if (cqe->flags & IORING_CQE_F_MORE) 167 - error(1, -EINVAL, "invalid notif flags"); 167 + error(1, EINVAL, "invalid notif flags"); 168 168 if (compl_cqes <= 0) 169 - error(1, -EINVAL, "notification mismatch"); 169 + error(1, EINVAL, "notification mismatch"); 170 170 compl_cqes--; 171 171 i--; 172 172 io_uring_cqe_seen(&ring); ··· 174 174 } 175 175 if (cqe->flags & IORING_CQE_F_MORE) { 176 176 if (cqe->user_data != ZC_TAG) 177 - error(1, cqe->res, "unexpected F_MORE"); 177 + error(1, -cqe->res, "unexpected F_MORE"); 178 178 compl_cqes++; 179 179 } 180 180 if (cqe->res >= 0) { 181 181 packets++; 182 182 bytes += cqe->res; 183 183 } else if (cqe->res != -EAGAIN) { 184 - error(1, cqe->res, "send failed"); 184 + error(1, -cqe->res, "send failed"); 185 185 } 186 186 io_uring_cqe_seen(&ring); 187 187 } ··· 190 190 while (compl_cqes) { 191 191 ret = io_uring_wait_cqe(&ring, &cqe); 192 192 if (ret) 193 - error(1, ret, "wait cqe"); 193 + error(1, -ret, "wait cqe"); 194 194 if (cqe->flags & IORING_CQE_F_MORE) 195 - error(1, -EINVAL, "invalid notif flags"); 195 + error(1, EINVAL, "invalid notif flags"); 196 196 if (!(cqe->flags & IORING_CQE_F_NOTIF)) 197 - error(1, -EINVAL, "missing notif flag"); 197 + error(1, EINVAL, "missing notif flag"); 198 198 199 199 io_uring_cqe_seen(&ring); 200 200 compl_cqes--;