Skip to content

Commit 0ab88ca

Browse files
arndbJ. Bruce Fields
authored andcommitted
nfsd: avoid uninitialized variable warning
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. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent f456458 commit 0ab88ca

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/nfsd/nfs4xdr.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2420,8 +2420,10 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
24202420
__be32 status;
24212421
int err;
24222422
struct nfs4_acl *acl = NULL;
2423+
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
24232424
void *context = NULL;
24242425
int contextlen;
2426+
#endif
24252427
bool contextsupport = false;
24262428
struct nfsd4_compoundres *resp = rqstp->rq_resp;
24272429
u32 minorversion = resp->cstate.minorversion;
@@ -2906,12 +2908,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
29062908
*p++ = cpu_to_be32(NFS4_CHANGE_TYPE_IS_TIME_METADATA);
29072909
}
29082910

2911+
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
29092912
if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
29102913
status = nfsd4_encode_security_label(xdr, rqstp, context,
29112914
contextlen);
29122915
if (status)
29132916
goto out;
29142917
}
2918+
#endif
29152919

29162920
attrlen = htonl(xdr->buf->len - attrlen_offset - 4);
29172921
write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, 4);

0 commit comments

Comments
 (0)