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