libbtrfsutil: 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 a0ff3f19af
commit 85ea79f6b2
3 changed files with 11 additions and 11 deletions

View file

@ -242,12 +242,12 @@ struct btrfs_ioctl_dev_info_args {
*/
/* 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 */

View file

@ -545,12 +545,12 @@ LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_fd);
* %BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY. It requires appropriate privilege
* (CAP_SYS_ADMIN).
*/
#define BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE (1 << 0)
#define BTRFS_UTIL_CREATE_SNAPSHOT_RECURSIVE (1U << 0)
/**
* BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY - Create a read-only snapshot.
*/
#define BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY (1 << 1)
#define BTRFS_UTIL_CREATE_SNAPSHOT_MASK ((1 << 2) - 1)
#define BTRFS_UTIL_CREATE_SNAPSHOT_READ_ONLY (1U << 1)
#define BTRFS_UTIL_CREATE_SNAPSHOT_MASK ((1U << 2) - 1)
/**
* btrfs_util_create_snapshot() - Alias of btrfs_util_snapshot_snapshot(), do not use in new code.
@ -629,8 +629,8 @@ LIBBTRFSUTIL_ALIAS(btrfs_util_create_snapshot_fd2);
* error. Note that this is currently implemented in userspace non-atomically.
* It requires appropriate privilege (CAP_SYS_ADMIN).
*/
#define BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE (1 << 0)
#define BTRFS_UTIL_DELETE_SUBVOLUME_MASK ((1 << 1) - 1)
#define BTRFS_UTIL_DELETE_SUBVOLUME_RECURSIVE (1U << 0)
#define BTRFS_UTIL_DELETE_SUBVOLUME_MASK ((1U << 1) - 1)
/**
* btrfs_util_delete_subvolume() - Alias of btrfs_util_subvolume_delete(), do not use in new code.
@ -698,8 +698,8 @@ struct btrfs_util_subvolume_iterator;
* behavior is pre-order, e.g., foo will be yielded before foo/bar. If this flag
* is specified, foo/bar will be yielded before foo.
*/
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_POST_ORDER (1 << 0)
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_MASK ((1 << 1) - 1)
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_POST_ORDER (1U << 0)
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_MASK ((1U << 1) - 1)
/**
* btrfs_util_create_subvolume_iterator() - Alias of btrfs_util_subvolume_iter_create(), do not use in new code.

View file

@ -784,7 +784,7 @@ PUBLIC enum btrfs_util_error btrfs_util_subvolume_create_fd(int parent_fd,
struct btrfs_util_qgroup_inherit *qgroup_inherit)
LIBBTRFSUTIL_ALIAS(btrfs_util_create_subvolume_fd);
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_CLOSE_FD (1 << 30)
#define BTRFS_UTIL_SUBVOLUME_ITERATOR_CLOSE_FD (1U << 30)
struct search_stack_entry {
union {