summaryrefslogtreecommitdiffstats
path: root/src/stat.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-08-07 19:11:18 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-08-07 19:41:38 -0400
commit3438244e02304700fa21f26798df363cfedfd78f (patch)
treeab9bec9dd31f50518bf51ec1f52b6b5ccb7765a7 /src/stat.c
parent2bc5a379b5f4f6a35465a2df19107209ed191d06 (diff)
downloadbfs-3438244e02304700fa21f26798df363cfedfd78f.tar.xz
stat: Don't check for statx() mask bits we already checked for
Diffstat (limited to 'src/stat.c')
-rw-r--r--src/stat.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/src/stat.c b/src/stat.c
index 7a413cd..e8f48ee 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -162,7 +162,7 @@ static int bfs_statx_impl(int at_fd, const char *at_path, int at_flags, struct b
}
// Callers shouldn't have to check anything except the times
- const unsigned int guaranteed = STATX_BASIC_STATS ^ (STATX_ATIME | STATX_CTIME | STATX_MTIME);
+ const unsigned int guaranteed = STATX_BASIC_STATS & ~(STATX_ATIME | STATX_CTIME | STATX_MTIME);
if ((xbuf.stx_mask & guaranteed) != guaranteed) {
errno = ENOTSUP;
return -1;
@@ -173,43 +173,27 @@ static int bfs_statx_impl(int at_fd, const char *at_path, int at_flags, struct b
buf->dev = xmakedev(xbuf.stx_dev_major, xbuf.stx_dev_minor);
buf->mask |= BFS_STAT_DEV;
- if (xbuf.stx_mask & STATX_INO) {
- buf->ino = xbuf.stx_ino;
- buf->mask |= BFS_STAT_INO;
- }
+ buf->ino = xbuf.stx_ino;
+ buf->mask |= BFS_STAT_INO;
buf->mode = xbuf.stx_mode;
- if (xbuf.stx_mask & STATX_TYPE) {
- buf->mask |= BFS_STAT_TYPE;
- }
- if (xbuf.stx_mask & STATX_MODE) {
- buf->mask |= BFS_STAT_MODE;
- }
+ buf->mask |= BFS_STAT_TYPE;
+ buf->mask |= BFS_STAT_MODE;
- if (xbuf.stx_mask & STATX_NLINK) {
- buf->nlink = xbuf.stx_nlink;
- buf->mask |= BFS_STAT_NLINK;
- }
+ buf->nlink = xbuf.stx_nlink;
+ buf->mask |= BFS_STAT_NLINK;
- if (xbuf.stx_mask & STATX_GID) {
- buf->gid = xbuf.stx_gid;
- buf->mask |= BFS_STAT_GID;
- }
+ buf->gid = xbuf.stx_gid;
+ buf->mask |= BFS_STAT_GID;
- if (xbuf.stx_mask & STATX_UID) {
- buf->uid = xbuf.stx_uid;
- buf->mask |= BFS_STAT_UID;
- }
+ buf->uid = xbuf.stx_uid;
+ buf->mask |= BFS_STAT_UID;
- if (xbuf.stx_mask & STATX_SIZE) {
- buf->size = xbuf.stx_size;
- buf->mask |= BFS_STAT_SIZE;
- }
+ buf->size = xbuf.stx_size;
+ buf->mask |= BFS_STAT_SIZE;
- if (xbuf.stx_mask & STATX_BLOCKS) {
- buf->blocks = xbuf.stx_blocks;
- buf->mask |= BFS_STAT_BLOCKS;
- }
+ buf->blocks = xbuf.stx_blocks;
+ buf->mask |= BFS_STAT_BLOCKS;
buf->rdev = xmakedev(xbuf.stx_rdev_major, xbuf.stx_rdev_minor);
buf->mask |= BFS_STAT_RDEV;