From 7efac5ddf05c8d6da3d609b9ba09dcc82f22cdb5 Mon Sep 17 00:00:00 2001 From: Mohamed Ashiq Liyazudeen Date: Thu, 25 Jun 2015 12:52:57 +0530 Subject: [PATCH 175/190] common-utils/libglusterfs : removing strerror to avoid duplicate printing of error message Change-Id: I0a1c99ae7a2efc657e3465b21dd238e725ae236c BUG: 1231792 Signed-off-by: Mohamed Ashiq Liyazudeen Reviewed-on: http://review.gluster.org/11400 Reviewed-by: Pranith Kumar Karampuri Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-on: https://code.engineering.redhat.com/gerrit/51749 Tested-by: Pranith Kumar Karampuri --- libglusterfs/src/common-utils.c | 30 +++++++++++++----------------- libglusterfs/src/common-utils.h | 3 +-- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index cbc5230..2057bd8 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -120,10 +120,12 @@ mkdir_p (char *path, mode_t mode, gf_boolean_t allow_symlinks) ret = stat (dir, &stbuf); if (ret || !S_ISDIR (stbuf.st_mode)) { + if (ret == 0) + errno = 0; ret = -1; - gf_msg ("", GF_LOG_ERROR, 0, LG_MSG_DIR_OP_FAILED, "Failed to " - "create directory, possibly some of the components " - "were not directories"); + gf_msg ("", GF_LOG_ERROR, errno, LG_MSG_DIR_OP_FAILED, "Failed" + " to create directory, possibly some of the components" + " were not directories"); goto out; } @@ -304,12 +306,10 @@ gf_resolve_ip6 (const char *hostname, ret = gf_asprintf (&port_str, "%d", port); if (-1 == ret) { - gf_msg ("resolver", GF_LOG_ERROR, 0, - LG_MSG_ASPRINTF_FAILED, "asprintf failed"); return -1; } if ((ret = getaddrinfo(hostname, port_str, &hints, &cache->first)) != 0) { - gf_msg ("resolver", GF_LOG_ERROR, ret, + gf_msg ("resolver", GF_LOG_ERROR, 0, LG_MSG_GETADDRINFO_FAILED, "getaddrinfo failed" " (%s)", gai_strerror (ret)); @@ -3139,8 +3139,7 @@ gf_is_local_addr (char *hostname) ret = getaddrinfo (hostname, NULL, NULL, &result); if (ret != 0) { - gf_msg (this->name, GF_LOG_ERROR, ret, - LG_MSG_GETADDRINFO_FAILED, + gf_msg (this->name, GF_LOG_ERROR, 0, LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: %s\n", gai_strerror(ret)); goto out; } @@ -3180,17 +3179,15 @@ gf_is_same_address (char *name1, char *name2) gai_err = getaddrinfo(name1,NULL,NULL,&addr1); if (gai_err != 0) { - gf_msg (name1, GF_LOG_WARNING, gai_err, - LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: " - "%s\n", gai_strerror(gai_err)); + gf_msg (name1, GF_LOG_WARNING, 0, LG_MSG_GETADDRINFO_FAILED, + "error in getaddrinfo: %s\n", gai_strerror(gai_err)); goto out; } gai_err = getaddrinfo(name2,NULL,NULL,&addr2); if (gai_err != 0) { - gf_msg (name2, GF_LOG_WARNING, gai_err, - LG_MSG_GETADDRINFO_FAILED, "error in getaddrinfo: " - "%s\n", gai_strerror(gai_err)); + gf_msg (name2, GF_LOG_WARNING, 0, LG_MSG_GETADDRINFO_FAILED, + "error in getaddrinfo: %s\n", gai_strerror(gai_err)); goto out; } @@ -3534,8 +3531,7 @@ gf_set_timestamp (const char *src, const char* dest) ret = stat (src, &sb); if (ret) { gf_msg (this->name, GF_LOG_ERROR, errno, - LG_MSG_FILE_STAT_FAILED, "stat on %s failed: %s", - src, strerror(errno)); + LG_MSG_FILE_STAT_FAILED, "stat on %s", src); goto out; } new_time[0].tv_sec = sb.st_atime; @@ -3551,7 +3547,7 @@ gf_set_timestamp (const char *src, const char* dest) ret = utimes (dest, new_time); if (ret) { gf_msg (this->name, GF_LOG_ERROR, errno, LG_MSG_UTIMES_FAILED, - "utimes on %s failed: %s", dest, strerror(errno)); + "utimes on %s", dest); } out: return ret; diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index a64917f..5b5d451 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -278,8 +278,7 @@ int gf_set_log_ident (cmd_args_t *cmd_args); gf_msg (this->name, GF_LOG_ERROR, op_errno, \ LG_MSG_NO_PERM, \ "attempt to set internal" \ - " xattr: %s: %s", pattern, \ - strerror (op_errno)); \ + " xattr: %s", pattern); \ goto label; \ } \ } while (0) -- 1.7.1