From 8e51827399036bc71163d4471f8edde946787993 Mon Sep 17 00:00:00 2001 From: Ryusuke Konishi Date: Sun, 11 Jan 2026 00:20:34 +0900 Subject: [PATCH] libcnormap: use unsigned int for one-bit bitfields The one-bit bitfields in 'struct nilfs_cnormap' are currently defined as 'int'. On two's complement systems, a one-bit signed integer can only represent 0 and -1, which is not suitable for boolean flags intended to hold 0 or 1. Change them to 'unsigned int' to ensure they can represent 0 and 1 correctly. While at it, clean up the comments for these members to improve readability. This resolves the following Sparse errors reported: cnormap.c:64:35: error: dubious one-bit signed bitfield cnormap.c:69:42: error: dubious one-bit signed bitfield cnormap.c:70:43: error: dubious one-bit signed bitfield Signed-off-by: Ryusuke Konishi --- lib/cnormap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/cnormap.c b/lib/cnormap.c index dd12fb6..ed34263 100644 --- a/lib/cnormap.c +++ b/lib/cnormap.c @@ -61,13 +61,15 @@ struct nilfs_cnormap { int64_t base_time; /* Base time */ int64_t base_clock; /* Monotonic clock at the base time */ - int has_clock_boottime : 1; /* - * Flag that indicates whether - * clock_gettime(CLOCK_BOOTTIME, ) - * is supported or not on the system. - */ - int has_clock_realtime_coarse : 1; /* Has CLOCK_REALTIME_COARSE */ - int has_clock_monotonic_coarse : 1; /* Has CLOCK_MONOTONIC_COARSE */ + /* Clock feature flags */ + unsigned int has_clock_boottime : 1; + /* clock_gettime(CLOCK_BOOTTIME, ) is available */ + + unsigned int has_clock_realtime_coarse : 1; + /* CLOCK_REALTIME_COARSE is available */ + + unsigned int has_clock_monotonic_coarse : 1; + /* CLOCK_MONOTONIC_COARSE is available */ }; struct nilfs_cnormap *nilfs_cnormap_create(struct nilfs *nilfs)