Skip to content

Commit 50e8a28

Browse files
mslusarzLinus Torvalds
authored andcommitted
ext3: replace all adds to little endians variables with le*_add_cpu
replace all: little_endian_variable = cpu_to_leX(leX_to_cpu(little_endian_variable) + expression_in_cpu_byteorder); with: leX_add_cpu(&little_endian_variable, expression_in_cpu_byteorder); sparse didn't generate any new warning with this patch Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com> Cc: Mark Fasheh <mark.fasheh@oracle.com> Cc: David Chinner <dgc@sgi.com> Cc: Timothy Shimmin <tes@sgi.com> Cc: <linux-ext4@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 8b5f688 commit 50e8a28

5 files changed

Lines changed: 13 additions & 26 deletions

File tree

‎fs/ext3/balloc.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,7 @@ void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb,
630630
jbd_unlock_bh_state(bitmap_bh);
631631

632632
spin_lock(sb_bgl_lock(sbi, block_group));
633-
desc->bg_free_blocks_count =
634-
cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) +
635-
group_freed);
633+
le16_add_cpu(&desc->bg_free_blocks_count, group_freed);
636634
spin_unlock(sb_bgl_lock(sbi, block_group));
637635
percpu_counter_add(&sbi->s_freeblocks_counter, count);
638636

@@ -1696,8 +1694,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
16961694
ret_block, goal_hits, goal_attempts);
16971695

16981696
spin_lock(sb_bgl_lock(sbi, group_no));
1699-
gdp->bg_free_blocks_count =
1700-
cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num);
1697+
le16_add_cpu(&gdp->bg_free_blocks_count, -num);
17011698
spin_unlock(sb_bgl_lock(sbi, group_no));
17021699
percpu_counter_sub(&sbi->s_freeblocks_counter, num);
17031700

‎fs/ext3/ialloc.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,9 @@ void ext3_free_inode (handle_t *handle, struct inode * inode)
164164

165165
if (gdp) {
166166
spin_lock(sb_bgl_lock(sbi, block_group));
167-
gdp->bg_free_inodes_count = cpu_to_le16(
168-
le16_to_cpu(gdp->bg_free_inodes_count) + 1);
167+
le16_add_cpu(&gdp->bg_free_inodes_count, 1);
169168
if (is_directory)
170-
gdp->bg_used_dirs_count = cpu_to_le16(
171-
le16_to_cpu(gdp->bg_used_dirs_count) - 1);
169+
le16_add_cpu(&gdp->bg_used_dirs_count, -1);
172170
spin_unlock(sb_bgl_lock(sbi, block_group));
173171
percpu_counter_inc(&sbi->s_freeinodes_counter);
174172
if (is_directory)
@@ -527,11 +525,9 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
527525
err = ext3_journal_get_write_access(handle, bh2);
528526
if (err) goto fail;
529527
spin_lock(sb_bgl_lock(sbi, group));
530-
gdp->bg_free_inodes_count =
531-
cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1);
528+
le16_add_cpu(&gdp->bg_free_inodes_count, -1);
532529
if (S_ISDIR(mode)) {
533-
gdp->bg_used_dirs_count =
534-
cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1);
530+
le16_add_cpu(&gdp->bg_used_dirs_count, 1);
535531
}
536532
spin_unlock(sb_bgl_lock(sbi, group));
537533
BUFFER_TRACE(bh2, "call ext3_journal_dirty_metadata");

‎fs/ext3/resize.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
518518
EXT3_SB(sb)->s_gdb_count++;
519519
kfree(o_group_desc);
520520

521-
es->s_reserved_gdt_blocks =
522-
cpu_to_le16(le16_to_cpu(es->s_reserved_gdt_blocks) - 1);
521+
le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
523522
ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
524523

525524
return 0;
@@ -890,10 +889,8 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
890889
* blocks/inodes before the group is live won't actually let us
891890
* allocate the new space yet.
892891
*/
893-
es->s_blocks_count = cpu_to_le32(le32_to_cpu(es->s_blocks_count) +
894-
input->blocks_count);
895-
es->s_inodes_count = cpu_to_le32(le32_to_cpu(es->s_inodes_count) +
896-
EXT3_INODES_PER_GROUP(sb));
892+
le32_add_cpu(&es->s_blocks_count, input->blocks_count);
893+
le32_add_cpu(&es->s_inodes_count, EXT3_INODES_PER_GROUP(sb));
897894

898895
/*
899896
* We need to protect s_groups_count against other CPUs seeing
@@ -926,8 +923,7 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
926923

927924
/* Update the reserved block counts only once the new group is
928925
* active. */
929-
es->s_r_blocks_count = cpu_to_le32(le32_to_cpu(es->s_r_blocks_count) +
930-
input->reserved_blocks);
926+
le32_add_cpu(&es->s_r_blocks_count, input->reserved_blocks);
931927

932928
/* Update the free space counts */
933929
percpu_counter_add(&sbi->s_freeblocks_counter,

‎fs/ext3/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
12221222
#endif
12231223
if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
12241224
es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT);
1225-
es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
1225+
le16_add_cpu(&es->s_mnt_count, 1);
12261226
es->s_mtime = cpu_to_le32(get_seconds());
12271227
ext3_update_dynamic_rev(sb);
12281228
EXT3_SET_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);

‎fs/ext3/xattr.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode,
492492
get_bh(bh);
493493
ext3_forget(handle, 1, inode, bh, bh->b_blocknr);
494494
} else {
495-
BHDR(bh)->h_refcount = cpu_to_le32(
496-
le32_to_cpu(BHDR(bh)->h_refcount) - 1);
495+
le32_add_cpu(&BHDR(bh)->h_refcount, -1);
497496
error = ext3_journal_dirty_metadata(handle, bh);
498497
if (IS_SYNC(inode))
499498
handle->h_sync = 1;
@@ -780,8 +779,7 @@ ext3_xattr_block_set(handle_t *handle, struct inode *inode,
780779
if (error)
781780
goto cleanup_dquot;
782781
lock_buffer(new_bh);
783-
BHDR(new_bh)->h_refcount = cpu_to_le32(1 +
784-
le32_to_cpu(BHDR(new_bh)->h_refcount));
782+
le32_add_cpu(&BHDR(new_bh)->h_refcount, 1);
785783
ea_bdebug(new_bh, "reusing; refcount now=%d",
786784
le32_to_cpu(BHDR(new_bh)->h_refcount));
787785
unlock_buffer(new_bh);

0 commit comments

Comments
 (0)