From 45a71c0548b6fd2c757aa2e7b7671a1411948894 Mon Sep 17 00:00:00 2001 From: Gluster Ant Date: Wed, 12 Sep 2018 17:22:48 +0530 Subject: Land clang-format changes Change-Id: I6f5d8140a06f3c1b2d196849299f8d483028d33b --- libglusterfs/src/compat.h | 300 ++++++++++++++++++++++++---------------------- 1 file changed, 159 insertions(+), 141 deletions(-) (limited to 'libglusterfs/src/compat.h') diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h index e0ffe73926a..38c07b5ae7c 100644 --- a/libglusterfs/src/compat.h +++ b/libglusterfs/src/compat.h @@ -15,8 +15,7 @@ #ifndef LLONG_MAX #define LLONG_MAX __LONG_LONG_MAX__ /* compat with old gcc */ -#endif /* LLONG_MAX */ - +#endif /* LLONG_MAX */ #ifdef GF_LINUX_HOST_OS @@ -38,7 +37,7 @@ #ifndef _PATH_UMOUNT #define _PATH_UMOUNT "/bin/umount" #endif -#define GF_XATTR_NAME_MAX XATTR_NAME_MAX +#define GF_XATTR_NAME_MAX XATTR_NAME_MAX #endif /* GF_LINUX_HOST_OS */ #ifdef HAVE_XATTR_H @@ -51,19 +50,19 @@ */ #ifndef FALLOC_FL_KEEP_SIZE -#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ +#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ #endif #ifndef FALLOC_FL_PUNCH_HOLE -#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ +#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ #endif #ifndef FALLOC_FL_ZERO_RANGE -#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */ +#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */ #endif #ifndef FALLOC_FL_COLLAPSE_RANGE -#define FALLOC_FL_COLLAPSE_RANGE 0x08 /* reduces the size */ +#define FALLOC_FL_COLLAPSE_RANGE 0x08 /* reduces the size */ #endif #ifndef FALLOC_FL_INSERT_RANGE -#define FALLOC_FL_INSERT_RANGE 0x20 /* expands the size */ +#define FALLOC_FL_INSERT_RANGE 0x20 /* expands the size */ #endif #ifndef HAVE_LLISTXATTR @@ -72,14 +71,14 @@ * 'llistxattr()' system calls. */ -#define lremovexattr(path,key) removexattr(path,key) -#define llistxattr(path,key,size) listxattr(path,key,size) -#define lgetxattr(path, key, value, size) getxattr(path,key,value,size) -#define lsetxattr(path,key,value,size,flags) setxattr(path,key,value,size,flags) +#define lremovexattr(path, key) removexattr(path, key) +#define llistxattr(path, key, size) listxattr(path, key, size) +#define lgetxattr(path, key, value, size) getxattr(path, key, value, size) +#define lsetxattr(path, key, value, size, flags) \ + setxattr(path, key, value, size, flags) #endif /* HAVE_LLISTXATTR */ - #ifdef GF_DARWIN_HOST_OS #include #include @@ -102,7 +101,6 @@ #endif - #ifdef GF_BSD_HOST_OS /* In case of FreeBSD and NetBSD */ @@ -121,14 +119,13 @@ #ifndef XATTR_CREATE enum { - ATTR_CREATE = 1, + ATTR_CREATE = 1, #define XATTR_CREATE ATTR_CREATE - ATTR_REPLACE = 2 + ATTR_REPLACE = 2 #define XATTR_REPLACE ATTR_REPLACE }; #endif /* XATTR_CREATE */ - #ifndef sighandler_t #define sighandler_t sig_t #endif @@ -141,11 +138,11 @@ enum { /* Using NAME_MAX since EXTATTR_MAXNAMELEN is inside a preprocessor conditional * for the kernel */ -#define GF_XATTR_NAME_MAX NAME_MAX +#define GF_XATTR_NAME_MAX NAME_MAX #endif /* __FreeBSD__ */ #ifdef __NetBSD__ -#define GF_XATTR_NAME_MAX XATTR_NAME_MAX +#define GF_XATTR_NAME_MAX XATTR_NAME_MAX #endif #ifndef ino64_t @@ -169,28 +166,29 @@ enum { #endif /* Posix dictates NAME_MAX to be used */ -# ifndef NAME_MAX -# ifdef MAXNAMLEN -# define NAME_MAX MAXNAMLEN -# else -# define NAME_MAX 255 -# endif -# endif - -#define F_GETLK64 F_GETLK -#define F_SETLK64 F_SETLK -#define F_SETLKW64 F_SETLKW -#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ -#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ -#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */ -#define FALLOC_FL_INSERT_RANGE 0x20 /* Expands the size */ +#ifndef NAME_MAX +#ifdef MAXNAMLEN +#define NAME_MAX MAXNAMLEN +#else +#define NAME_MAX 255 +#endif +#endif + +#define F_GETLK64 F_GETLK +#define F_SETLK64 F_SETLK +#define F_SETLKW64 F_SETLKW +#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */ +#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */ +#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */ +#define FALLOC_FL_INSERT_RANGE 0x20 /* Expands the size */ #define FALLOC_FL_COLLAPSE_RANGE 0x08 /* Reduces the size */ #ifndef _PATH_UMOUNT - #define _PATH_UMOUNT "/sbin/umount" +#define _PATH_UMOUNT "/sbin/umount" #endif -void gf_extattr_list_reshape(char *list, ssize_t size); +void +gf_extattr_list_reshape(char *list, ssize_t size); #endif /* GF_BSD_HOST_OS */ @@ -226,14 +224,12 @@ void gf_extattr_list_reshape(char *list, ssize_t size); #include - #if __DARWIN_64_BIT_INO_T == 0 -# error '64 bit ino_t is must for GlusterFS to work, Compile with "CFLAGS=-D__DARWIN_64_BIT_INO_T"' +#error '64 bit ino_t is must for GlusterFS to work, Compile with "CFLAGS=-D__DARWIN_64_BIT_INO_T"' #endif /* __DARWIN_64_BIT_INO_T */ - #if __DARWIN_64_BIT_INO_T == 0 -# error '64 bit ino_t is must for GlusterFS to work, Compile with "CFLAGS=-D__DARWIN_64_BIT_INO_T"' +#error '64 bit ino_t is must for GlusterFS to work, Compile with "CFLAGS=-D__DARWIN_64_BIT_INO_T"' #endif /* __DARWIN_64_BIT_INO_T */ #ifndef sighandler_t @@ -253,24 +249,24 @@ void gf_extattr_list_reshape(char *list, ssize_t size); #endif /* Posix dictates NAME_MAX to be used */ -# ifndef NAME_MAX -# ifdef MAXNAMLEN -# define NAME_MAX MAXNAMLEN -# else -# define NAME_MAX 255 -# endif -# endif - -#define F_GETLK64 F_GETLK -#define F_SETLK64 F_SETLK -#define F_SETLKW64 F_SETLKW +#ifndef NAME_MAX +#ifdef MAXNAMLEN +#define NAME_MAX MAXNAMLEN +#else +#define NAME_MAX 255 +#endif +#endif + +#define F_GETLK64 F_GETLK +#define F_SETLK64 F_SETLK +#define F_SETLKW64 F_SETLKW #ifndef FTW_CONTINUE - #define FTW_CONTINUE 0 +#define FTW_CONTINUE 0 #endif #ifndef _PATH_UMOUNT - #define _PATH_UMOUNT "/sbin/umount" +#define _PATH_UMOUNT "/sbin/umount" #endif #endif /* GF_DARWIN_HOST_OS */ @@ -291,107 +287,120 @@ void gf_extattr_list_reshape(char *list, ssize_t size); #define lchmod chmod #endif -#define lgetxattr(path, key, value, size) solaris_getxattr(path,key,value,size) +#define lgetxattr(path, key, value, size) \ + solaris_getxattr(path, key, value, size) enum { - ATTR_CREATE = 1, + ATTR_CREATE = 1, #define XATTR_CREATE ATTR_CREATE - ATTR_REPLACE = 2 + ATTR_REPLACE = 2 #define XATTR_REPLACE ATTR_REPLACE }; /* This patch is not present in Solaris 10 and before */ #ifndef dirfd -#define dirfd(dirp) ((dirp)->dd_fd) +#define dirfd(dirp) ((dirp)->dd_fd) #endif /* Posix dictates NAME_MAX to be used */ -# ifndef NAME_MAX -# ifdef MAXNAMLEN -# define NAME_MAX MAXNAMLEN -# else -# define NAME_MAX 255 -# endif -# endif +#ifndef NAME_MAX +#ifdef MAXNAMLEN +#define NAME_MAX MAXNAMLEN +#else +#define NAME_MAX 255 +#endif +#endif #include #ifndef s6_addr16 -#define S6_ADDR16(x) ((uint16_t*) ((char*)&(x).s6_addr)) +#define S6_ADDR16(x) ((uint16_t *)((char *)&(x).s6_addr)) #endif #ifndef s6_addr32 -#define s6_addr32 _S6_un._S6_u32 +#define s6_addr32 _S6_un._S6_u32 #endif -#define lutimes(filename,times) utimes(filename,times) +#define lutimes(filename, times) utimes(filename, times) #ifndef SEEK_SET #define SEEK_SET 0 #endif enum { - DT_UNKNOWN = 0, -# define DT_UNKNOWN DT_UNKNOWN - DT_FIFO = 1, -# define DT_FIFO DT_FIFO - DT_CHR = 2, -# define DT_CHR DT_CHR - DT_DIR = 4, -# define DT_DIR DT_DIR - DT_BLK = 6, -# define DT_BLK DT_BLK - DT_REG = 8, -# define DT_REG DT_REG - DT_LNK = 10, -# define DT_LNK DT_LNK - DT_SOCK = 12, -# define DT_SOCK DT_SOCK - DT_WHT = 14 -# define DT_WHT DT_WHT + DT_UNKNOWN = 0, +#define DT_UNKNOWN DT_UNKNOWN + DT_FIFO = 1, +#define DT_FIFO DT_FIFO + DT_CHR = 2, +#define DT_CHR DT_CHR + DT_DIR = 4, +#define DT_DIR DT_DIR + DT_BLK = 6, +#define DT_BLK DT_BLK + DT_REG = 8, +#define DT_REG DT_REG + DT_LNK = 10, +#define DT_LNK DT_LNK + DT_SOCK = 12, +#define DT_SOCK DT_SOCK + DT_WHT = 14 +#define DT_WHT DT_WHT }; #ifndef _PATH_MOUNTED - #define _PATH_MOUNTED "/etc/mtab" +#define _PATH_MOUNTED "/etc/mtab" #endif #ifndef _PATH_UMOUNT - #define _PATH_UMOUNT "/sbin/umount" +#define _PATH_UMOUNT "/sbin/umount" #endif #ifndef O_ASYNC - #ifdef FASYNC - #define O_ASYNC FASYNC - #else - #define O_ASYNC 0 - #endif +#ifdef FASYNC +#define O_ASYNC FASYNC +#else +#define O_ASYNC 0 #endif - -#ifndef FTW_CONTINUE - #define FTW_CONTINUE 0 #endif -int asprintf(char **string_ptr, const char *format, ...); - -int vasprintf (char **result, const char *format, va_list args); -char* strsep(char** str, const char* delims); -int solaris_listxattr(const char *path, char *list, size_t size); -int solaris_removexattr(const char *path, const char* key); -int solaris_getxattr(const char *path, const char* key, - char *value, size_t size); -int solaris_setxattr(const char *path, const char* key, const char *value, - size_t size, int flags); -int solaris_fgetxattr(int fd, const char* key, - char *value, size_t size); -int solaris_fsetxattr(int fd, const char* key, const char *value, - size_t size, int flags); -int solaris_flistxattr(int fd, char *list, size_t size); - -int solaris_rename (const char *oldpath, const char *newpath); - -int solaris_unlink (const char *pathname); - -char *mkdtemp (char *temp); +#ifndef FTW_CONTINUE +#define FTW_CONTINUE 0 +#endif + +int +asprintf(char **string_ptr, const char *format, ...); + +int +vasprintf(char **result, const char *format, va_list args); +char * +strsep(char **str, const char *delims); +int +solaris_listxattr(const char *path, char *list, size_t size); +int +solaris_removexattr(const char *path, const char *key); +int +solaris_getxattr(const char *path, const char *key, char *value, size_t size); +int +solaris_setxattr(const char *path, const char *key, const char *value, + size_t size, int flags); +int +solaris_fgetxattr(int fd, const char *key, char *value, size_t size); +int +solaris_fsetxattr(int fd, const char *key, const char *value, size_t size, + int flags); +int +solaris_flistxattr(int fd, char *list, size_t size); + +int +solaris_rename(const char *oldpath, const char *newpath); + +int +solaris_unlink(const char *pathname); + +char * +mkdtemp(char *temp); #define GF_SOLARIS_XATTR_DIR ".glusterfs_xattr_inode" -int solaris_xattr_resolve_path (const char *real_path, char **path); +int +solaris_xattr_resolve_path(const char *real_path, char **path); #endif /* GF_SOLARIS_HOST_OS */ @@ -402,52 +411,54 @@ int solaris_xattr_resolve_path (const char *real_path, char **path); #endif /* HAVE_ARGP */ #ifndef HAVE_STRNLEN -size_t strnlen(const char *string, size_t maxlen); +size_t +strnlen(const char *string, size_t maxlen); #endif /* STRNLEN */ #ifndef strdupa -#define strdupa(s) \ - (__extension__ \ - ({ \ - __const char *__old = (s); \ - size_t __len = strlen (__old) + 1; \ - char *__new = (char *) __builtin_alloca (__len); \ - (char *) memcpy (__new, __old, __len); \ - })) +#define strdupa(s) \ + (__extension__({ \ + __const char *__old = (s); \ + size_t __len = strlen(__old) + 1; \ + char *__new = (char *)__builtin_alloca(__len); \ + (char *)memcpy(__new, __old, __len); \ + })) #endif -#define GF_DIR_ALIGN(x) (((x) + sizeof (uint64_t) - 1) & ~(sizeof (uint64_t) - 1)) +#define GF_DIR_ALIGN(x) (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1)) #include #include static inline int32_t -dirent_size (struct dirent *entry) +dirent_size(struct dirent *entry) { - int32_t size = -1; + int32_t size = -1; #ifdef GF_BSD_HOST_OS - size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_namlen); + size = GF_DIR_ALIGN(24 /* FIX MEEEE!!! */ + entry->d_namlen); #endif #ifdef GF_DARWIN_HOST_OS - size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_namlen); + size = GF_DIR_ALIGN(24 /* FIX MEEEE!!! */ + entry->d_namlen); #endif #ifdef GF_LINUX_HOST_OS - size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_reclen); + size = GF_DIR_ALIGN(24 /* FIX MEEEE!!! */ + entry->d_reclen); #endif #ifdef GF_SOLARIS_HOST_OS - size = GF_DIR_ALIGN (24 /* FIX MEEEE!!! */ + entry->d_reclen); + size = GF_DIR_ALIGN(24 /* FIX MEEEE!!! */ + entry->d_reclen); #endif - return size; + return size; } #ifdef THREAD_UNSAFE_BASENAME -char *basename_r(const char *); +char * +basename_r(const char *); #define basename(path) basename_r(path) #endif /* THREAD_UNSAFE_BASENAME */ #ifdef THREAD_UNSAFE_DIRNAME -char *dirname_r(char *path); +char * +dirname_r(char *path); #define dirname(path) dirname_r(path) #endif /* THREAD_UNSAFE_DIRNAME */ @@ -483,9 +494,15 @@ char *dirname_r(char *path); #define ST_ATIM_NSEC(stbuf) (0) #define ST_CTIM_NSEC(stbuf) (0) #define ST_MTIM_NSEC(stbuf) (0) -#define ST_ATIM_NSEC_SET(stbuf, val) do { } while (0); -#define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0); -#define ST_CTIM_NSEC_SET(stbuf, val) do { } while (0); +#define ST_ATIM_NSEC_SET(stbuf, val) \ + do { \ + } while (0); +#define ST_MTIM_NSEC_SET(stbuf, val) \ + do { \ + } while (0); +#define ST_CTIM_NSEC_SET(stbuf, val) \ + do { \ + } while (0); #endif #ifdef GF_BSD_HOST_OS @@ -495,11 +512,12 @@ char *dirname_r(char *path); #if defined(__GNUC__) && !defined(RELAX_POISONING) /* Use run API, see run.h */ #include /* system(), mkostemp() */ -#include /* popen() */ +#include /* popen() */ #pragma GCC poison system mkostemp popen #endif -int gf_umount_lazy(char *xlname, char *path, int rmdir); +int +gf_umount_lazy(char *xlname, char *path, int rmdir); #ifndef GF_XATTR_NAME_MAX #error 'Please define GF_XATTR_NAME_MAX for your OS distribution.' -- cgit