From f86f10757912918b8ba7b4b3bfdab1cd4c2d180c Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 14 Dec 2017 09:25:54 +0900 Subject: [PATCH] conf: Remove use of perror() for strdup() failure All SPDK libraries should use the spdk/log.h family of functions for logging. The cause of strdup failure is only out-of-memory for malloc(). Hence errno is omitted. Change-Id: I682f11fbb6f12c9de8d57a025b704b4f050f7474 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/391685 Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System --- lib/conf/conf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/conf/conf.c b/lib/conf/conf.c index 96eefb270..e52372e90 100644 --- a/lib/conf/conf.c +++ b/lib/conf/conf.c @@ -487,7 +487,7 @@ parse_line(struct spdk_conf *cp, char *lp) cp->current_section = sp; sp->name = strdup(key); if (sp->name == NULL) { - perror("strdup sp->name"); + SPDK_ERRLOG("cannot duplicate %s to sp->name\n", key); return -1; } @@ -513,7 +513,7 @@ parse_line(struct spdk_conf *cp, char *lp) append_cf_item(sp, ip); ip->key = strdup(key); if (ip->key == NULL) { - perror("strdup ip->key"); + SPDK_ERRLOG("cannot make duplicate of %s\n", key); return -1; } ip->val = NULL; @@ -529,7 +529,7 @@ parse_line(struct spdk_conf *cp, char *lp) append_cf_value(ip, vp); vp->value = strdup(val); if (vp->value == NULL) { - perror("strdup vp->value"); + SPDK_ERRLOG("cannot duplicate %s to vp->value\n", val); return -1; } } @@ -617,7 +617,7 @@ spdk_conf_read(struct spdk_conf *cp, const char *file) cp->file = strdup(file); if (cp->file == NULL) { - perror("strdup cp->file"); + SPDK_ERRLOG("cannot duplicate %s to cp->file\n", file); fclose(fp); return -1; }