summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.h
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2015-01-01 13:15:45 +0100
committerVijay Bellur <vbellur@redhat.com>2015-03-03 12:31:38 -0800
commit95d5e60afb29aedc29909340e7564d54a6a247c2 (patch)
tree9d0c2b2963e0b74add7109b5952c1252d868c3cf /libglusterfs/src/common-utils.h
parent2acfbcf34ed77985905b2d122adbfd541eb01db1 (diff)
core: add generic parser utility
This generic parser will get used for parsing the netgroups and exports files for the Gluster/NFS server. The parsing of netgroups shows how the parser can be used (see Change-Id Ie04800d4). BUG: 1143880 Change-Id: Id4cf2b0189ef5799c06868d211d3fcd9c8608c08 Original-author: Shreyas Siravara <shreyas.siravara@gmail.com> CC: Richard Wareing <rwareing@fb.com> CC: Jiffin Tony Thottan <jthottan@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/9359 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.h')
-rw-r--r--libglusterfs/src/common-utils.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 6e1669912cd..71ff9eab5de 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -166,6 +166,21 @@ int gf_set_log_ident (cmd_args_t *cmd_args);
} \
}while (0)
+#define GF_CHECK_ALLOC(arg, retval, label) do { \
+ if (!(arg)) { \
+ retval = -ENOMEM; \
+ goto label; \
+ } \
+ } while (0) \
+
+#define GF_CHECK_ALLOC_AND_LOG(name, item, retval, msg, errlabel) do { \
+ if (!(item)) { \
+ (retval) = -ENOMEM; \
+ gf_log (name, GF_LOG_CRITICAL, (msg)); \
+ goto errlabel; \
+ } \
+ } while (0)
+
#define GF_ASSERT_AND_GOTO_WITH_ERROR(name, arg, label, errno, error) do { \
if (!arg) { \
GF_ASSERT (0); \