aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZorro Lang <zlang@kernel.org>2024-03-12 00:20:27 +0800
committerZorro Lang <zlang@kernel.org>2024-03-12 11:39:52 +0800
commit46b783fe67fc2afd2bc30df458934d4916b91cce (patch)
tree4dcf1949597f9c70a0c24e5c50a9a3355cbeeba8
parent7bb78927c0f53f7b86f932836ef1d3b34606a3a9 (diff)
downloadxfstests-dev-46b783fe67fc2afd2bc30df458934d4916b91cce.tar.gz
fsstress: check io_uring_queue_init errno properly
As the manual of io_uring_queue_init says "io_uring_queue_init(3) returns 0 on success and -errno on failure". We should check if the return value is -ENOSYS, not the errno. Fixes: d15b1721f284 ("ltp/fsstress: don't fail on io_uring ENOSYS") Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
-rw-r--r--ltp/fsstress.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 63c757672e..4fc50efb9b 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -763,13 +763,17 @@ int main(int argc, char **argv)
#ifdef URING
have_io_uring = true;
/* If ENOSYS, just ignore uring, other errors are fatal. */
- if (io_uring_queue_init(URING_ENTRIES, &ring, 0)) {
- if (errno == ENOSYS) {
- have_io_uring = false;
- } else {
- fprintf(stderr, "io_uring_queue_init failed\n");
- exit(1);
- }
+ c = io_uring_queue_init(URING_ENTRIES, &ring, 0);
+ switch(c){
+ case 0:
+ have_io_uring = true;
+ break;
+ case -ENOSYS:
+ have_io_uring = false;
+ break;
+ default:
+ fprintf(stderr, "io_uring_queue_init failed\n");
+ exit(1);
}
#endif
for (i = 0; keep_looping(i, loops); i++)