From ccd3865f1944811ca91db08935882c8daf061cbf Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Wed, 26 Feb 2020 07:54:08 -0800 Subject: [PATCH] modules/kvs: Cleanup asprintf error paths asprintf already sets errno on error, so there is no need to explicitly set errno = ENOMEM on asprintf errors. --- src/modules/kvs/kvs.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/modules/kvs/kvs.c b/src/modules/kvs/kvs.c index ac8a57a581d2..13494421bd75 100644 --- a/src/modules/kvs/kvs.c +++ b/src/modules/kvs/kvs.c @@ -211,30 +211,24 @@ static int event_subscribe (kvs_ctx_t *ctx, const char *ns) } if (ctx->rank != 0) { - if (asprintf (&setroot_topic, "kvs.setroot-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&setroot_topic, "kvs.setroot-%s", ns) < 0) goto cleanup; - } if (flux_event_subscribe (ctx->h, setroot_topic) < 0) { flux_log_error (ctx->h, "flux_event_subscribe"); goto cleanup; } - if (asprintf (&error_topic, "kvs.error-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&error_topic, "kvs.error-%s", ns) < 0) goto cleanup; - } if (flux_event_subscribe (ctx->h, error_topic) < 0) { flux_log_error (ctx->h, "flux_event_subscribe"); goto cleanup; } - if (asprintf (&removed_topic, "kvs.namespace-removed-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&removed_topic, "kvs.namespace-removed-%s", ns) < 0) goto cleanup; - } if (flux_event_subscribe (ctx->h, removed_topic) < 0) { flux_log_error (ctx->h, "flux_event_subscribe"); @@ -258,30 +252,24 @@ static int event_unsubscribe (kvs_ctx_t *ctx, const char *ns) int rc = -1; if (ctx->rank != 0) { - if (asprintf (&setroot_topic, "kvs.setroot-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&setroot_topic, "kvs.setroot-%s", ns) < 0) goto cleanup; - } if (flux_event_unsubscribe (ctx->h, setroot_topic) < 0) { flux_log_error (ctx->h, "flux_event_subscribe"); goto cleanup; } - if (asprintf (&error_topic, "kvs.error-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&error_topic, "kvs.error-%s", ns) < 0) goto cleanup; - } if (flux_event_unsubscribe (ctx->h, error_topic) < 0) { flux_log_error (ctx->h, "flux_event_subscribe"); goto cleanup; } - if (asprintf (&removed_topic, "kvs.namespace-removed-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&removed_topic, "kvs.namespace-removed-%s", ns) < 0) goto cleanup; - } if (flux_event_subscribe (ctx->h, removed_topic) < 0) { flux_log_error (ctx->h, "flux_event_subscribe"); @@ -2423,10 +2411,8 @@ static int namespace_create (kvs_ctx_t *ctx, const char *ns, goto cleanup; } - if (asprintf (&topic, "kvs.namespace-created-%s", ns) < 0) { - errno = ENOMEM; + if (asprintf (&topic, "kvs.namespace-created-%s", ns) < 0) goto cleanup; - } if (!(msg = flux_event_pack (topic, "{ s:s s:i s:s s:i }",