[PATCH V3 1/7] security_dac: annotate some functions with ATTRIBUTE_NONNULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Annotate some static function parameters with ATTRIBUTE_NONNULL
and remove checks for NULL inputs.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/security/security_dac.c | 34 ++++++++++------------------------
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index ed79857..19742ed 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -81,10 +81,9 @@ virSecurityDACSetDynamicOwnership(virSecurityManagerPtr mgr,
 
 /* returns 1 if label isn't found, 0 on success, -1 on error */
 static int
+ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
 virSecurityDACParseIds(virDomainDefPtr def, uid_t *uidPtr, gid_t *gidPtr)
 {
-    uid_t uid;
-    gid_t gid;
     virSecurityLabelDefPtr seclabel;
 
     if (def == NULL)
@@ -96,18 +95,14 @@ virSecurityDACParseIds(virDomainDefPtr def, uid_t *uidPtr, gid_t *gidPtr)
         return 1;
     }
 
-    if (virParseOwnershipIds(seclabel->label, &uid, &gid) < 0)
+    if (virParseOwnershipIds(seclabel->label, uidPtr, gidPtr) < 0)
         return -1;
 
-    if (uidPtr)
-        *uidPtr = uid;
-    if (gidPtr)
-        *gidPtr = gid;
-
     return 0;
 }
 
 static int
+ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
 virSecurityDACGetIds(virDomainDefPtr def, virSecurityDACDataPtr priv,
                      uid_t *uidPtr, gid_t *gidPtr,
                      gid_t **groups, int *ngroups)
@@ -136,10 +131,8 @@ virSecurityDACGetIds(virDomainDefPtr def, virSecurityDACDataPtr priv,
         return -1;
     }
 
-    if (uidPtr)
-        *uidPtr = priv->user;
-    if (gidPtr)
-        *gidPtr = priv->group;
+    *uidPtr = priv->user;
+    *gidPtr = priv->group;
 
     return 0;
 }
@@ -147,11 +140,10 @@ virSecurityDACGetIds(virDomainDefPtr def, virSecurityDACDataPtr priv,
 
 /* returns 1 if label isn't found, 0 on success, -1 on error */
 static int
+ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
 virSecurityDACParseImageIds(virDomainDefPtr def,
                             uid_t *uidPtr, gid_t *gidPtr)
 {
-    uid_t uid;
-    gid_t gid;
     virSecurityLabelDefPtr seclabel;
 
     if (def == NULL)
@@ -163,18 +155,14 @@ virSecurityDACParseImageIds(virDomainDefPtr def,
         return 1;
     }
 
-    if (virParseOwnershipIds(seclabel->imagelabel, &uid, &gid) < 0)
+    if (virParseOwnershipIds(seclabel->imagelabel, uidPtr, gidPtr) < 0)
         return -1;
 
-    if (uidPtr)
-        *uidPtr = uid;
-    if (gidPtr)
-        *gidPtr = gid;
-
     return 0;
 }
 
 static int
+ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
 virSecurityDACGetImageIds(virDomainDefPtr def, virSecurityDACDataPtr priv,
                           uid_t *uidPtr, gid_t *gidPtr)
 {
@@ -197,10 +185,8 @@ virSecurityDACGetImageIds(virDomainDefPtr def, virSecurityDACDataPtr priv,
         return -1;
     }
 
-    if (uidPtr)
-        *uidPtr = priv->user;
-    if (gidPtr)
-        *gidPtr = priv->group;
+    *uidPtr = priv->user;
+    *gidPtr = priv->group;
 
     return 0;
 }
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]