Skip to content

Commit

Permalink
Rename '*ret' to '*err' for io_uring_setup_buf_ring()
Browse files Browse the repository at this point in the history
Do that both in the source and in the man page, it better describes
what the purpose of this variable is - in case of error (eg NULL
return), it'll be filled with the error that occurred.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 23, 2024
1 parent cb14306 commit 80272cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions man/io_uring_setup_buf_ring.3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ io_uring_setup_buf_ring \- setup and register buffer ring for provided buffers
.BI " unsigned int " nentries ",
.BI " int " bgid ",
.BI " unsigned int " flags ",
.BI " int *" ret ");"
.BI " int *" err ");"
.BI "
.fi
.SH DESCRIPTION
Expand Down Expand Up @@ -41,7 +41,7 @@ a power-of 2 in size.
is the chosen buffer group ID,
.I flags
are modifier flags for the operation, and
.I *ret
.I *err
is is a pointer to an integer for the error value if any part of the ring
allocation and registration fails.

Expand Down Expand Up @@ -78,7 +78,7 @@ On success
returns a pointer to the buffer ring. On failure it returns
.BR NULL
and sets
.I *ret
.I *err
to -errno.
.SH NOTES
Note that even if the kernel supports this feature, registering a provided
Expand Down
2 changes: 1 addition & 1 deletion src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ int io_uring_register(unsigned int fd, unsigned int opcode, const void *arg,
struct io_uring_buf_ring *io_uring_setup_buf_ring(struct io_uring *ring,
unsigned int nentries,
int bgid, unsigned int flags,
int *ret);
int *err);
int io_uring_free_buf_ring(struct io_uring *ring, struct io_uring_buf_ring *br,
unsigned int nentries, int bgid);

Expand Down
20 changes: 10 additions & 10 deletions src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ __cold ssize_t io_uring_mlock_size(unsigned entries, unsigned flags)
#if defined(__hppa__)
static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
unsigned int nentries, int bgid,
unsigned int flags, int *ret)
unsigned int flags, int *err)
{
struct io_uring_buf_ring *br;
struct io_uring_buf_reg reg;
Expand All @@ -608,10 +608,10 @@ static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
reg.bgid = bgid;
reg.flags = IOU_PBUF_RING_MMAP;

*ret = 0;
*err = 0;
lret = io_uring_register_buf_ring(ring, &reg, flags);
if (lret) {
*ret = lret;
*err = lret;
return NULL;
}

Expand All @@ -620,7 +620,7 @@ static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
br = __sys_mmap(NULL, ring_size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, ring->ring_fd, off);
if (IS_ERR(br)) {
*ret = PTR_ERR(br);
*err = PTR_ERR(br);
return NULL;
}

Expand All @@ -629,7 +629,7 @@ static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
#else
static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
unsigned int nentries, int bgid,
unsigned int flags, int *ret)
unsigned int flags, int *err)
{
struct io_uring_buf_ring *br;
struct io_uring_buf_reg reg;
Expand All @@ -641,19 +641,19 @@ static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
br = __sys_mmap(NULL, ring_size, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
if (IS_ERR(br)) {
*ret = PTR_ERR(br);
*err = PTR_ERR(br);
return NULL;
}

reg.ring_addr = (unsigned long) (uintptr_t) br;
reg.ring_entries = nentries;
reg.bgid = bgid;

*ret = 0;
*err = 0;
lret = io_uring_register_buf_ring(ring, &reg, flags);
if (lret) {
__sys_munmap(br, ring_size);
*ret = lret;
*err = lret;
br = NULL;
}

Expand All @@ -664,11 +664,11 @@ static struct io_uring_buf_ring *br_setup(struct io_uring *ring,
struct io_uring_buf_ring *io_uring_setup_buf_ring(struct io_uring *ring,
unsigned int nentries,
int bgid, unsigned int flags,
int *ret)
int *err)
{
struct io_uring_buf_ring *br;

br = br_setup(ring, nentries, bgid, flags, ret);
br = br_setup(ring, nentries, bgid, flags, err);
if (br)
io_uring_buf_ring_init(br);

Expand Down

0 comments on commit 80272cb

Please sign in to comment.