Commit f7a136ae authored by Eric Sandeen's avatar Eric Sandeen Committed by Dave Chinner

xfs: several xattr functions can be void

There are a handful of xattr functions which now return
nothing but zero.  They can be made void, chased through calling
functions, and error handling etc can be removed.
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent c44a1f22
...@@ -77,7 +77,7 @@ int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer, ...@@ -77,7 +77,7 @@ int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
struct xfs_da_args *args); struct xfs_da_args *args);
int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer, int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
struct xfs_da_args *args); struct xfs_da_args *args);
int xfs_attr3_leaf_list_int(struct xfs_buf *bp, void xfs_attr3_leaf_list_int(struct xfs_buf *bp,
struct xfs_attr_list_context *context); struct xfs_attr_list_context *context);
/* /*
......
...@@ -112,8 +112,8 @@ typedef struct attrlist_cursor_kern { ...@@ -112,8 +112,8 @@ typedef struct attrlist_cursor_kern {
*========================================================================*/ *========================================================================*/
/* Return 0 on success, or -errno; other state communicated via *context */ /* void; state communicated via *context */
typedef int (*put_listent_func_t)(struct xfs_attr_list_context *, int, typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int,
unsigned char *, int, int); unsigned char *, int, int);
typedef struct xfs_attr_list_context { typedef struct xfs_attr_list_context {
......
...@@ -74,7 +74,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -74,7 +74,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
xfs_attr_sf_entry_t *sfe; xfs_attr_sf_entry_t *sfe;
xfs_inode_t *dp; xfs_inode_t *dp;
int sbsize, nsbuf, count, i; int sbsize, nsbuf, count, i;
int error;
ASSERT(context != NULL); ASSERT(context != NULL);
dp = context->dp; dp = context->dp;
...@@ -102,13 +101,11 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -102,13 +101,11 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
(XFS_ISRESET_CURSOR(cursor) && (XFS_ISRESET_CURSOR(cursor) &&
(dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) {
for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
error = context->put_listent(context, context->put_listent(context,
sfe->flags, sfe->flags,
sfe->nameval, sfe->nameval,
(int)sfe->namelen, (int)sfe->namelen,
(int)sfe->valuelen); (int)sfe->valuelen);
if (error)
return error;
/* /*
* Either search callback finished early or * Either search callback finished early or
* didn't fit it all in the buffer after all. * didn't fit it all in the buffer after all.
...@@ -193,15 +190,11 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) ...@@ -193,15 +190,11 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
cursor->hashval = sbp->hash; cursor->hashval = sbp->hash;
cursor->offset = 0; cursor->offset = 0;
} }
error = context->put_listent(context, context->put_listent(context,
sbp->flags, sbp->flags,
sbp->name, sbp->name,
sbp->namelen, sbp->namelen,
sbp->valuelen); sbp->valuelen);
if (error) {
kmem_free(sbuf);
return error;
}
if (context->seen_enough) if (context->seen_enough)
break; break;
cursor->offset++; cursor->offset++;
...@@ -335,11 +328,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -335,11 +328,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
*/ */
for (;;) { for (;;) {
leaf = bp->b_addr; leaf = bp->b_addr;
error = xfs_attr3_leaf_list_int(bp, context); xfs_attr3_leaf_list_int(bp, context);
if (error) {
xfs_trans_brelse(NULL, bp);
return error;
}
xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf); xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf);
if (context->seen_enough || leafhdr.forw == 0) if (context->seen_enough || leafhdr.forw == 0)
break; break;
...@@ -356,7 +345,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -356,7 +345,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
/* /*
* Copy out attribute list entries for attr_list(), for leaf attribute lists. * Copy out attribute list entries for attr_list(), for leaf attribute lists.
*/ */
int void
xfs_attr3_leaf_list_int( xfs_attr3_leaf_list_int(
struct xfs_buf *bp, struct xfs_buf *bp,
struct xfs_attr_list_context *context) struct xfs_attr_list_context *context)
...@@ -366,7 +355,6 @@ xfs_attr3_leaf_list_int( ...@@ -366,7 +355,6 @@ xfs_attr3_leaf_list_int(
struct xfs_attr3_icleaf_hdr ichdr; struct xfs_attr3_icleaf_hdr ichdr;
struct xfs_attr_leaf_entry *entries; struct xfs_attr_leaf_entry *entries;
struct xfs_attr_leaf_entry *entry; struct xfs_attr_leaf_entry *entry;
int retval;
int i; int i;
struct xfs_mount *mp = context->dp->i_mount; struct xfs_mount *mp = context->dp->i_mount;
...@@ -399,7 +387,7 @@ xfs_attr3_leaf_list_int( ...@@ -399,7 +387,7 @@ xfs_attr3_leaf_list_int(
} }
if (i == ichdr.count) { if (i == ichdr.count) {
trace_xfs_attr_list_notfound(context); trace_xfs_attr_list_notfound(context);
return 0; return;
} }
} else { } else {
entry = &entries[0]; entry = &entries[0];
...@@ -410,7 +398,6 @@ xfs_attr3_leaf_list_int( ...@@ -410,7 +398,6 @@ xfs_attr3_leaf_list_int(
/* /*
* We have found our place, start copying out the new attributes. * We have found our place, start copying out the new attributes.
*/ */
retval = 0;
for (; i < ichdr.count; entry++, i++) { for (; i < ichdr.count; entry++, i++) {
char *name; char *name;
int namelen, valuelen; int namelen, valuelen;
...@@ -439,16 +426,14 @@ xfs_attr3_leaf_list_int( ...@@ -439,16 +426,14 @@ xfs_attr3_leaf_list_int(
valuelen = be32_to_cpu(name_rmt->valuelen); valuelen = be32_to_cpu(name_rmt->valuelen);
} }
retval = context->put_listent(context, entry->flags, context->put_listent(context, entry->flags,
name, namelen, valuelen); name, namelen, valuelen);
if (retval)
break;
if (context->seen_enough) if (context->seen_enough)
break; break;
cursor->offset++; cursor->offset++;
} }
trace_xfs_attr_list_leaf_end(context); trace_xfs_attr_list_leaf_end(context);
return retval; return;
} }
/* /*
...@@ -467,9 +452,9 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) ...@@ -467,9 +452,9 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
if (error) if (error)
return error; return error;
error = xfs_attr3_leaf_list_int(bp, context); xfs_attr3_leaf_list_int(bp, context);
xfs_trans_brelse(NULL, bp); xfs_trans_brelse(NULL, bp);
return error; return 0;
} }
int int
...@@ -513,7 +498,7 @@ xfs_attr_list_int( ...@@ -513,7 +498,7 @@ xfs_attr_list_int(
* Take care to check values and protect against them changing later, * Take care to check values and protect against them changing later,
* we may be reading them directly out of a user buffer. * we may be reading them directly out of a user buffer.
*/ */
STATIC int STATIC void
xfs_attr_put_listent( xfs_attr_put_listent(
xfs_attr_list_context_t *context, xfs_attr_list_context_t *context,
int flags, int flags,
...@@ -536,10 +521,10 @@ xfs_attr_put_listent( ...@@ -536,10 +521,10 @@ xfs_attr_put_listent(
*/ */
if (((context->flags & ATTR_SECURE) == 0) != if (((context->flags & ATTR_SECURE) == 0) !=
((flags & XFS_ATTR_SECURE) == 0)) ((flags & XFS_ATTR_SECURE) == 0))
return 0; return;
if (((context->flags & ATTR_ROOT) == 0) != if (((context->flags & ATTR_ROOT) == 0) !=
((flags & XFS_ATTR_ROOT) == 0)) ((flags & XFS_ATTR_ROOT) == 0))
return 0; return;
arraytop = sizeof(*alist) + arraytop = sizeof(*alist) +
context->count * sizeof(alist->al_offset[0]); context->count * sizeof(alist->al_offset[0]);
...@@ -548,7 +533,7 @@ xfs_attr_put_listent( ...@@ -548,7 +533,7 @@ xfs_attr_put_listent(
trace_xfs_attr_list_full(context); trace_xfs_attr_list_full(context);
alist->al_more = 1; alist->al_more = 1;
context->seen_enough = 1; context->seen_enough = 1;
return 0; return;
} }
aep = (attrlist_ent_t *)&context->alist[context->firstu]; aep = (attrlist_ent_t *)&context->alist[context->firstu];
...@@ -558,7 +543,7 @@ xfs_attr_put_listent( ...@@ -558,7 +543,7 @@ xfs_attr_put_listent(
alist->al_offset[context->count++] = context->firstu; alist->al_offset[context->count++] = context->firstu;
alist->al_count = context->count; alist->al_count = context->count;
trace_xfs_attr_list_add(context); trace_xfs_attr_list_add(context);
return 0; return;
} }
/* /*
......
...@@ -130,7 +130,7 @@ const struct xattr_handler *xfs_xattr_handlers[] = { ...@@ -130,7 +130,7 @@ const struct xattr_handler *xfs_xattr_handlers[] = {
NULL NULL
}; };
static int static void
__xfs_xattr_put_listent( __xfs_xattr_put_listent(
struct xfs_attr_list_context *context, struct xfs_attr_list_context *context,
char *prefix, char *prefix,
...@@ -148,7 +148,7 @@ __xfs_xattr_put_listent( ...@@ -148,7 +148,7 @@ __xfs_xattr_put_listent(
if (arraytop > context->firstu) { if (arraytop > context->firstu) {
context->count = -1; /* insufficient space */ context->count = -1; /* insufficient space */
context->seen_enough = 1; context->seen_enough = 1;
return 0; return;
} }
offset = (char *)context->alist + context->count; offset = (char *)context->alist + context->count;
strncpy(offset, prefix, prefix_len); strncpy(offset, prefix, prefix_len);
...@@ -159,10 +159,10 @@ __xfs_xattr_put_listent( ...@@ -159,10 +159,10 @@ __xfs_xattr_put_listent(
compute_size: compute_size:
context->count += prefix_len + namelen + 1; context->count += prefix_len + namelen + 1;
return 0; return;
} }
static int static void
xfs_xattr_put_listent( xfs_xattr_put_listent(
struct xfs_attr_list_context *context, struct xfs_attr_list_context *context,
int flags, int flags,
...@@ -180,23 +180,19 @@ xfs_xattr_put_listent( ...@@ -180,23 +180,19 @@ xfs_xattr_put_listent(
if (namelen == SGI_ACL_FILE_SIZE && if (namelen == SGI_ACL_FILE_SIZE &&
strncmp(name, SGI_ACL_FILE, strncmp(name, SGI_ACL_FILE,
SGI_ACL_FILE_SIZE) == 0) { SGI_ACL_FILE_SIZE) == 0) {
int ret = __xfs_xattr_put_listent( __xfs_xattr_put_listent(
context, XATTR_SYSTEM_PREFIX, context, XATTR_SYSTEM_PREFIX,
XATTR_SYSTEM_PREFIX_LEN, XATTR_SYSTEM_PREFIX_LEN,
XATTR_POSIX_ACL_ACCESS, XATTR_POSIX_ACL_ACCESS,
strlen(XATTR_POSIX_ACL_ACCESS)); strlen(XATTR_POSIX_ACL_ACCESS));
if (ret)
return ret;
} else if (namelen == SGI_ACL_DEFAULT_SIZE && } else if (namelen == SGI_ACL_DEFAULT_SIZE &&
strncmp(name, SGI_ACL_DEFAULT, strncmp(name, SGI_ACL_DEFAULT,
SGI_ACL_DEFAULT_SIZE) == 0) { SGI_ACL_DEFAULT_SIZE) == 0) {
int ret = __xfs_xattr_put_listent( __xfs_xattr_put_listent(
context, XATTR_SYSTEM_PREFIX, context, XATTR_SYSTEM_PREFIX,
XATTR_SYSTEM_PREFIX_LEN, XATTR_SYSTEM_PREFIX_LEN,
XATTR_POSIX_ACL_DEFAULT, XATTR_POSIX_ACL_DEFAULT,
strlen(XATTR_POSIX_ACL_DEFAULT)); strlen(XATTR_POSIX_ACL_DEFAULT));
if (ret)
return ret;
} }
#endif #endif
...@@ -205,7 +201,7 @@ xfs_xattr_put_listent( ...@@ -205,7 +201,7 @@ xfs_xattr_put_listent(
* see them. * see them.
*/ */
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return 0; return;
prefix = XATTR_TRUSTED_PREFIX; prefix = XATTR_TRUSTED_PREFIX;
prefix_len = XATTR_TRUSTED_PREFIX_LEN; prefix_len = XATTR_TRUSTED_PREFIX_LEN;
...@@ -217,8 +213,9 @@ xfs_xattr_put_listent( ...@@ -217,8 +213,9 @@ xfs_xattr_put_listent(
prefix_len = XATTR_USER_PREFIX_LEN; prefix_len = XATTR_USER_PREFIX_LEN;
} }
return __xfs_xattr_put_listent(context, prefix, prefix_len, name, __xfs_xattr_put_listent(context, prefix, prefix_len, name,
namelen); namelen);
return;
} }
ssize_t ssize_t
......
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