* [f2fs-dev] [bug report] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC
@ 2024-02-27 15:22 Dan Carpenter
2024-02-27 17:42 ` Jaegeuk Kim
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-02-27 15:22 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [f2fs-dev] [bug report] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC
2024-02-27 15:22 [f2fs-dev] [bug report] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC Dan Carpenter
@ 2024-02-27 17:42 ` Jaegeuk Kim
0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2024-02-27 17:42 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-f2fs-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-02-27 17:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 15:22 [f2fs-dev] [bug report] f2fs: use BLKS_PER_SEG, BLKS_PER_SEC, and SEGS_PER_SEC Dan Carpenter
2024-02-27 17:42 ` Jaegeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.