From c1b3deff1186c581cb8d9893a3a0de6bf00d3adc Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Thu, 16 Apr 2009 23:52:04 -0700 Subject: libglusterfsclient: Use macros for argument checks Having those if {} blocks to check for argument validity hurts the eye so this patch replaces those checks with macros. One macro already exists in libglusterfs. The second macro is introduced by this commit for libglusterfsclient-specific check for paths. Signed-off-by: Anand V. Avati --- libglusterfs/src/common-utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index b3630d478..c90342f7a 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -116,6 +116,16 @@ extern char *gf_cbk_list[GF_CBK_MAXVALUE]; } \ } while (0); +#define GF_VALIDATE_ABSOLUTE_PATH_OR_GOTO(name,arg,label) \ + do { \ + GF_VALIDATE_OR_GOTO (name, arg, label); \ + if ((arg[0]) != '/') { \ + errno = EINVAL; \ + gf_log (name, GF_LOG_ERROR, \ + "invalid argument: " #arg); \ + goto label; \ + } \ + } while (0); #define GF_FILE_CONTENT_REQUESTED(_xattr_req,_content_limit) \ (dict_get_uint64 (_xattr_req, "glusterfs.content", _content_limit) == 0) -- cgit