Skip to content

Commit 3d8ab67

Browse files
committedFeb 11, 2025
btrfs-progs: fix UNITS_DECIMAL and UNITS_NEGATIVE bit definitions
The values of UNITS_ modes are supposed to be unique and non-overlapping. Due to wrong definition this was not true for UNITS_DECIMAL which set 2 bits. This breaks code that strictly depends on the uniqueness of the bits and not on the order of processing of the constants. Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 6609489 commit 3d8ab67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎common/units.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#define UNITS_TBYTES (5)
3232
#define UNITS_RAW (1U << UNITS_MODE_SHIFT)
3333
#define UNITS_BINARY (2U << UNITS_MODE_SHIFT)
34-
#define UNITS_DECIMAL (3U << UNITS_MODE_SHIFT)
34+
#define UNITS_DECIMAL (4U << UNITS_MODE_SHIFT)
3535
/* Interpret the u64 value as s64 */
36-
#define UNITS_NEGATIVE (4U << UNITS_MODE_SHIFT)
36+
#define UNITS_NEGATIVE (8U << UNITS_MODE_SHIFT)
3737
#define UNITS_MODE_MASK ((1U << UNITS_MODE_SHIFT) - 1)
3838
#define UNITS_MODE_SHIFT (8)
3939
#define UNITS_HUMAN_BINARY (UNITS_BINARY)

0 commit comments

Comments
 (0)
Please sign in to comment.