summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/glusterfs
diff options
context:
space:
mode:
authorAmar Tumballi <amar@kadalu.io>2020-07-20 23:05:10 +0530
committerXavi Hernandez <xhernandez@redhat.com>2020-07-21 07:18:20 +0000
commit0696c330fadd34430394e23712450f89d924ea55 (patch)
treedc82d5d51763a220c6da009f4e6142b55fc904ce /libglusterfs/src/glusterfs
parentd05a2332bf5f0a92c57f99de06476d4a78c65baa (diff)
glusterfs.h: add IS_ERROR() and IS_SUCCESS() macro
These macros helps to clearly identify all negetive checks are 'errors', and all 0 and above are success. With this clasification, we can add more error codes to the process / method / function. Updates: #280 Change-Id: I0ebc5c4ad41eb78e4f2c1b98648986be62e7b521 Signed-off-by: Amar Tumballi <amar@kadalu.io>
Diffstat (limited to 'libglusterfs/src/glusterfs')
-rw-r--r--libglusterfs/src/glusterfs/glusterfs.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h
index 6d6ac36cfd5..e4dfda8d01a 100644
--- a/libglusterfs/src/glusterfs/glusterfs.h
+++ b/libglusterfs/src/glusterfs/glusterfs.h
@@ -43,6 +43,9 @@
#define GF_YES 1
#define GF_NO 0
+#define IS_ERROR(ret) ((ret) < 0)
+#define IS_SUCCESS(ret) ((ret) >= 0)
+
#ifndef O_LARGEFILE
/* savannah bug #20053, patch for compiling on darwin */
#define O_LARGEFILE 0100000 /* from bits/fcntl.h */
@@ -422,7 +425,7 @@ static const char *const FOP_PRI_STRINGS[] = {"HIGH", "NORMAL", "LOW", "LEAST"};
static inline const char *
fop_pri_to_string(gf_fop_pri_t pri)
{
- if (pri < 0)
+ if (IS_ERROR(pri))
return "UNSPEC";
if (pri >= GF_FOP_PRI_MAX)