From: NeilBrown <neilb@suse.com>
To: Arnd Bergmann <arnd@arndb.de>,
Oleg Drokin <oleg.drokin@intel.com>,
Andreas Dilger <andreas.dilger@intel.com>,
James Simmons <jsimmons@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: lustre: fid: avoid false-positive uninitialized variable warning
Date: Wed, 14 Mar 2018 08:54:39 +1100 [thread overview]
Message-ID: <87lgevd4kg.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20180313130532.4015402-1-arnd@arndb.de>
[-- Attachment #1: Type: text/plain, Size: 1838 bytes --]
On Tue, Mar 13 2018, Arnd Bergmann wrote:
> One of Neil's recent cleanups apparently has led the code to get
> to a state where gcc tracks the 'seqnr' variable just enough to
> see that it is sometimes initialized in seq_client_alloc_seq(),
> but not enough that it can prove this initialization to be reliable
> before the use of that variable:
>
> drivers/staging/lustre/lustre/fid/fid_request.c: In function 'seq_client_alloc_fid':
> drivers/staging/lustre/lustre/fid/fid_request.c:245:22: error: 'seqnr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> The code seems to be otherwise correct, and I could not come
> up with a good way to simplify it further, so this adds a fake
> initialization to shut up that warning.
We could possibly have seq_client_alloc_seq return the seqnr,
or U64_MAX+rc.
Then if (seqnr >= U64MAX-MAX_ERRNO) there is an error.
I'm not sure that is actually an improvement though, and I'm happy with
your approach
Reviewed-by: NeilBrown <neilb@suse.com>
Thanks,
NeilBrown
>
> Cc: NeilBrown <neilb@suse.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/staging/lustre/lustre/fid/fid_request.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c
> index fa23423eb8b3..030680f37c79 100644
> --- a/drivers/staging/lustre/lustre/fid/fid_request.c
> +++ b/drivers/staging/lustre/lustre/fid/fid_request.c
> @@ -174,6 +174,7 @@ static int seq_client_alloc_seq(const struct lu_env *env,
> if (rc) {
> CERROR("%s: Can't allocate new meta-sequence, rc %d\n",
> seq->lcs_name, rc);
> + *seqnr = U64_MAX;
> return rc;
> }
> CDEBUG(D_INFO, "%s: New range - " DRANGE "\n",
> --
> 2.9.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
prev parent reply other threads:[~2018-03-13 21:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 13:05 [PATCH] staging: lustre: fid: avoid false-positive uninitialized variable warning Arnd Bergmann
2018-03-13 21:54 ` NeilBrown [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lgevd4kg.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=andreas.dilger@intel.com \
--cc=arnd@arndb.de \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox