From: "J. Bruce Fields" <bfields@fieldses.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Jeff Layton <jlayton@kernel.org>,
clang-built-linux@googlegroups.com,
Nick Desaulniers <ndesaulniers@google.com>,
Nathan Chancellor <natechancellor@gmail.com>,
Olga Kornievskaia <kolga@netapp.com>,
Chuck Lever <chuck.lever@oracle.com>,
Scott Mayhew <smayhew@redhat.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfsd: avoid uninitialized variable warning
Date: Fri, 22 Mar 2019 11:23:39 -0400 [thread overview]
Message-ID: <20190322152339.GA7692@fieldses.org> (raw)
In-Reply-To: <20190322140726.251521-1-arnd@arndb.de>
On Fri, Mar 22, 2019 at 03:07:11PM +0100, Arnd Bergmann wrote:
> clang warns that 'contextlen' may be accessed without an initialization:
>
> fs/nfsd/nfs4xdr.c:2911:9: error: variable 'contextlen' is uninitialized when used here [-Werror,-Wuninitialized]
> contextlen);
> ^~~~~~~~~~
> fs/nfsd/nfs4xdr.c:2424:16: note: initialize the variable 'contextlen' to silence this warning
> int contextlen;
> ^
> = 0
>
> Presumably this cannot happen, as FATTR4_WORD2_SECURITY_LABEL is
> set if CONFIG_NFSD_V4_SECURITY_LABEL is enabled.
> Adding another #ifdef like the other two in this function
> avoids the warning.
Thanks, applied.--b.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> fs/nfsd/nfs4xdr.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 3de42a729093..a3a3455826aa 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -2420,8 +2420,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
> __be32 status;
> int err;
> struct nfs4_acl *acl = NULL;
> +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
> void *context = NULL;
> int contextlen;
> +#endif
> bool contextsupport = false;
> struct nfsd4_compoundres *resp = rqstp->rq_resp;
> u32 minorversion = resp->cstate.minorversion;
> @@ -2906,12 +2908,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
> *p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_TIME_METADATA);
> }
>
> +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
> if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
> status = nfsd4_encode_security_label(xdr, rqstp, context,
> contextlen);
> if (status)
> goto out;
> }
> +#endif
>
> attrlen = htonl(xdr->buf->len - attrlen_offset - 4);
> write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, 4);
> --
> 2.20.0
prev parent reply other threads:[~2019-03-22 15:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 14:07 [PATCH] nfsd: avoid uninitialized variable warning Arnd Bergmann
2019-03-22 15:23 ` J. Bruce Fields [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=20190322152339.GA7692@fieldses.org \
--to=bfields@fieldses.org \
--cc=arnd@arndb.de \
--cc=chuck.lever@oracle.com \
--cc=clang-built-linux@googlegroups.com \
--cc=jlayton@kernel.org \
--cc=kolga@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=smayhew@redhat.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