From 307713b0cf837122c02128382f81fbe757863cb1 Mon Sep 17 00:00:00 2001 From: trasz Date: Thu, 3 Jun 2010 14:29:17 +0000 Subject: _posix1e_acl_sort() never returns anything other than 0; change its return type to void and update callers. This simplifies code and fixes one place where the returned value was not actually checked. Found with: Coverity Prevent CID: 4791 --- lib/libc/posix1e/acl_set.c | 30 ++++++------------------------ lib/libc/posix1e/acl_support.c | 8 ++------ lib/libc/posix1e/acl_support.h | 2 +- lib/libc/posix1e/acl_valid.c | 30 ++++++------------------------ 4 files changed, 15 insertions(+), 55 deletions(-) (limited to 'lib/libc/posix1e') diff --git a/lib/libc/posix1e/acl_set.c b/lib/libc/posix1e/acl_set.c index f9ee76d..fdc12b6 100644 --- a/lib/libc/posix1e/acl_set.c +++ b/lib/libc/posix1e/acl_set.c @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); int acl_set_file(const char *path_p, acl_type_t type, acl_t acl) { - int error; if (acl == NULL || path_p == NULL) { errno = EINVAL; @@ -64,13 +63,8 @@ acl_set_file(const char *path_p, acl_type_t type, acl_t acl) errno = EINVAL; return (-1); } - if (_posix1e_acl(acl, type)) { - error = _posix1e_acl_sort(acl); - if (error) { - errno = error; - return (-1); - } - } + if (_posix1e_acl(acl, type)) + _posix1e_acl_sort(acl); acl->ats_cur_entry = 0; @@ -80,7 +74,6 @@ acl_set_file(const char *path_p, acl_type_t type, acl_t acl) int acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl) { - int error; if (acl == NULL || path_p == NULL) { errno = EINVAL; @@ -91,13 +84,8 @@ acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl) errno = EINVAL; return (-1); } - if (_posix1e_acl(acl, type)) { - error = _posix1e_acl_sort(acl); - if (error) { - errno = error; - return (-1); - } - } + if (_posix1e_acl(acl, type)) + _posix1e_acl_sort(acl); acl->ats_cur_entry = 0; @@ -117,7 +105,6 @@ acl_set_fd(int fd, acl_t acl) int acl_set_fd_np(int fd, acl_t acl, acl_type_t type) { - int error; if (acl == NULL) { errno = EINVAL; @@ -128,13 +115,8 @@ acl_set_fd_np(int fd, acl_t acl, acl_type_t type) errno = EINVAL; return (-1); } - if (_posix1e_acl(acl, type)) { - error = _posix1e_acl_sort(acl); - if (error) { - errno = error; - return (-1); - } - } + if (_posix1e_acl(acl, type)) + _posix1e_acl_sort(acl); acl->ats_cur_entry = 0; diff --git a/lib/libc/posix1e/acl_support.c b/lib/libc/posix1e/acl_support.c index 680debc..afbe7de 100644 --- a/lib/libc/posix1e/acl_support.c +++ b/lib/libc/posix1e/acl_support.c @@ -127,11 +127,9 @@ _posix1e_acl_entry_compare(struct acl_entry *a, struct acl_entry *b) } /* - * _posix1e_acl_sort -- sort ACL entries in POSIX.1e-formatted ACLs - * Give the opportunity to fail, although we don't currently have a way - * to fail. + * _posix1e_acl_sort -- sort ACL entries in POSIX.1e-formatted ACLs. */ -int +void _posix1e_acl_sort(acl_t acl) { struct acl *acl_int; @@ -140,8 +138,6 @@ _posix1e_acl_sort(acl_t acl) qsort(&acl_int->acl_entry[0], acl_int->acl_cnt, sizeof(struct acl_entry), (compare) _posix1e_acl_entry_compare); - - return (0); } /* diff --git a/lib/libc/posix1e/acl_support.h b/lib/libc/posix1e/acl_support.h index 9826577..8f7dfed 100644 --- a/lib/libc/posix1e/acl_support.h +++ b/lib/libc/posix1e/acl_support.h @@ -50,7 +50,7 @@ int _nfs4_format_access_mask(char *str, size_t size, acl_perm_t var, int verbose int _nfs4_parse_flags(const char *str, acl_flag_t *var); int _nfs4_parse_access_mask(const char *str, acl_perm_t *var); int _posix1e_acl_check(acl_t acl); -int _posix1e_acl_sort(acl_t acl); +void _posix1e_acl_sort(acl_t acl); int _posix1e_acl(acl_t acl, acl_type_t type); int _posix1e_acl_id_to_name(acl_tag_t tag, uid_t id, ssize_t buf_len, char *buf, int flags); diff --git a/lib/libc/posix1e/acl_valid.c b/lib/libc/posix1e/acl_valid.c index f345c01..d4cb872 100644 --- a/lib/libc/posix1e/acl_valid.c +++ b/lib/libc/posix1e/acl_valid.c @@ -79,20 +79,14 @@ acl_valid(acl_t acl) int acl_valid_file_np(const char *pathp, acl_type_t type, acl_t acl) { - int error; if (pathp == NULL || acl == NULL) { errno = EINVAL; return (-1); } type = _acl_type_unold(type); - if (_posix1e_acl(acl, type)) { - error = _posix1e_acl_sort(acl); - if (error) { - errno = error; - return (-1); - } - } + if (_posix1e_acl(acl, type)) + _posix1e_acl_sort(acl); return (__acl_aclcheck_file(pathp, type, &acl->ats_acl)); } @@ -100,20 +94,14 @@ acl_valid_file_np(const char *pathp, acl_type_t type, acl_t acl) int acl_valid_link_np(const char *pathp, acl_type_t type, acl_t acl) { - int error; if (pathp == NULL || acl == NULL) { errno = EINVAL; return (-1); } type = _acl_type_unold(type); - if (_posix1e_acl(acl, type)) { - error = _posix1e_acl_sort(acl); - if (error) { - errno = error; - return (-1); - } - } + if (_posix1e_acl(acl, type)) + _posix1e_acl_sort(acl); return (__acl_aclcheck_link(pathp, type, &acl->ats_acl)); } @@ -121,20 +109,14 @@ acl_valid_link_np(const char *pathp, acl_type_t type, acl_t acl) int acl_valid_fd_np(int fd, acl_type_t type, acl_t acl) { - int error; if (acl == NULL) { errno = EINVAL; return (-1); } type = _acl_type_unold(type); - if (_posix1e_acl(acl, type)) { - error = _posix1e_acl_sort(acl); - if (error) { - errno = error; - return (-1); - } - } + if (_posix1e_acl(acl, type)) + _posix1e_acl_sort(acl); acl->ats_cur_entry = 0; -- cgit v1.1