Commit cde2c5bc authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: nfsd4: encode_dirent: simplify control flow

Replace series of if's by a switch, remove (now unnecessary) label "out".
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bdc337cc
......@@ -1854,32 +1854,31 @@ nfsd4_encode_dirent(struct readdir_cd *ccd, const char *name, int namlen,
* Now we come to the ugly part: writing the fattr for this entry.
*/
nfserr = nfsd4_encode_dirent_fattr(cd, name, namlen, p, &buflen);
if (!nfserr) {
switch (nfserr) {
case nfs_ok:
p += buflen;
goto out;
}
if (nfserr == nfserr_resource) {
break;
case nfserr_resource:
nfserr = nfserr_toosmall;
goto fail;
default:
/*
* If we get here, we experienced a miscellaneous
* failure while writing the attributes. If the
* client requested the RDATTR_ERROR attribute,
* we stuff the error code into this attribute
* and continue. If this attribute was not requested,
* then in accordance with the spec, we fail the
* entire READDIR operation(!)
*/
if (!(cd->rd_bmval[0] & FATTR4_WORD0_RDATTR_ERROR))
goto fail;
nfserr = nfserr_toosmall;
p = nfsd4_encode_rdattr_error(p, buflen, nfserr);
if (p == NULL)
goto fail;
}
/*
* If we get here, we experienced a miscellaneous
* failure while writing the attributes. If the
* client requested the RDATTR_ERROR attribute,
* we stuff the error code into this attribute
* and continue. If this attribute was not requested,
* then in accordance with the spec, we fail the
* entire READDIR operation(!)
*/
if (!(cd->rd_bmval[0] & FATTR4_WORD0_RDATTR_ERROR))
goto fail;
nfserr = nfserr_toosmall;
p = nfsd4_encode_rdattr_error(p, buflen, nfserr);
if (p == NULL)
goto fail;
out:
cd->buflen -= (p - cd->buffer);
cd->buffer = p;
cd->common.err = nfs_ok;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment