[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20201107032330.GN1750809@mit.edu>
Date: Fri, 6 Nov 2020 22:23:30 -0500
From: "Theodore Y. Ts'o" <tytso@....edu>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: Harshad Shirwadkar <harshadshirwadkar@...il.com>,
Andreas Dilger <adilger.kernel@...ger.ca>,
linux-ext4@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] ext4: silence an uninitialized variable warning
On Fri, Oct 30, 2020 at 02:46:20PM +0300, Dan Carpenter wrote:
> Smatch complains that "i" can be uninitialized if we don't enter the
> loop. I don't know if it's possible but we may as well silence this
> warning.
Thanks, applied.
I changed the patch so that i gets initialized to sb->s_blocksize
instead of 0. The only way the for loop could be skipped entirely,
leaving i initialized, is if the in-memory data structures, in
particular the bh->b_data for the on-disk superblock has gotten
corrupted enough that calculated value of group is >= to
ext4_get_groups_count(sb). In that case, we want to exit immediately
without allocating a block, and if i is left to sb->s_blocksize, that
will cause the function to bail out right after the skipped for loop.
- Ted
Powered by blists - more mailing lists