[PATCH 6/7] libsupport: fix gcc -Wall warnings

Theodore Ts'o
2026-05-04T23:33:28Z

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
lib/support/cache.c | 12 +++++++++---
lib/support/cache.h | 2 +-
lib/support/list.h | 8 ++++----
3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/lib/support/cache.c b/lib/support/cache.c
index aec785347..ece0adece 100644
--- a/lib/support/cache.c
+++ b/lib/support/cache.c
@@ -15,6 +15,12 @@
#include <stdint.h>
#include <errno.h>

+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
#include "config.h"
#include "list.h"
#include "cache.h"
@@ -711,7 +717,7 @@ cache_node_put(

void
cache_node_set_priority(
- struct cache * cache,
+ struct cache * cache EXT2FS_ATTR((unused)),
struct cache_node * node,
int priority)
{
@@ -820,7 +826,7 @@ cache_flush(
{
struct cache_hash *hash;
struct cache_node *node;
- int i;
+ unsigned int i;
bool still_dirty = false;

if (!cache->flush)
@@ -848,7 +854,7 @@ cache_report(
const char *name,
struct cache *cache)
{
- int i;
+ unsigned int i;
unsigned long count, index, total;
unsigned long hash_bucket_lengths[HASH_REPORT + 2] = { 0 };

diff --git a/lib/support/cache.h b/lib/support/cache.h
index 71fb9762f..cd0e8c20e 100644
--- a/lib/support/cache.h
+++ b/lib/support/cache.h
@@ -83,7 +83,7 @@ typedef unsigned int (*cache_node_resize_t)(const struct cache *c,
unsigned int curr_size,
int dir);

-static inline unsigned int cache_gradual_resize(const struct cache *cache,
+static inline unsigned int cache_gradual_resize(const struct cache *cache EXT2FS_ATTR((unused)),
unsigned int curr_size,
int dir)
{
diff --git a/lib/support/list.h b/lib/support/list.h
index 0ec8de525..54e8e2360 100644
--- a/lib/support/list.h
+++ b/lib/support/list.h
@@ -148,13 +148,13 @@ static __always_inline bool __list_del_entry_valid(struct list_head *entry)
return ret;
}
#else
-static inline bool __list_add_valid(struct list_head *new,
- struct list_head *prev,
- struct list_head *next)
+static inline bool __list_add_valid(struct list_head *new EXT2FS_ATTR((unused)),
+ struct list_head *prev EXT2FS_ATTR((unused)),
+ struct list_head *next EXT2FS_ATTR((unused)))
{
return true;
}
-static inline bool __list_del_entry_valid(struct list_head *entry)
+static inline bool __list_del_entry_valid(struct list_head *entry EXT2FS_ATTR((unused)))
{
return true;
}
--
2.53.0