Commit 731f3f482ad3b2c58a1af2d0a9a634a82803706a

Authored by Chuck Lever
Committed by Trond Myklebust
1 parent ee5dc7732b

NFS: nfsacl_{encode,decode} should return signed integer

Clean up.

The nfsacl_encode() and nfsacl_decode() functions return negative
errno values, and each call site verifies that the returned value
is not negative.  Change the synopsis of both of these functions
to reflect this usage.

Document the synopsis and return values.

Reported-by: Trond Myklebust <trond.myklebust@netapp.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 2 changed files with 28 additions and 8 deletions Side-by-side Diff

fs/nfs_common/nfsacl.c
... ... @@ -72,9 +72,20 @@
72 72 return 0;
73 73 }
74 74  
75   -unsigned int
76   -nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
77   - struct posix_acl *acl, int encode_entries, int typeflag)
  75 +/**
  76 + * nfsacl_encode - Encode an NFSv3 ACL
  77 + *
  78 + * @buf: destination xdr_buf to contain XDR encoded ACL
  79 + * @base: byte offset in xdr_buf where XDR'd ACL begins
  80 + * @inode: inode of file whose ACL this is
  81 + * @acl: posix_acl to encode
  82 + * @encode_entries: whether to encode ACEs as well
  83 + * @typeflag: ACL type: NFS_ACL_DEFAULT or zero
  84 + *
  85 + * Returns size of encoded ACL in bytes or a negative errno value.
  86 + */
  87 +int nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
  88 + struct posix_acl *acl, int encode_entries, int typeflag)
78 89 {
79 90 int entries = (acl && acl->a_count) ? max_t(int, acl->a_count, 4) : 0;
80 91 struct nfsacl_encode_desc nfsacl_desc = {
... ... @@ -224,9 +235,18 @@
224 235 return 0;
225 236 }
226 237  
227   -unsigned int
228   -nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
229   - struct posix_acl **pacl)
  238 +/**
  239 + * nfsacl_decode - Decode an NFSv3 ACL
  240 + *
  241 + * @buf: xdr_buf containing XDR'd ACL data to decode
  242 + * @base: byte offset in xdr_buf where XDR'd ACL begins
  243 + * @aclcnt: count of ACEs in decoded posix_acl
  244 + * @pacl: buffer in which to place decoded posix_acl
  245 + *
  246 + * Returns the length of the decoded ACL in bytes, or a negative errno value.
  247 + */
  248 +int nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
  249 + struct posix_acl **pacl)
230 250 {
231 251 struct nfsacl_decode_desc nfsacl_desc = {
232 252 .desc = {
include/linux/nfsacl.h
... ... @@ -51,10 +51,10 @@
51 51 return w;
52 52 }
53 53  
54   -extern unsigned int
  54 +extern int
55 55 nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode,
56 56 struct posix_acl *acl, int encode_entries, int typeflag);
57   -extern unsigned int
  57 +extern int
58 58 nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt,
59 59 struct posix_acl **pacl);
60 60