summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-17 16:10:00 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-17 17:46:16 -0400
commitcf9230659e8d64e95209a4d57cbda8a474049ddb (patch)
tree8df76d6a165473a26f08dbfea9da5ad442460073
parent23e048793401900c8d1768b4ffb0fc4ff623ef3e (diff)
downloadbfs-cf9230659e8d64e95209a4d57cbda8a474049ddb.tar.xz
Cast AT_FDCWD to int for comparisons
Some platforms define AT_FDCWD to a constant like 0xFFFAFDCD that gets typed as an unsigned int.
-rw-r--r--src/bftw.c6
-rw-r--r--src/color.c2
-rw-r--r--src/eval.c2
-rw-r--r--src/exec.c2
-rw-r--r--src/fsade.c2
-rw-r--r--tests/xtouch.c2
6 files changed, 8 insertions, 8 deletions
diff --git a/src/bftw.c b/src/bftw.c
index c4d3c17..5322181 100644
--- a/src/bftw.c
+++ b/src/bftw.c
@@ -1281,7 +1281,7 @@ static int bftw_pin_parent(struct bftw_state *state, struct bftw_file *file) {
int fd = parent->fd;
if (fd < 0) {
- bfs_static_assert(AT_FDCWD != -1);
+ bfs_static_assert((int)AT_FDCWD != -1);
return -1;
}
@@ -1298,7 +1298,7 @@ static int bftw_ioq_opendir(struct bftw_state *state, struct bftw_file *file) {
}
int dfd = bftw_pin_parent(state, file);
- if (dfd < 0 && dfd != AT_FDCWD) {
+ if (dfd < 0 && dfd != (int)AT_FDCWD) {
goto fail;
}
@@ -1450,7 +1450,7 @@ static int bftw_ioq_stat(struct bftw_state *state, struct bftw_file *file) {
}
int dfd = bftw_pin_parent(state, file);
- if (dfd < 0 && dfd != AT_FDCWD) {
+ if (dfd < 0 && dfd != (int)AT_FDCWD) {
goto fail;
}
diff --git a/src/color.c b/src/color.c
index 326291d..a0e553f 100644
--- a/src/color.c
+++ b/src/color.c
@@ -976,7 +976,7 @@ static ssize_t first_broken_offset(const char *path, const struct BFTW *ftwbuf,
} else {
// We're in print_link_target(), so resolve relative to the link's parent directory
at_fd = ftwbuf->at_fd;
- if (at_fd == AT_FDCWD && path[0] != '/') {
+ if (at_fd == (int)AT_FDCWD && path[0] != '/') {
at_path = dstrndup(ftwbuf->path, ftwbuf->nameoff);
if (at_path && dstrncat(&at_path, path, max) != 0) {
ret = -1;
diff --git a/src/eval.c b/src/eval.c
index 49028b7..4fcda60 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1270,7 +1270,7 @@ static void debug_stat(const struct bfs_ctx *ctx, const struct BFTW *ftwbuf, enu
bfs_debug_prefix(ctx, DEBUG_STAT);
fprintf(stderr, "bfs_stat(");
- if (ftwbuf->at_fd == AT_FDCWD) {
+ if (ftwbuf->at_fd == (int)AT_FDCWD) {
fprintf(stderr, "AT_FDCWD");
} else {
size_t baselen = strlen(ftwbuf->path) - strlen(ftwbuf->at_path);
diff --git a/src/exec.c b/src/exec.c
index 15b3c79..cd73d6c 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -268,7 +268,7 @@ static int bfs_exec_openwd(struct bfs_exec *execbuf, const struct BFTW *ftwbuf)
bfs_assert(execbuf->wd_fd < 0);
bfs_assert(!execbuf->wd_path);
- if (ftwbuf->at_fd != AT_FDCWD) {
+ if (ftwbuf->at_fd != (int)AT_FDCWD) {
// Rely on at_fd being the immediate parent
bfs_assert(xbaseoff(ftwbuf->at_path) == 0);
diff --git a/src/fsade.c b/src/fsade.c
index d56fb07..7310141 100644
--- a/src/fsade.c
+++ b/src/fsade.c
@@ -41,7 +41,7 @@ static const char *fake_at(const struct BFTW *ftwbuf) {
static atomic int proc_works = -1;
dchar *path = NULL;
- if (ftwbuf->at_fd == AT_FDCWD || load(&proc_works, relaxed) == 0) {
+ if (ftwbuf->at_fd == (int)AT_FDCWD || load(&proc_works, relaxed) == 0) {
goto fail;
}
diff --git a/tests/xtouch.c b/tests/xtouch.c
index cd41842..427e3e0 100644
--- a/tests/xtouch.c
+++ b/tests/xtouch.c
@@ -120,7 +120,7 @@ static int at_flags(const struct args *args) {
/** Touch one path. */
static int xtouch(const struct args *args, const char *path) {
int dfd = open_parent(args, &path);
- if (dfd < 0 && dfd != AT_FDCWD) {
+ if (dfd < 0 && dfd != (int)AT_FDCWD) {
return -1;
}