diff mbox

[v2] aio-posix: remove useless parameter

Message ID 1468376773-27338-1-git-send-email-caoj.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cao jin July 13, 2016, 2:26 a.m. UTC
Parameter **errp of aio_context_setup() is useless, remove it
and clean up the related code.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 aio-posix.c         | 3 ++-
 async.c             | 8 ++------
 include/block/aio.h | 2 +-
 3 files changed, 5 insertions(+), 8 deletions(-)

Comments

Fam Zheng July 13, 2016, 2:24 a.m. UTC | #1
On Wed, 07/13 10:26, Cao jin wrote:
> Parameter **errp of aio_context_setup() is useless, remove it
> and clean up the related code.
> 
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>  aio-posix.c         | 3 ++-
>  async.c             | 8 ++------
>  include/block/aio.h | 2 +-
>  3 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/aio-posix.c b/aio-posix.c
> index 6006122..24ebf2d 100644
> --- a/aio-posix.c
> +++ b/aio-posix.c
> @@ -485,12 +485,13 @@ bool aio_poll(AioContext *ctx, bool blocking)
>      return progress;
>  }
>  
> -void aio_context_setup(AioContext *ctx, Error **errp)
> +void aio_context_setup(AioContext *ctx)
>  {
>  #ifdef CONFIG_EPOLL_CREATE1
>      assert(!ctx->epollfd);
>      ctx->epollfd = epoll_create1(EPOLL_CLOEXEC);
>      if (ctx->epollfd == -1) {
> +        fprintf(stderr, "Failed to create epoll instance");
>          ctx->epoll_available = false;
>      } else {
>          ctx->epoll_available = true;
> diff --git a/async.c b/async.c
> index b4bf205..1f9754b 100644
> --- a/async.c
> +++ b/async.c
> @@ -327,14 +327,10 @@ AioContext *aio_context_new(Error **errp)
>  {
>      int ret;
>      AioContext *ctx;
> -    Error *local_err = NULL;
>  
>      ctx = (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioContext));
> -    aio_context_setup(ctx, &local_err);
> -    if (local_err) {
> -        error_propagate(errp, local_err);
> -        goto fail;
> -    }
> +    aio_context_setup(ctx);
> +
>      ret = event_notifier_init(&ctx->notifier, false);
>      if (ret < 0) {
>          error_setg_errno(errp, -ret, "Failed to initialize event notifier");
> diff --git a/include/block/aio.h b/include/block/aio.h
> index 88a64ee..0922b69 100644
> --- a/include/block/aio.h
> +++ b/include/block/aio.h
> @@ -439,6 +439,6 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external)
>   *
>   * Initialize the aio context.
>   */
> -void aio_context_setup(AioContext *ctx, Error **errp);
> +void aio_context_setup(AioContext *ctx);
>  
>  #endif
> -- 
> 2.1.0
> 
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>
Stefan Hajnoczi July 14, 2016, 12:18 p.m. UTC | #2
On Wed, Jul 13, 2016 at 10:26:13AM +0800, Cao jin wrote:
> -void aio_context_setup(AioContext *ctx, Error **errp)
> +void aio_context_setup(AioContext *ctx)
>  {
>  #ifdef CONFIG_EPOLL_CREATE1
>      assert(!ctx->epollfd);
>      ctx->epollfd = epoll_create1(EPOLL_CLOEXEC);
>      if (ctx->epollfd == -1) {
> +        fprintf(stderr, "Failed to create epoll instance");

Please include errno so it's clear whether this happened due to EMFILE,
ENOMEM, ENOSYS, etc.

> diff --git a/include/block/aio.h b/include/block/aio.h
> index 88a64ee..0922b69 100644
> --- a/include/block/aio.h
> +++ b/include/block/aio.h
> @@ -439,6 +439,6 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external)
>   *
>   * Initialize the aio context.
>   */
> -void aio_context_setup(AioContext *ctx, Error **errp);
> +void aio_context_setup(AioContext *ctx);

This function is also implemented in aio-win32.c so this patch breaks
the build.
diff mbox

Patch

diff --git a/aio-posix.c b/aio-posix.c
index 6006122..24ebf2d 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -485,12 +485,13 @@  bool aio_poll(AioContext *ctx, bool blocking)
     return progress;
 }
 
-void aio_context_setup(AioContext *ctx, Error **errp)
+void aio_context_setup(AioContext *ctx)
 {
 #ifdef CONFIG_EPOLL_CREATE1
     assert(!ctx->epollfd);
     ctx->epollfd = epoll_create1(EPOLL_CLOEXEC);
     if (ctx->epollfd == -1) {
+        fprintf(stderr, "Failed to create epoll instance");
         ctx->epoll_available = false;
     } else {
         ctx->epoll_available = true;
diff --git a/async.c b/async.c
index b4bf205..1f9754b 100644
--- a/async.c
+++ b/async.c
@@ -327,14 +327,10 @@  AioContext *aio_context_new(Error **errp)
 {
     int ret;
     AioContext *ctx;
-    Error *local_err = NULL;
 
     ctx = (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioContext));
-    aio_context_setup(ctx, &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-        goto fail;
-    }
+    aio_context_setup(ctx);
+
     ret = event_notifier_init(&ctx->notifier, false);
     if (ret < 0) {
         error_setg_errno(errp, -ret, "Failed to initialize event notifier");
diff --git a/include/block/aio.h b/include/block/aio.h
index 88a64ee..0922b69 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -439,6 +439,6 @@  static inline bool aio_node_check(AioContext *ctx, bool is_external)
  *
  * Initialize the aio context.
  */
-void aio_context_setup(AioContext *ctx, Error **errp);
+void aio_context_setup(AioContext *ctx);
 
 #endif