Convert #if defined to #ifdef where possible (#2698)

Suggested by clang-tidy.
This commit is contained in:
Andrew Gaul
2025-08-01 10:43:44 +09:00
committed by GitHub
parent 57b5d367f2
commit c78517d410
3 changed files with 18 additions and 18 deletions

View File

@ -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

View File

@ -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;

View File

@ -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