Re: [f2fs-dev] [bug report] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC
On 02/27, Dan Carpenter wrote: > Hello Jaegeuk Kim, > > The patch 9c1d3cd4ff8c: "f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and > SEGS_PER_SEC" from Feb 6, 2024 (linux-next), leads to the following > Smatch static checker warning: > > fs/f2fs/gc.c:2092 update_fs_metadata() > warn: cast after binop > > fs/f2fs/gc.c > 2089 static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs) > 2090 { > 2091 int segs = secs * SEGS_PER_SEC(sbi); > --> 2092 long long blks = (long long)(segs << > sbi->log_blocks_per_seg); > > ^^ > Originally this was something like: > > long long blks = (long long)segs << sbi->log_blocks_per_seg; Thanks. I just reverted this line back to the original cast one. > > So the cast seemed necessary to avoid an integer overflow. > > 2093 long long user_block_count = > 2094 > le64_to_cpu(F2FS_CKPT(sbi)->user_block_count); > 2095 > 2096 SM_I(sbi)->segment_count = (int)SM_I(sbi)->segment_count + > segs; > 2097 MAIN_SEGS(sbi) = (int)MAIN_SEGS(sbi) + segs; > > regards, > dan carpenter ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
[f2fs-dev] [bug report] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC
Hello Jaegeuk Kim, The patch 9c1d3cd4ff8c: "f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC" from Feb 6, 2024 (linux-next), leads to the following Smatch static checker warning: fs/f2fs/gc.c:2092 update_fs_metadata() warn: cast after binop fs/f2fs/gc.c 2089 static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs) 2090 { 2091 int segs = secs * SEGS_PER_SEC(sbi); --> 2092 long long blks = (long long)(segs << sbi->log_blocks_per_seg); ^^ Originally this was something like: long long blks = (long long)segs << sbi->log_blocks_per_seg; So the cast seemed necessary to avoid an integer overflow. 2093 long long user_block_count = 2094 le64_to_cpu(F2FS_CKPT(sbi)->user_block_count); 2095 2096 SM_I(sbi)->segment_count = (int)SM_I(sbi)->segment_count + segs; 2097 MAIN_SEGS(sbi) = (int)MAIN_SEGS(sbi) + segs; regards, dan carpenter ___ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel