qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [RFC PATCH 5/9] util/asyn: add aio interfa


From: Stefan Hajnoczi
Subject: Re: [Qemu-block] [Qemu-devel] [RFC PATCH 5/9] util/asyn: add aio interfaces for io_uring
Date: Wed, 22 May 2019 14:16:51 +0100
User-agent: Mutt/1.11.4 (2019-03-13)

On Wed, May 22, 2019 at 05:22:11AM +0530, Aarushi Mehta wrote:

s/asyn/async/ in the Subject line.

> @@ -341,6 +349,25 @@ LinuxAioState *aio_get_linux_aio(AioContext *ctx)
>  }
>  #endif
> 
> +#ifdef CONFIG_LINUX_IO_URING
> +LuringState *aio_setup_linux_io_uring(AioContext *ctx, Error **errp)
> +{
> +    if (!ctx->linux_io_uring) {
> +        ctx->linux_io_uring = luring_init(errp);
> +        if (ctx->linux_io_uring) {
> +            luring_attach_aio_context(ctx->linux_io_uring, ctx);
> +        }
> +    }
> +    return ctx->linux_io_uring;
> +}

Personally I find functions that are written to have a single return
statement hard to understand due to the nesting and multiple code paths.
I prefer a straight-line approach that returns as soon as there is an
error.

This is a style thing.  You can do it either way.  Here is the same
without nesting:

  if (ctx->linux_io_uring) {
      return ctx->linux_io_uring;
  }

  ctx->linux_io_uring = luring_init(errp);
  if (!ctx->linux_io_uring) {
      return NULL;
  }

  luring_attach_aio_context(ctx->linux_io_uring, ctx);
  return ctx->linux_io_uring;

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]