On Tue, Jun 3, 2025 at 9:52 AM Daeho Jeong <daeh...@gmail.com> wrote:
>
> On Tue, Jun 3, 2025 at 12:29 AM Chao Yu via Linux-f2fs-devel
> <linux-f2fs-devel@lists.sourceforge.net> wrote:
> >
> > fsck.c: In function ‘chk_and_fix_wp_with_sit’:
> > fsck.c:3529:17: error: variable-sized object may not be initialized
> >  3529 |                 char buffer[F2FS_BLKSIZE] = {};
> >       |                 ^~~~
> >
> > The reason is F2FS_BLKSIZE macro is defined w/ c.blksize, let's use
> > calloc() to allocate zeroed memory to fix this issue.
> >
> > Cc: Daeho Jeong <daehoje...@google.com>
> > Signed-off-by: Chao Yu <c...@kernel.org>
> > ---
> >  fsck/fsck.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/fsck/fsck.c b/fsck/fsck.c
> > index 4d05e1b..bb39f8b 100644
> > --- a/fsck/fsck.c
> > +++ b/fsck/fsck.c
> > @@ -3526,7 +3526,7 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), 
> > void *blkzone, void *opaque)
> >
> >         ret = f2fs_finish_zone(wpd->dev_index, blkz);
> >         if (ret) {
> > -               u8 buffer[F2FS_BLKSIZE] = {};
> > +               u8 *buffer;
> >                 u64 blk_addr = wp_block;
> >                 u64 fill_sects = blk_zone_length(blkz) -
> >                         (blk_zone_wp_sector(blkz) - blk_zone_sector(blkz));
> > @@ -3534,6 +3534,9 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), 
> > void *blkzone, void *opaque)
> >                 struct seg_entry *se = get_seg_entry(sbi, wp_segno);
> >                 enum rw_hint whint = f2fs_io_type_to_rw_hint(se->type);
> >
> > +               buffer = calloc(F2FS_BLKSIZE, 1);
> > +               ASSERT(buffer);
> > +
> >                 printf("[FSCK] Finishing zone failed: %s\n", dev->path);
> >                 while (len--) {
> >                         ret = dev_fill_block(buffer, blk_addr++, whint);
> > @@ -3542,6 +3545,8 @@ static int chk_and_fix_wp_with_sit(int UNUSED(i), 
> > void *blkzone, void *opaque)
> >                                 break;
> >                         }
> >                 }
> > +
> > +               free(buffer);
> >         }
> >
> >         if (!ret)
> > --
> > 2.40.1
> >
>
> Reviewed-by: Chao Yu <daehoje...@google.com>
>
> Thanks,

Oops,

Reviewed-by: Daeho Jeong <daehoje...@google.com>

Thanks,

>
> >
> >
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to