btrfs-progs: use unsigned types for bit shifts

Bit shifts should be done on unsigned type as a matter of good practice
to avoid any problems with bit overflowing to the sign bit.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-03-12 22:03:36 +01:00
parent 85ea79f6b2
commit 2edd439617
6 changed files with 14 additions and 14 deletions

View File

@ -1957,7 +1957,7 @@ static int fill_chunk_up(struct chunk_record *chunk, struct list_head *devexts,
return ret;
}
#define EQUAL_STRIPE (1 << 0)
#define EQUAL_STRIPE (1U << 0)
static int rebuild_raid_data_chunk_stripes(struct recover_control *rc,
struct btrfs_root *root,

View File

@ -73,7 +73,7 @@
#define BITS_PER_BYTE 8
#define BITS_PER_LONG (__SIZEOF_LONG__ * BITS_PER_BYTE)
#define __GFP_BITS_SHIFT 20
#define __GFP_BITS_MASK ((int)((1 << __GFP_BITS_SHIFT) - 1))
#define __GFP_BITS_MASK ((int)((1U << __GFP_BITS_SHIFT) - 1))
#define __GFP_DMA32 0
#define __GFP_HIGHMEM 0
#define GFP_KERNEL 0

View File

@ -128,19 +128,19 @@ enum btrfs_open_ctree_flags {
enum btrfs_read_sb_flags {
SBREAD_DEFAULT = 0,
/* Reading superblock during recovery */
SBREAD_RECOVER = (1 << 0),
SBREAD_RECOVER = (1U << 0),
/*
* Read superblock with the fake signature, cannot be used with
* SBREAD_RECOVER
*/
SBREAD_TEMPORARY = (1 << 1),
SBREAD_TEMPORARY = (1U << 1),
/*
* Equivalent of OPEN_CTREE_IGNORE_FSID_MISMATCH, allow to read
* superblock that has mismatched sb::fsid and sb::dev_item.fsid
*/
SBREAD_IGNORE_FSID_MISMATCH = (1 << 2),
SBREAD_IGNORE_FSID_MISMATCH = (1U << 2),
};
/*

View File

@ -41,7 +41,7 @@
* single word in a bitmap may straddle two pages in the extent buffer.
*/
#define BIT_BYTE(nr) ((nr) / BITS_PER_BYTE)
#define BYTE_MASK ((1 << BITS_PER_BYTE) - 1)
#define BYTE_MASK ((1U << BITS_PER_BYTE) - 1)
#define BITMAP_FIRST_BYTE_MASK(start) \
((BYTE_MASK << ((start) & (BITS_PER_BYTE - 1))) & BYTE_MASK)
#define BITMAP_LAST_BYTE_MASK(nbits) \

View File

@ -30,15 +30,15 @@ struct extent_buffer;
enum {
/* Depth-first search, nodes and leaves can be interleaved */
BTRFS_PRINT_TREE_DFS = (1 << 0),
BTRFS_PRINT_TREE_DFS = (1U << 0),
/* Breadth-first search, first nodes, then leaves */
BTRFS_PRINT_TREE_BFS = (1 << 1),
BTRFS_PRINT_TREE_BFS = (1U << 1),
/* Follow to child nodes */
BTRFS_PRINT_TREE_FOLLOW = (1 << 2),
BTRFS_PRINT_TREE_FOLLOW = (1U << 2),
/* Print checksum of node/leaf */
BTRFS_PRINT_TREE_CSUM_HEADERS = (1 << 3),
BTRFS_PRINT_TREE_CSUM_HEADERS = (1U << 3),
/* Print checksums in checksum items */
BTRFS_PRINT_TREE_CSUM_ITEMS = (1 << 4),
BTRFS_PRINT_TREE_CSUM_ITEMS = (1U << 4),
BTRFS_PRINT_TREE_DEFAULT = BTRFS_PRINT_TREE_BFS,
};

View File

@ -287,12 +287,12 @@ _static_assert(sizeof(struct btrfs_ioctl_dev_info_args) == 4096);
*/
/* Request information about checksum type and size */
#define BTRFS_FS_INFO_FLAG_CSUM_INFO (1 << 0)
#define BTRFS_FS_INFO_FLAG_CSUM_INFO (1U << 0)
/* Request information about filesystem generation */
#define BTRFS_FS_INFO_FLAG_GENERATION (1 << 1)
#define BTRFS_FS_INFO_FLAG_GENERATION (1U << 1)
/* Request information about filesystem metadata UUID */
#define BTRFS_FS_INFO_FLAG_METADATA_UUID (1 << 2)
#define BTRFS_FS_INFO_FLAG_METADATA_UUID (1U << 2)
struct btrfs_ioctl_fs_info_args {
__u64 max_id; /* out */