staging: lustre: fid: avoid false-positive uninitialized variable warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 13 Mar 2018 13:05:16 +0000 (14:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Mar 2018 11:56:15 +0000 (12:56 +0100)
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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/fid/fid_request.c

index fa23423eb8b3842866ee439ee4ad9d1bd3157a2f..030680f37c791898facc1eea332e49c24ecfac05 100644 (file)
@@ -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",