Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nilfs2: use div64_ul() instead of do_div()

Fixes Coccinelle/coccicheck warnings reported by do_div.cocci.

Compared to do_div(), div64_ul() does not implicitly cast the divisor and
does not unnecessarily calculate the remainder.

Link: https://lkml.kernel.org/r/20240229210456.63234-2-thorsten.blum@toblux.com
Link: https://lkml.kernel.org/r/20240306142547.4612-1-konishi.ryusuke@gmail.com
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Thorsten Blum and committed by
Andrew Morton
adc2c8d0 8c86fb68

+7 -7
+1 -1
fs/nilfs2/cpfile.c
··· 28 28 { 29 29 __u64 tcno = cno + NILFS_MDT(cpfile)->mi_first_entry_offset - 1; 30 30 31 - do_div(tcno, nilfs_cpfile_checkpoints_per_block(cpfile)); 31 + tcno = div64_ul(tcno, nilfs_cpfile_checkpoints_per_block(cpfile)); 32 32 return (unsigned long)tcno; 33 33 } 34 34
+1 -1
fs/nilfs2/dat.c
··· 460 460 kaddr = kmap_local_page(entry_bh->b_page); 461 461 /* last virtual block number in this block */ 462 462 first = vinfo->vi_vblocknr; 463 - do_div(first, entries_per_block); 463 + first = div64_ul(first, entries_per_block); 464 464 first *= entries_per_block; 465 465 last = first + entries_per_block - 1; 466 466 for (j = i, n = 0;
+2 -2
fs/nilfs2/ioctl.c
··· 1111 1111 segbytes = nilfs->ns_blocks_per_segment * nilfs->ns_blocksize; 1112 1112 1113 1113 minseg = range[0] + segbytes - 1; 1114 - do_div(minseg, segbytes); 1114 + minseg = div64_ul(minseg, segbytes); 1115 1115 1116 1116 if (range[1] < 4096) 1117 1117 goto out; ··· 1120 1120 if (maxseg < segbytes) 1121 1121 goto out; 1122 1122 1123 - do_div(maxseg, segbytes); 1123 + maxseg = div64_ul(maxseg, segbytes); 1124 1124 maxseg--; 1125 1125 1126 1126 ret = nilfs_sufile_set_alloc_range(nilfs->ns_sufile, minseg, maxseg);
+1 -1
fs/nilfs2/sufile.c
··· 48 48 { 49 49 __u64 t = segnum + NILFS_MDT(sufile)->mi_first_entry_offset; 50 50 51 - do_div(t, nilfs_sufile_segment_usages_per_block(sufile)); 51 + t = div64_ul(t, nilfs_sufile_segment_usages_per_block(sufile)); 52 52 return (unsigned long)t; 53 53 } 54 54
+1 -1
fs/nilfs2/super.c
··· 448 448 449 449 sb2off = NILFS_SB2_OFFSET_BYTES(newsize); 450 450 newnsegs = sb2off >> nilfs->ns_blocksize_bits; 451 - do_div(newnsegs, nilfs->ns_blocks_per_segment); 451 + newnsegs = div64_ul(newnsegs, nilfs->ns_blocks_per_segment); 452 452 453 453 ret = nilfs_sufile_resize(nilfs->ns_sufile, newnsegs); 454 454 up_write(&nilfs->ns_segctor_sem);
+1 -1
fs/nilfs2/the_nilfs.c
··· 413 413 { 414 414 u64 max_count = U64_MAX; 415 415 416 - do_div(max_count, nilfs->ns_blocks_per_segment); 416 + max_count = div64_ul(max_count, nilfs->ns_blocks_per_segment); 417 417 return min_t(u64, max_count, ULONG_MAX); 418 418 } 419 419