summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.h13
-rw-r--r--src/fsade.c7
-rw-r--r--src/mtab.c3
-rw-r--r--src/xspawn.c3
4 files changed, 19 insertions, 7 deletions
diff --git a/src/config.h b/src/config.h
index a474fb3..9f95674 100644
--- a/src/config.h
+++ b/src/config.h
@@ -186,7 +186,7 @@ typedef long double max_align_t;
// Wrappers for attributes
/**
- * Silence compiler warnings about switch/case fall-throughs.
+ * Silence warnings about switch/case fall-throughs.
*/
#if __has_c_attribute(fallthrough)
# define fallthru [[fallthrough]]
@@ -197,6 +197,17 @@ typedef long double max_align_t;
#endif
/**
+ * Silence warnings about unused declarations.
+ */
+#if __has_c_attribute(maybe_unused)
+# define attr_maybe_unused [[maybe_unused]]
+#elif __has_attribute(unused)
+# define attr_maybe_unused __attribute__((unused))
+#else
+# define attr_maybe_unused
+#endif
+
+/**
* Warn if a value is unused.
*/
#if __has_c_attribute(nodiscard)
diff --git a/src/fsade.c b/src/fsade.c
index cbff47b..4d22d99 100644
--- a/src/fsade.c
+++ b/src/fsade.c
@@ -28,12 +28,11 @@
# include <sys/xattr.h>
#endif
-#if BFS_CAN_CHECK_ACL || BFS_CAN_CHECK_CAPABILITIES || BFS_CAN_CHECK_XATTRS
-
/**
* Many of the APIs used here don't have *at() variants, but we can try to
* emulate something similar if /proc/self/fd is available.
*/
+attr_maybe_unused
static const char *fake_at(const struct BFTW *ftwbuf) {
static atomic int proc_works = -1;
@@ -67,6 +66,7 @@ fail:
return ftwbuf->path;
}
+attr_maybe_unused
static void free_fake_at(const struct BFTW *ftwbuf, const char *path) {
if (path != ftwbuf->path) {
dstrfree((dchar *)path);
@@ -76,6 +76,7 @@ static void free_fake_at(const struct BFTW *ftwbuf, const char *path) {
/**
* Check if an error was caused by the absence of support or data for a feature.
*/
+attr_maybe_unused
static bool is_absence_error(int error) {
// If the OS doesn't support the feature, it's obviously not enabled for
// any files
@@ -114,8 +115,6 @@ static bool is_absence_error(int error) {
return false;
}
-#endif // BFS_CAN_CHECK_ACL || BFS_CAN_CHECK_CAPABILITIES || BFS_CAN_CHECK_XATTRS
-
#if BFS_CAN_CHECK_ACL
/** Check if a POSIX.1e ACL is non-trivial. */
diff --git a/src/mtab.c b/src/mtab.c
index 384fdfc..6b6f9d1 100644
--- a/src/mtab.c
+++ b/src/mtab.c
@@ -59,7 +59,8 @@ struct bfs_mtab {
/**
* Add an entry to the mount table.
*/
-static inline int bfs_mtab_add(struct bfs_mtab *mtab, const char *path, const char *type) {
+attr_maybe_unused
+static int bfs_mtab_add(struct bfs_mtab *mtab, const char *path, const char *type) {
struct bfs_mtab_entry entry = {
.path = strdup(path),
.type = strdup(type),
diff --git a/src/xspawn.c b/src/xspawn.c
index 3974768..51432dd 100644
--- a/src/xspawn.c
+++ b/src/xspawn.c
@@ -73,7 +73,8 @@ int bfs_spawn_destroy(struct bfs_spawn *ctx) {
}
/** Set some posix_spawnattr flags. */
-static inline int bfs_spawn_addflags(struct bfs_spawn *ctx, short flags) {
+attr_maybe_unused
+static int bfs_spawn_addflags(struct bfs_spawn *ctx, short flags) {
short prev;
errno = posix_spawnattr_getflags(&ctx->attr, &prev);
if (errno != 0) {