From b128a8983376c70b6f9f35ed60d54404da314624 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Fri, 13 May 2016 12:41:39 +0530 Subject: index: Fix compiler warning Problem: ---------------------------- index.c:420:18: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare] if (type < 0 || type >= XATTROP_TYPE_END) ~~~~ ^ ~ 1 warning generated. ---------------------------- Fix: Add a -1 value in the enumeration and use that in if-statements. Cherry picked from commit e221827c18ad4161a8e54ad67c9128ad234b8c03: > BUG: 1335232 > Change-Id: I830a565b8d96d7b51ff775e94aa23dd567ffe0d9 > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/14409 > Smoke: Gluster Build System > Reviewed-by: Ravishankar N > CentOS-regression: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Kaleb KEITHLEY The backport prevens the need for commit 137bd83 to be backported. Commit e221827 undoes the ugly type-casting. Change-Id: I65911a05de5f8b5634f1e8cf359c38dad7d125aa BUG: 1336268 Signed-off-by: Ravishankar N Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/14346 Tested-by: Niels de Vos Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Kaleb KEITHLEY --- xlators/features/index/src/index.c | 6 +++--- xlators/features/index/src/index.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'xlators') diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 41d21c50abe..36502383488 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -417,7 +417,7 @@ index_dec_link_count (index_priv_t *priv, index_xattrop_type_t type) char* index_get_subdir_from_type (index_xattrop_type_t type) { - if (type < 0 || type >= XATTROP_TYPE_END) + if (type < XATTROP || type >= XATTROP_TYPE_END) return NULL; return index_subdirs[type]; } @@ -1558,7 +1558,7 @@ index_unlink_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flag, int32_t op_ret = 0; int32_t op_errno = 0; int ret = 0; - int type = -1; + index_xattrop_type_t type = XATTROP_TYPE_UNSET; struct iatt preparent = {0}; struct iatt postparent = {0}; char index_dir[PATH_MAX] = {0}; @@ -1588,7 +1588,7 @@ index_unlink_wrapper (call_frame_t *frame, xlator_t *this, loc_t *loc, int flag, gf_uuid_copy (preparent.ia_gfid, loc->pargfid); preparent.ia_ino = -1; - if (type < 0) { + if (type <= XATTROP_TYPE_UNSET) { ret = index_inode_ctx_get (loc->parent, this, &ictx); if ((ret == 0) && gf_uuid_is_null (ictx->virtual_pargfid)) { ret = -EINVAL; diff --git a/xlators/features/index/src/index.h b/xlators/features/index/src/index.h index 44e0039ff70..24fd293db70 100644 --- a/xlators/features/index/src/index.h +++ b/xlators/features/index/src/index.h @@ -27,6 +27,7 @@ typedef enum { } index_state_t; typedef enum { + XATTROP_TYPE_UNSET = -1, XATTROP, DIRTY, ENTRY_CHANGES, -- cgit