]>
Commit | Line | Data |
---|---|---|
37554d48 SL |
1 | From b43daa9f1d29e108520841d6dea0352e1d66a3d3 Mon Sep 17 00:00:00 2001 |
2 | From: Arnd Bergmann <arnd@arndb.de> | |
3 | Date: Fri, 22 Mar 2019 15:07:11 +0100 | |
4 | Subject: nfsd: avoid uninitialized variable warning | |
5 | ||
6 | [ Upstream commit 0ab88ca4bcf18ba21058d8f19220f60afe0d34d8 ] | |
7 | ||
8 | clang warns that 'contextlen' may be accessed without an initialization: | |
9 | ||
10 | fs/nfsd/nfs4xdr.c:2911:9: error: variable 'contextlen' is uninitialized when used here [-Werror,-Wuninitialized] | |
11 | contextlen); | |
12 | ^~~~~~~~~~ | |
13 | fs/nfsd/nfs4xdr.c:2424:16: note: initialize the variable 'contextlen' to silence this warning | |
14 | int contextlen; | |
15 | ^ | |
16 | = 0 | |
17 | ||
18 | Presumably this cannot happen, as FATTR4_WORD2_SECURITY_LABEL is | |
19 | set if CONFIG_NFSD_V4_SECURITY_LABEL is enabled. | |
20 | Adding another #ifdef like the other two in this function | |
21 | avoids the warning. | |
22 | ||
23 | Signed-off-by: Arnd Bergmann <arnd@arndb.de> | |
24 | Signed-off-by: J. Bruce Fields <bfields@redhat.com> | |
25 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
26 | --- | |
27 | fs/nfsd/nfs4xdr.c | 4 ++++ | |
28 | 1 file changed, 4 insertions(+) | |
29 | ||
30 | diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c | |
31 | index 418fa9c78186..db0beefe65ec 100644 | |
32 | --- a/fs/nfsd/nfs4xdr.c | |
33 | +++ b/fs/nfsd/nfs4xdr.c | |
34 | @@ -2413,8 +2413,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, | |
35 | __be32 status; | |
36 | int err; | |
37 | struct nfs4_acl *acl = NULL; | |
38 | +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL | |
39 | void *context = NULL; | |
40 | int contextlen; | |
41 | +#endif | |
42 | bool contextsupport = false; | |
43 | struct nfsd4_compoundres *resp = rqstp->rq_resp; | |
44 | u32 minorversion = resp->cstate.minorversion; | |
45 | @@ -2899,12 +2901,14 @@ out_acl: | |
46 | *p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_TIME_METADATA); | |
47 | } | |
48 | ||
49 | +#ifdef CONFIG_NFSD_V4_SECURITY_LABEL | |
50 | if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) { | |
51 | status = nfsd4_encode_security_label(xdr, rqstp, context, | |
52 | contextlen); | |
53 | if (status) | |
54 | goto out; | |
55 | } | |
56 | +#endif | |
57 | ||
58 | attrlen = htonl(xdr->buf->len - attrlen_offset - 4); | |
59 | write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, 4); | |
60 | -- | |
61 | 2.20.1 | |
62 |