aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2024-03-12 22:03:36 +0100
committerDavid Sterba <dsterba@suse.com>2024-03-12 22:05:09 +0100
commit2edd439617a1a536c5f0ccec6fb4a5e6715aa203 (patch)
treed1c1d52bd79282050418e4dae9afae7f82f972cf
parent85ea79f6b2a3743b9999cda93774387cfae01766 (diff)
downloadbtrfs-progs-2edd439617a1a536c5f0ccec6fb4a5e6715aa203.tar.gz
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>
-rw-r--r--cmds/rescue-chunk-recover.c2
-rw-r--r--include/kerncompat.h2
-rw-r--r--kernel-shared/disk-io.h6
-rw-r--r--kernel-shared/extent_io.h2
-rw-r--r--kernel-shared/print-tree.h10
-rw-r--r--kernel-shared/uapi/btrfs.h6
6 files changed, 14 insertions, 14 deletions
diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c
index 7998afc3..328154af 100644
--- a/cmds/rescue-chunk-recover.c
+++ b/cmds/rescue-chunk-recover.c
@@ -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,
diff --git a/include/kerncompat.h b/include/kerncompat.h
index 18b474f6..3f981bf3 100644
--- a/include/kerncompat.h
+++ b/include/kerncompat.h
@@ -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
diff --git a/kernel-shared/disk-io.h b/kernel-shared/disk-io.h
index 647fccd9..9f848635 100644
--- a/kernel-shared/disk-io.h
+++ b/kernel-shared/disk-io.h
@@ -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),
};
/*
diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h
index 0885b941..99f6765a 100644
--- a/kernel-shared/extent_io.h
+++ b/kernel-shared/extent_io.h
@@ -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) \
diff --git a/kernel-shared/print-tree.h b/kernel-shared/print-tree.h
index d857e1da..3c4cee90 100644
--- a/kernel-shared/print-tree.h
+++ b/kernel-shared/print-tree.h
@@ -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,
};
diff --git a/kernel-shared/uapi/btrfs.h b/kernel-shared/uapi/btrfs.h
index 34e84b89..e5e62eac 100644
--- a/kernel-shared/uapi/btrfs.h
+++ b/kernel-shared/uapi/btrfs.h
@@ -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 */