From c78517d41090aa711e3205de45227c9c9dc9944e Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Fri, 1 Aug 2025 10:43:44 +0900 Subject: [PATCH] Convert #if defined to #ifdef where possible (#2698) Suggested by clang-tidy. --- src/common.h | 2 +- src/s3fs.cpp | 22 +++++++++++----------- src/s3fs_util.cpp | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/common.h b/src/common.h index 38fcf65..9717b25 100644 --- a/src/common.h +++ b/src/common.h @@ -54,7 +54,7 @@ extern std::string instance_name; //------------------------------------------------------------------- // For clang -Wthread-safety //------------------------------------------------------------------- -#if defined(__clang__) +#ifdef __clang__ #define THREAD_ANNOTATION_ATTRIBUTE(x) __attribute__((x)) #else #define THREAD_ANNOTATION_ATTRIBUTE(x) // no-op diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 0441b13..7ea0039 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -62,7 +62,7 @@ //------------------------------------------------------------------- // Symbols //------------------------------------------------------------------- -#if !defined(ENOATTR) +#ifndef ENOATTR #define ENOATTR ENODATA #endif @@ -172,7 +172,7 @@ static int s3fs_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off static int s3fs_access(const char* path, int mask); static void* s3fs_init(struct fuse_conn_info* conn); static void s3fs_destroy(void*); -#if defined(__APPLE__) +#ifdef __APPLE__ static int s3fs_setxattr(const char* path, const char* name, const char* value, size_t size, int flags, uint32_t position); static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size, uint32_t position); #else @@ -886,7 +886,7 @@ static int s3fs_getattr(const char* _path, struct stat* stbuf) WTF8_ENCODE(path) int result; -#if defined(__APPLE__) +#ifdef __APPLE__ FUSE_CTX_DBG("[path=%s]", path); #else FUSE_CTX_INFO("[path=%s]", path); @@ -2834,7 +2834,7 @@ static int s3fs_truncate(const char* _path, off_t size) return -EIO; } -#if defined(__APPLE__) +#ifdef __APPLE__ // [NOTE] // Only for macos, this truncate calls to "size=0" do not reflect size. // The cause is unknown now, but it can be avoided by flushing the file. @@ -3057,7 +3057,7 @@ static int s3fs_statfs(const char* _path, struct statvfs* stbuf) stbuf->f_bsize = s3fs_block_size; stbuf->f_namemax = NAME_MAX; -#if defined(__MSYS__) +#ifdef __MSYS__ // WinFsp resolves the free space from f_bfree * f_frsize, and the total space from f_blocks * f_frsize (in bytes). stbuf->f_blocks = bucket_block_count; stbuf->f_frsize = stbuf->f_bsize; @@ -3792,14 +3792,14 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v headers_t::iterator iter; if(meta.cend() == (iter = meta.find("x-amz-meta-xattr"))){ -#if defined(XATTR_REPLACE) +#ifdef XATTR_REPLACE if(XATTR_REPLACE == (flags & XATTR_REPLACE)){ // there is no xattr header but flags is replace, so failure. return -ENOATTR; } #endif }else{ -#if defined(XATTR_CREATE) +#ifdef XATTR_CREATE if(XATTR_CREATE == (flags & XATTR_CREATE)){ // found xattr header but flags is only creating, so failure. return -EEXIST; @@ -3822,7 +3822,7 @@ static int set_xattrs_to_header(headers_t& meta, const char* name, const char* v return 0; } -#if defined(__APPLE__) +#ifdef __APPLE__ static int s3fs_setxattr(const char* _path, const char* name, const char* value, size_t size, int flags, uint32_t position) #else static int s3fs_setxattr(const char* _path, const char* name, const char* value, size_t size, int flags) @@ -3833,7 +3833,7 @@ static int s3fs_setxattr(const char* _path, const char* name, const char* value, return 0; } -#if defined(__APPLE__) +#ifdef __APPLE__ if(position != 0){ // No resource fork support return -EINVAL; @@ -3986,7 +3986,7 @@ static int s3fs_setxattr(const char* _path, const char* name, const char* value, return 0; } -#if defined(__APPLE__) +#ifdef __APPLE__ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size, uint32_t position) #else static int s3fs_getxattr(const char* path, const char* name, char* value, size_t size) @@ -3998,7 +3998,7 @@ static int s3fs_getxattr(const char* path, const char* name, char* value, size_t return -EIO; } -#if defined(__APPLE__) +#ifdef __APPLE__ if (position != 0) { // No resource fork support return -EINVAL; diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index 5e16549..a146ed7 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -442,7 +442,7 @@ int compare_timespec(const struct stat& st, stat_time_type type, const struct ti void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct timespec& ts) { if(stat_time_type::ATIME == type){ - #if defined(__APPLE__) + #ifdef __APPLE__ st.st_atime = ts.tv_sec; st.st_atimespec.tv_nsec = ts.tv_nsec; #else @@ -450,7 +450,7 @@ void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct tim st.st_atim.tv_nsec = ts.tv_nsec; #endif }else if(stat_time_type::MTIME == type){ - #if defined(__APPLE__) + #ifdef __APPLE__ st.st_mtime = ts.tv_sec; st.st_mtimespec.tv_nsec = ts.tv_nsec; #else @@ -458,7 +458,7 @@ void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct tim st.st_mtim.tv_nsec = ts.tv_nsec; #endif }else if(stat_time_type::CTIME == type){ - #if defined(__APPLE__) + #ifdef __APPLE__ st.st_ctime = ts.tv_sec; st.st_ctimespec.tv_nsec = ts.tv_nsec; #else @@ -473,21 +473,21 @@ void set_timespec_to_stat(struct stat& st, stat_time_type type, const struct tim struct timespec* set_stat_to_timespec(const struct stat& st, stat_time_type type, struct timespec& ts) { if(stat_time_type::ATIME == type){ - #if defined(__APPLE__) + #ifdef __APPLE__ ts.tv_sec = st.st_atime; ts.tv_nsec = st.st_atimespec.tv_nsec; #else ts = st.st_atim; #endif }else if(stat_time_type::MTIME == type){ - #if defined(__APPLE__) + #ifdef __APPLE__ ts.tv_sec = st.st_mtime; ts.tv_nsec = st.st_mtimespec.tv_nsec; #else ts = st.st_mtim; #endif }else if(stat_time_type::CTIME == type){ - #if defined(__APPLE__) + #ifdef __APPLE__ ts.tv_sec = st.st_ctime; ts.tv_nsec = st.st_ctimespec.tv_nsec; #else