Minor cleanups to sepolLoadPolicies() in sepolicy plugin
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 30 May 2011 09:12:24 +0000 (12:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 30 May 2011 09:12:24 +0000 (12:12 +0300)
- Having an err label which we fall through on success too seems
  a bit funny, rename the label to exit
- Initialize the sepoltrans at declaration already
- Remove redundant RPMRC_FAIL assignment on sepoltransNew() fail
  case, this already assumes failure
- Remove redundant jump to exit from sepoltransCommit() error
- Eliminate trailing dead NULL assignment of the local pt variable

plugins/sepolicy.c

index b4fa910..a0a9ccc 100644 (file)
@@ -251,14 +251,11 @@ static rpmRC sepolWritePolicy(const sepol * pol, char **path)
 static rpmRC sepolLoadPolicies(const sepol * pols)
 {
     const sepol *pol;
-    sepoltrans *pt;
     rpmRC rc = RPMRC_FAIL;
+    sepoltrans *pt = sepoltransNew();
 
-    pt = sepoltransNew();
-    if (!pt) {
-       rc = RPMRC_FAIL;
-       goto err;
-    }
+    if (pt == NULL)
+       goto exit;
 
     for (pol = pols; pol; pol = pol->next) {
        switch (pol->action) {
@@ -274,18 +271,14 @@ static rpmRC sepolLoadPolicies(const sepol * pols)
            break;
        }
 
-       if (rc != RPMRC_OK) {
-           goto err;
-       }
+       if (rc != RPMRC_OK)
+           goto exit;
     }
 
     rc = sepoltransCommit(pt);
-    if (rc != RPMRC_OK) {
-       goto err;
-    }
 
-  err:
-    pt = sepoltransFree(pt);
+exit:
+    sepoltransFree(pt);
 
     return rc;
 }