From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: io-uring@vger.kernel.org
Subject: [PATCH] man: Fix syscall wrappers in example code
Date: Wed, 16 Apr 2025 16:08:53 -0400 [thread overview]
Message-ID: <yq1o6wveuun.fsf@ca-mkp.ca.oracle.com> (raw)
The example code in io_uring.7 provides two wrappers for the io_uring
syscalls. However, the example fails to take into account that glibc's
syscall(2) returns -1 and sets errno on failure. This means that any
errors returned by the provided wrapper functions will be reported as
-EPERM which could lead to incorrect error handling actions being
taken.
Adjust the two example wrappers to match arch/generic/syscall.h. This
makes them follow the documented io_uring calling convention which
reports a call error as a negative return value.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
diff --git a/man/io_uring.7 b/man/io_uring.7
index 49cdc25290e7..b6c092b60201 100644
--- a/man/io_uring.7
+++ b/man/io_uring.7
@@ -651,14 +651,18 @@ off_t offset;
int io_uring_setup(unsigned entries, struct io_uring_params *p)
{
- return (int) syscall(__NR_io_uring_setup, entries, p);
+ int ret;
+ ret = syscall(__NR_io_uring_setup, entries, p);
+ return (ret < 0) ? -errno : ret;
}
int io_uring_enter(int ring_fd, unsigned int to_submit,
unsigned int min_complete, unsigned int flags)
{
- return (int) syscall(__NR_io_uring_enter, ring_fd, to_submit,
- min_complete, flags, NULL, 0);
+ int ret;
+ ret = syscall(__NR_io_uring_enter, ring_fd, to_submit,
+ min_complete, flags, NULL, 0);
+ return (ret < 0) ? -errno : ret;
}
int app_setup_uring(void) {
next reply other threads:[~2025-04-16 20:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-16 20:08 Martin K. Petersen [this message]
2025-04-16 20:11 ` [PATCH] man: Fix syscall wrappers in example code Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yq1o6wveuun.fsf@ca-mkp.ca.oracle.com \
--to=martin.petersen@oracle.com \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox