From d7cb404d9f75253b86b7a9263cab56ec853c5c94 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Wed, 22 Feb 2017 22:47:02 +0100 Subject: Refactor the code for posix_handle_pair It was no longer compiling on Darwin, and triggered a cppcheck error: [xlators/storage/posix/src/posix-helpers.c:1097]: (error) Invalid number of character '{' when these macros are defined: 'GF_DARWIN_HOST_OS'. Change-Id: I986609cc6cfc13ddea0ed35d7776736171f40a41 BUG: 789278 Signed-off-by: Michael Scherer Reviewed-on: https://review.gluster.org/16729 Tested-by: Michael Scherer NetBSD-regression: NetBSD Build System Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Jeff Darcy --- xlators/storage/posix/src/posix-helpers.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'xlators/storage/posix/src/posix-helpers.c') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index eef1546cc69..ae07b28e48a 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -1148,6 +1148,11 @@ posix_handle_pair (xlator_t *this, const char *real_path, { int sys_ret = -1; int ret = 0; +#ifdef GF_DARWIN_HOST_OS + const int error_code = EINVAL; +#else + const int error_code = EEXIST; +#endif if (XATTR_IS_PATHINFO (key)) { ret = -EACCES; @@ -1179,37 +1184,20 @@ posix_handle_pair (xlator_t *this, const char *real_path, real_path); } } else { - -#ifdef GF_DARWIN_HOST_OS - if (errno == EINVAL) { - gf_msg_debug (this->name, 0, "%s: key:" - "%s flags: %u length:%d " - "error:%s", real_path, - key, flags, value->len, - strerror (errno)); - } else { - gf_msg (this->name, GF_LOG_ERROR, - errno, P_MSG_XATTR_FAILED, - "%s: key:%s flags: " - "%u length:%d", - real_path, key, flags, - value->len); - -#else /* ! DARWIN */ - if (errno == EEXIST) + if (errno == error_code) { gf_msg_debug (this->name, 0, "%s: key:%s" "flags: %u length:%d", real_path, key, flags, value->len); - else + } else { gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_XATTR_FAILED, "%s: key:%s" "flags: %u length:%d", real_path, key, flags, value->len); -#endif /* DARWIN */ } + } goto out; } -- cgit