Skip to contentSkip to conversation

aio-posix: remove useless parameter

PATCH Superseded Cao jin 2 participants 3 messages Jul 14, 2016 – Jul 15, 2016

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Cao jin

author
#0 lore raw

PATCH v3 1/1 aio-posix: remove useless parameter

Parameter **errp of aio_context_setup() is useless, remove it and clean up the related code.

Cc Stefan Hajnoczi <[email protected]>
Cc Fam Zheng <[email protected]>
Cc Eric Blake <[email protected]>
---
 aio-posix.c         | 3 ++-
 aio-win32.c         | 2 +-
 async.c             | 8 ++------
 include/block/aio.h | 2 +-
 4 files changed, 6 insertions(+), 9 deletions(-)

v3 changelog:
1. printf errno, and fix build failure on Windows (Stefan)

aio-posix.c +2 -1
index 6006122..0bb4144 100644
@@ -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: %d", errno);
         ctx->epoll_available = false;
     } else {
         ctx->epoll_available = true;
aio-win32.c +1 -1
index 6aaa32a..c8c249e 100644
@@ -371,6 +371,6 @@ bool aio_poll(AioContext *ctx, bool blocking)
     return progress;
 }
 
-void aio_context_setup(AioContext *ctx, Error **errp)
+void aio_context_setup(AioContext *ctx)
 {
 }
async.c +2 -6
index fb7dd92..8589017 100644
@@ -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");
include/block/aio.h +1 -1
index 88a64ee..0922b69 100644
@@ -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
Signature · 1 line
2.1.0
#1 lore raw
Quoted 24 lines · Cao jin

Parameter **errp of aio_context_setup() is useless, remove it and clean up the related code.

Cc Stefan Hajnoczi <[email protected]>
Cc Fam Zheng <[email protected]>
Cc Eric Blake <[email protected]>
---
 aio-posix.c         | 3 ++-
 aio-win32.c         | 2 +-
 async.c             | 8 ++------
 include/block/aio.h | 2 +-
 4 files changed, 6 insertions(+), 9 deletions(-)

v3 changelog:
1. printf errno, and fix build failure on Windows (Stefan)

aio-posix.c +0 -0
index 6006122..0bb4144 100644
@@ -485,12 +485,13 @@ bool aio_poll(AioContext *ctx, bool blocking)
     return progress;

aio-posix.c bool aio_poll(AioContext *ctx, bool blocking) · line 494

Quoted 10 lines
aio-posix.c +2 -1
 }
 
-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: %d", errno);

Better is to use %s and strerror(errno), as a raw int isn't very meaningful.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
author
#2 lore raw
Quoted 27 lines · Eric Blake
Quoted 26 lines · Cao jin

Parameter **errp of aio_context_setup() is useless, remove it and clean up the related code.

Cc Stefan Hajnoczi <[email protected]>
Cc Fam Zheng <[email protected]>
Cc Eric Blake <[email protected]>
---
  aio-posix.c         | 3 ++-
  aio-win32.c         | 2 +-
  async.c             | 8 ++------
  include/block/aio.h | 2 +-
  4 files changed, 6 insertions(+), 9 deletions(-)

v3 changelog:
1. printf errno, and fix build failure on Windows (Stefan)

aio-posix.c +0 -0
index 6006122..0bb4144 100644
@@ -485,12 +485,13 @@ bool aio_poll(AioContext *ctx, bool blocking)
      return progress;
  }
 
Quoted 11 lines

aio-posix.c bool aio_poll(AioContext *ctx, bool blocking) · line 494

Quoted 8 lines
aio-posix.c +2 -1
-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: %d", errno);

Better is to use %s and strerror(errno), as a raw int isn't very meaningful.

strerror came to my mind first, I regret not using it:P

Signature · 3 lines
Yours Sincerely,

Cao jin