From 0696c330fadd34430394e23712450f89d924ea55 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Mon, 20 Jul 2020 23:05:10 +0530 Subject: 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 --- libglusterfs/src/glusterfs/glusterfs.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) -- cgit