* [patch] Btrfs: remove some no-op casts
@ 2016-10-12 8:33 Dan Carpenter
2016-10-19 14:05 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-10-12 8:33 UTC (permalink / raw)
To: Chris Mason, Omar Sandoval
Cc: Josef Bacik, David Sterba, linux-btrfs, kernel-janitors
We cast 0 to a u8 but then because of type promotion, it's immediately
cast to int back to int before we do a bitwise negate. The cast doesn't
matter in this case, the code works as intended. It causes a static
checker warning though so let's remove it.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 66a7551..8ed05d9 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5569,7 +5569,7 @@ void le_bitmap_set(u8 *map, unsigned int start, int len)
*p |= mask_to_set;
len -= bits_to_set;
bits_to_set = BITS_PER_BYTE;
- mask_to_set = ~(u8)0;
+ mask_to_set = ~0;
p++;
}
if (len) {
@@ -5589,7 +5589,7 @@ void le_bitmap_clear(u8 *map, unsigned int start, int len)
*p &= ~mask_to_clear;
len -= bits_to_clear;
bits_to_clear = BITS_PER_BYTE;
- mask_to_clear = ~(u8)0;
+ mask_to_clear = ~0;
p++;
}
if (len) {
@@ -5679,7 +5679,7 @@ void extent_buffer_bitmap_set(struct extent_buffer *eb, unsigned long start,
kaddr[offset] |= mask_to_set;
len -= bits_to_set;
bits_to_set = BITS_PER_BYTE;
- mask_to_set = ~(u8)0;
+ mask_to_set = ~0;
if (++offset >= PAGE_SIZE && len > 0) {
offset = 0;
page = eb->pages[++i];
@@ -5721,7 +5721,7 @@ void extent_buffer_bitmap_clear(struct extent_buffer *eb, unsigned long start,
kaddr[offset] &= ~mask_to_clear;
len -= bits_to_clear;
bits_to_clear = BITS_PER_BYTE;
- mask_to_clear = ~(u8)0;
+ mask_to_clear = ~0;
if (++offset >= PAGE_SIZE && len > 0) {
offset = 0;
page = eb->pages[++i];
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [patch] Btrfs: remove some no-op casts
2016-10-12 8:33 [patch] Btrfs: remove some no-op casts Dan Carpenter
@ 2016-10-19 14:05 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2016-10-19 14:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: Chris Mason, Omar Sandoval, Josef Bacik, David Sterba,
linux-btrfs, kernel-janitors
On Wed, Oct 12, 2016 at 11:33:21AM +0300, Dan Carpenter wrote:
> We cast 0 to a u8 but then because of type promotion, it's immediately
> cast to int back to int before we do a bitwise negate. The cast doesn't
> matter in this case, the code works as intended. It causes a static
> checker warning though so let's remove it.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applies to the free space tree fixes that are now in master.
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-10-19 14:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-12 8:33 [patch] Btrfs: remove some no-op casts Dan Carpenter
2016-10-19 14:05 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).