diff options
author | Eric Sandeen <sandeen@redhat.com> | 2016-12-04 20:32:14 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-12-04 20:32:14 -0500 |
commit | f7a136aee3c1c3f7daf87197b3b3c361744a2812 (patch) | |
tree | 1f70a45137c8591b25b589f7f5f681adff59c341 | |
parent | c44a1f22626c153976289e1cd67bdcdfefc16e1f (diff) |
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: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r-- | fs/xfs/libxfs/xfs_attr_leaf.h | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_attr.h | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_attr_list.c | 59 | ||||
-rw-r--r-- | fs/xfs/xfs_xattr.c | 23 |
4 files changed, 35 insertions, 53 deletions
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h index 4f2aed04f827..91f51637f8af 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.h +++ b/fs/xfs/libxfs/xfs_attr_leaf.h | |||
@@ -77,7 +77,7 @@ int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer, | |||
77 | struct xfs_da_args *args); | 77 | struct xfs_da_args *args); |
78 | int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer, | 78 | int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer, |
79 | struct xfs_da_args *args); | 79 | struct xfs_da_args *args); |
80 | int xfs_attr3_leaf_list_int(struct xfs_buf *bp, | 80 | void xfs_attr3_leaf_list_int(struct xfs_buf *bp, |
81 | struct xfs_attr_list_context *context); | 81 | struct xfs_attr_list_context *context); |
82 | 82 | ||
83 | /* | 83 | /* |
diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h index e3da5d448bcf..d14691aa02b4 100644 --- a/fs/xfs/xfs_attr.h +++ b/fs/xfs/xfs_attr.h | |||
@@ -112,8 +112,8 @@ typedef struct attrlist_cursor_kern { | |||
112 | *========================================================================*/ | 112 | *========================================================================*/ |
113 | 113 | ||
114 | 114 | ||
115 | /* Return 0 on success, or -errno; other state communicated via *context */ | 115 | /* void; state communicated via *context */ |
116 | typedef int (*put_listent_func_t)(struct xfs_attr_list_context *, int, | 116 | typedef void (*put_listent_func_t)(struct xfs_attr_list_context *, int, |
117 | unsigned char *, int, int); | 117 | unsigned char *, int, int); |
118 | 118 | ||
119 | typedef struct xfs_attr_list_context { | 119 | typedef struct xfs_attr_list_context { |
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 25e76cd6c053..97c45b6eb91e 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c | |||
@@ -74,7 +74,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
74 | xfs_attr_sf_entry_t *sfe; | 74 | xfs_attr_sf_entry_t *sfe; |
75 | xfs_inode_t *dp; | 75 | xfs_inode_t *dp; |
76 | int sbsize, nsbuf, count, i; | 76 | int sbsize, nsbuf, count, i; |
77 | int error; | ||
78 | 77 | ||
79 | ASSERT(context != NULL); | 78 | ASSERT(context != NULL); |
80 | dp = context->dp; | 79 | dp = context->dp; |
@@ -102,13 +101,11 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context) | |||
102 | (XFS_ISRESET_CURSOR(cursor) && | 101 | (XFS_ISRESET_CURSOR(cursor) && |
103 | (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { | 102 | (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { |
104 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { | 103 | for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { |
105 | error = context->put_listent(context, | 104 | context->put_listent(context, |
106 | sfe->flags, | 105 | sfe->flags, |
107 | sfe->nameval, | 106 | sfe->nameval, |
108 | (int)sfe->namelen, | 107 | (int)sfe->namelen, |
109 | (int)sfe->valuelen); | 108 | (int)sfe->valuelen); |
110 | if (error) | ||
111 | return error; | ||
112 | /* | 109 | /* |
113 | * Either search callback finished early or | 110 | * Either search callback finished early or |
114 | * didn't fit it all in the buffer after all. | 111 | * 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 | cursor->hashval = sbp->hash; | 190 | cursor->hashval = sbp->hash; |
194 | cursor->offset = 0; | 191 | cursor->offset = 0; |
195 | } | 192 | } |
196 | error = context->put_listent(context, | 193 | context->put_listent(context, |
197 | sbp->flags, | 194 | sbp->flags, |
198 | sbp->name, | 195 | sbp->name, |
199 | sbp->namelen, | 196 | sbp->namelen, |
200 | sbp->valuelen); | 197 | sbp->valuelen); |
201 | if (error) { | ||
202 | kmem_free(sbuf); | ||
203 | return error; | ||
204 | } | ||
205 | if (context->seen_enough) | 198 | if (context->seen_enough) |
206 | break; | 199 | break; |
207 | cursor->offset++; | 200 | cursor->offset++; |
@@ -335,11 +328,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
335 | */ | 328 | */ |
336 | for (;;) { | 329 | for (;;) { |
337 | leaf = bp->b_addr; | 330 | leaf = bp->b_addr; |
338 | error = xfs_attr3_leaf_list_int(bp, context); | 331 | xfs_attr3_leaf_list_int(bp, context); |
339 | if (error) { | ||
340 | xfs_trans_brelse(NULL, bp); | ||
341 | return error; | ||
342 | } | ||
343 | xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf); | 332 | xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf); |
344 | if (context->seen_enough || leafhdr.forw == 0) | 333 | if (context->seen_enough || leafhdr.forw == 0) |
345 | break; | 334 | break; |
@@ -356,7 +345,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
356 | /* | 345 | /* |
357 | * Copy out attribute list entries for attr_list(), for leaf attribute lists. | 346 | * Copy out attribute list entries for attr_list(), for leaf attribute lists. |
358 | */ | 347 | */ |
359 | int | 348 | void |
360 | xfs_attr3_leaf_list_int( | 349 | xfs_attr3_leaf_list_int( |
361 | struct xfs_buf *bp, | 350 | struct xfs_buf *bp, |
362 | struct xfs_attr_list_context *context) | 351 | struct xfs_attr_list_context *context) |
@@ -366,7 +355,6 @@ xfs_attr3_leaf_list_int( | |||
366 | struct xfs_attr3_icleaf_hdr ichdr; | 355 | struct xfs_attr3_icleaf_hdr ichdr; |
367 | struct xfs_attr_leaf_entry *entries; | 356 | struct xfs_attr_leaf_entry *entries; |
368 | struct xfs_attr_leaf_entry *entry; | 357 | struct xfs_attr_leaf_entry *entry; |
369 | int retval; | ||
370 | int i; | 358 | int i; |
371 | struct xfs_mount *mp = context->dp->i_mount; | 359 | struct xfs_mount *mp = context->dp->i_mount; |
372 | 360 | ||
@@ -399,7 +387,7 @@ xfs_attr3_leaf_list_int( | |||
399 | } | 387 | } |
400 | if (i == ichdr.count) { | 388 | if (i == ichdr.count) { |
401 | trace_xfs_attr_list_notfound(context); | 389 | trace_xfs_attr_list_notfound(context); |
402 | return 0; | 390 | return; |
403 | } | 391 | } |
404 | } else { | 392 | } else { |
405 | entry = &entries[0]; | 393 | entry = &entries[0]; |
@@ -410,7 +398,6 @@ xfs_attr3_leaf_list_int( | |||
410 | /* | 398 | /* |
411 | * We have found our place, start copying out the new attributes. | 399 | * We have found our place, start copying out the new attributes. |
412 | */ | 400 | */ |
413 | retval = 0; | ||
414 | for (; i < ichdr.count; entry++, i++) { | 401 | for (; i < ichdr.count; entry++, i++) { |
415 | char *name; | 402 | char *name; |
416 | int namelen, valuelen; | 403 | int namelen, valuelen; |
@@ -439,16 +426,14 @@ xfs_attr3_leaf_list_int( | |||
439 | valuelen = be32_to_cpu(name_rmt->valuelen); | 426 | valuelen = be32_to_cpu(name_rmt->valuelen); |
440 | } | 427 | } |
441 | 428 | ||
442 | retval = context->put_listent(context, entry->flags, | 429 | context->put_listent(context, entry->flags, |
443 | name, namelen, valuelen); | 430 | name, namelen, valuelen); |
444 | if (retval) | ||
445 | break; | ||
446 | if (context->seen_enough) | 431 | if (context->seen_enough) |
447 | break; | 432 | break; |
448 | cursor->offset++; | 433 | cursor->offset++; |
449 | } | 434 | } |
450 | trace_xfs_attr_list_leaf_end(context); | 435 | trace_xfs_attr_list_leaf_end(context); |
451 | return retval; | 436 | return; |
452 | } | 437 | } |
453 | 438 | ||
454 | /* | 439 | /* |
@@ -467,9 +452,9 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) | |||
467 | if (error) | 452 | if (error) |
468 | return error; | 453 | return error; |
469 | 454 | ||
470 | error = xfs_attr3_leaf_list_int(bp, context); | 455 | xfs_attr3_leaf_list_int(bp, context); |
471 | xfs_trans_brelse(NULL, bp); | 456 | xfs_trans_brelse(NULL, bp); |
472 | return error; | 457 | return 0; |
473 | } | 458 | } |
474 | 459 | ||
475 | int | 460 | int |
@@ -513,7 +498,7 @@ xfs_attr_list_int( | |||
513 | * Take care to check values and protect against them changing later, | 498 | * Take care to check values and protect against them changing later, |
514 | * we may be reading them directly out of a user buffer. | 499 | * we may be reading them directly out of a user buffer. |
515 | */ | 500 | */ |
516 | STATIC int | 501 | STATIC void |
517 | xfs_attr_put_listent( | 502 | xfs_attr_put_listent( |
518 | xfs_attr_list_context_t *context, | 503 | xfs_attr_list_context_t *context, |
519 | int flags, | 504 | int flags, |
@@ -536,10 +521,10 @@ xfs_attr_put_listent( | |||
536 | */ | 521 | */ |
537 | if (((context->flags & ATTR_SECURE) == 0) != | 522 | if (((context->flags & ATTR_SECURE) == 0) != |
538 | ((flags & XFS_ATTR_SECURE) == 0)) | 523 | ((flags & XFS_ATTR_SECURE) == 0)) |
539 | return 0; | 524 | return; |
540 | if (((context->flags & ATTR_ROOT) == 0) != | 525 | if (((context->flags & ATTR_ROOT) == 0) != |
541 | ((flags & XFS_ATTR_ROOT) == 0)) | 526 | ((flags & XFS_ATTR_ROOT) == 0)) |
542 | return 0; | 527 | return; |
543 | 528 | ||
544 | arraytop = sizeof(*alist) + | 529 | arraytop = sizeof(*alist) + |
545 | context->count * sizeof(alist->al_offset[0]); | 530 | context->count * sizeof(alist->al_offset[0]); |
@@ -548,7 +533,7 @@ xfs_attr_put_listent( | |||
548 | trace_xfs_attr_list_full(context); | 533 | trace_xfs_attr_list_full(context); |
549 | alist->al_more = 1; | 534 | alist->al_more = 1; |
550 | context->seen_enough = 1; | 535 | context->seen_enough = 1; |
551 | return 0; | 536 | return; |
552 | } | 537 | } |
553 | 538 | ||
554 | aep = (attrlist_ent_t *)&context->alist[context->firstu]; | 539 | aep = (attrlist_ent_t *)&context->alist[context->firstu]; |
@@ -558,7 +543,7 @@ xfs_attr_put_listent( | |||
558 | alist->al_offset[context->count++] = context->firstu; | 543 | alist->al_offset[context->count++] = context->firstu; |
559 | alist->al_count = context->count; | 544 | alist->al_count = context->count; |
560 | trace_xfs_attr_list_add(context); | 545 | trace_xfs_attr_list_add(context); |
561 | return 0; | 546 | return; |
562 | } | 547 | } |
563 | 548 | ||
564 | /* | 549 | /* |
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 62900938f26d..0594db435972 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c | |||
@@ -130,7 +130,7 @@ const struct xattr_handler *xfs_xattr_handlers[] = { | |||
130 | NULL | 130 | NULL |
131 | }; | 131 | }; |
132 | 132 | ||
133 | static int | 133 | static void |
134 | __xfs_xattr_put_listent( | 134 | __xfs_xattr_put_listent( |
135 | struct xfs_attr_list_context *context, | 135 | struct xfs_attr_list_context *context, |
136 | char *prefix, | 136 | char *prefix, |
@@ -148,7 +148,7 @@ __xfs_xattr_put_listent( | |||
148 | if (arraytop > context->firstu) { | 148 | if (arraytop > context->firstu) { |
149 | context->count = -1; /* insufficient space */ | 149 | context->count = -1; /* insufficient space */ |
150 | context->seen_enough = 1; | 150 | context->seen_enough = 1; |
151 | return 0; | 151 | return; |
152 | } | 152 | } |
153 | offset = (char *)context->alist + context->count; | 153 | offset = (char *)context->alist + context->count; |
154 | strncpy(offset, prefix, prefix_len); | 154 | strncpy(offset, prefix, prefix_len); |
@@ -159,10 +159,10 @@ __xfs_xattr_put_listent( | |||
159 | 159 | ||
160 | compute_size: | 160 | compute_size: |
161 | context->count += prefix_len + namelen + 1; | 161 | context->count += prefix_len + namelen + 1; |
162 | return 0; | 162 | return; |
163 | } | 163 | } |
164 | 164 | ||
165 | static int | 165 | static void |
166 | xfs_xattr_put_listent( | 166 | xfs_xattr_put_listent( |
167 | struct xfs_attr_list_context *context, | 167 | struct xfs_attr_list_context *context, |
168 | int flags, | 168 | int flags, |
@@ -180,23 +180,19 @@ xfs_xattr_put_listent( | |||
180 | if (namelen == SGI_ACL_FILE_SIZE && | 180 | if (namelen == SGI_ACL_FILE_SIZE && |
181 | strncmp(name, SGI_ACL_FILE, | 181 | strncmp(name, SGI_ACL_FILE, |
182 | SGI_ACL_FILE_SIZE) == 0) { | 182 | SGI_ACL_FILE_SIZE) == 0) { |
183 | int ret = __xfs_xattr_put_listent( | 183 | __xfs_xattr_put_listent( |
184 | context, XATTR_SYSTEM_PREFIX, | 184 | context, XATTR_SYSTEM_PREFIX, |
185 | XATTR_SYSTEM_PREFIX_LEN, | 185 | XATTR_SYSTEM_PREFIX_LEN, |
186 | XATTR_POSIX_ACL_ACCESS, | 186 | XATTR_POSIX_ACL_ACCESS, |
187 | strlen(XATTR_POSIX_ACL_ACCESS)); | 187 | strlen(XATTR_POSIX_ACL_ACCESS)); |
188 | if (ret) | ||
189 | return ret; | ||
190 | } else if (namelen == SGI_ACL_DEFAULT_SIZE && | 188 | } else if (namelen == SGI_ACL_DEFAULT_SIZE && |
191 | strncmp(name, SGI_ACL_DEFAULT, | 189 | strncmp(name, SGI_ACL_DEFAULT, |
192 | SGI_ACL_DEFAULT_SIZE) == 0) { | 190 | SGI_ACL_DEFAULT_SIZE) == 0) { |
193 | int ret = __xfs_xattr_put_listent( | 191 | __xfs_xattr_put_listent( |
194 | context, XATTR_SYSTEM_PREFIX, | 192 | context, XATTR_SYSTEM_PREFIX, |
195 | XATTR_SYSTEM_PREFIX_LEN, | 193 | XATTR_SYSTEM_PREFIX_LEN, |
196 | XATTR_POSIX_ACL_DEFAULT, | 194 | XATTR_POSIX_ACL_DEFAULT, |
197 | strlen(XATTR_POSIX_ACL_DEFAULT)); | 195 | strlen(XATTR_POSIX_ACL_DEFAULT)); |
198 | if (ret) | ||
199 | return ret; | ||
200 | } | 196 | } |
201 | #endif | 197 | #endif |
202 | 198 | ||
@@ -205,7 +201,7 @@ xfs_xattr_put_listent( | |||
205 | * see them. | 201 | * see them. |
206 | */ | 202 | */ |
207 | if (!capable(CAP_SYS_ADMIN)) | 203 | if (!capable(CAP_SYS_ADMIN)) |
208 | return 0; | 204 | return; |
209 | 205 | ||
210 | prefix = XATTR_TRUSTED_PREFIX; | 206 | prefix = XATTR_TRUSTED_PREFIX; |
211 | prefix_len = XATTR_TRUSTED_PREFIX_LEN; | 207 | prefix_len = XATTR_TRUSTED_PREFIX_LEN; |
@@ -217,8 +213,9 @@ xfs_xattr_put_listent( | |||
217 | prefix_len = XATTR_USER_PREFIX_LEN; | 213 | prefix_len = XATTR_USER_PREFIX_LEN; |
218 | } | 214 | } |
219 | 215 | ||
220 | return __xfs_xattr_put_listent(context, prefix, prefix_len, name, | 216 | __xfs_xattr_put_listent(context, prefix, prefix_len, name, |
221 | namelen); | 217 | namelen); |
218 | return; | ||
222 | } | 219 | } |
223 | 220 | ||
224 | ssize_t | 221 | ssize_t |