Author: trasz
Date: Thu Jun  3 14:29:17 2010
New Revision: 208785
URL: http://svn.freebsd.org/changeset/base/208785

Log:
  _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

Modified:
  head/lib/libc/posix1e/acl_set.c
  head/lib/libc/posix1e/acl_support.c
  head/lib/libc/posix1e/acl_support.h
  head/lib/libc/posix1e/acl_valid.c

Modified: head/lib/libc/posix1e/acl_set.c
==============================================================================
--- head/lib/libc/posix1e/acl_set.c     Thu Jun  3 14:27:18 2010        
(r208784)
+++ head/lib/libc/posix1e/acl_set.c     Thu Jun  3 14:29:17 2010        
(r208785)
@@ -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_typ
                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_typ
 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_
                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_typ
                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;
 

Modified: head/lib/libc/posix1e/acl_support.c
==============================================================================
--- head/lib/libc/posix1e/acl_support.c Thu Jun  3 14:27:18 2010        
(r208784)
+++ head/lib/libc/posix1e/acl_support.c Thu Jun  3 14:29:17 2010        
(r208785)
@@ -127,11 +127,9 @@ _posix1e_acl_entry_compare(struct acl_en
 }
 
 /*
- * _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);
 }
 
 /*

Modified: head/lib/libc/posix1e/acl_support.h
==============================================================================
--- head/lib/libc/posix1e/acl_support.h Thu Jun  3 14:27:18 2010        
(r208784)
+++ head/lib/libc/posix1e/acl_support.h Thu Jun  3 14:29:17 2010        
(r208785)
@@ -50,7 +50,7 @@ int   _nfs4_format_access_mask(char *str, 
 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);

Modified: head/lib/libc/posix1e/acl_valid.c
==============================================================================
--- head/lib/libc/posix1e/acl_valid.c   Thu Jun  3 14:27:18 2010        
(r208784)
+++ head/lib/libc/posix1e/acl_valid.c   Thu Jun  3 14:29:17 2010        
(r208785)
@@ -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
 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
 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;
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to