[PATCH 22/75] security: Drop virAsprintf() and virAsprintfQuiet() retval checking

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

 



These functions can't fail really. Drop checking of their retval
then.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/security/security_apparmor.c | 38 +++++-----------
 src/security/security_dac.c      | 30 +++++--------
 src/security/security_selinux.c  | 55 +++++++++---------------
 src/security/security_util.c     | 14 +++---
 src/security/virt-aa-helper.c    | 74 ++++++++------------------------
 5 files changed, 64 insertions(+), 147 deletions(-)

diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c
index 9ad218b383..7263c2face 100644
--- a/src/security/security_apparmor.c
+++ b/src/security/security_apparmor.c
@@ -76,15 +76,11 @@ profile_status(const char *str, const int check_enforcing)
     int rc = -2;
 
     /* create string that is '<str> \0' for accurate matching */
-    if (virAsprintf(&tmp, "%s ", str) == -1)
-        return rc;
+    virAsprintf(&tmp, "%s ", str);
 
     if (check_enforcing != 0) {
         /* create string that is '<str> (enforce)\0' for accurate matching */
-        if (virAsprintf(&etmp, "%s (enforce)", str) == -1) {
-            VIR_FREE(tmp);
-            return rc;
-        }
+        virAsprintf(&etmp, "%s (enforce)", str);
     }
 
     if (virFileReadAll(APPARMOR_PROFILES_PATH, MAX_FILE_LEN, &content) < 0) {
@@ -130,8 +126,7 @@ profile_status_file(const char *str)
     int rc = -1;
     int len;
 
-    if (virAsprintf(&profile, "%s/%s", APPARMOR_DIR "/libvirt", str) == -1)
-        return rc;
+    virAsprintf(&profile, "%s/%s", APPARMOR_DIR "/libvirt", str);
 
     if (!virFileExists(profile))
         goto failed;
@@ -143,8 +138,7 @@ profile_status_file(const char *str)
     }
 
     /* create string that is ' <str> flags=(complain)\0' */
-    if (virAsprintf(&tmp, " %s flags=(complain)", str) == -1)
-        goto failed;
+    virAsprintf(&tmp, " %s flags=(complain)", str);
 
     if (strstr(content, tmp) != NULL)
         rc = 0;
@@ -227,8 +221,7 @@ get_profile_name(virDomainDefPtr def)
     char *name = NULL;
 
     virUUIDFormat(def->uuid, uuidstr);
-    if (virAsprintf(&name, "%s%s", AA_PREFIX, uuidstr) < 0)
-        return NULL;
+    virAsprintf(&name, "%s%s", AA_PREFIX, uuidstr);
 
     return name;
 }
@@ -360,13 +353,8 @@ AppArmorSecurityManagerProbe(const char *virtDriver G_GNUC_UNUSED)
         return rc;
 
     /* see if template file exists */
-    if (virAsprintf(&template_qemu, "%s/TEMPLATE.qemu",
-                               APPARMOR_DIR "/libvirt") == -1)
-        return rc;
-
-    if (virAsprintf(&template_lxc, "%s/TEMPLATE.lxc",
-                               APPARMOR_DIR "/libvirt") == -1)
-        goto cleanup;
+    virAsprintf(&template_qemu, "%s/TEMPLATE.qemu", APPARMOR_DIR "/libvirt");
+    virAsprintf(&template_lxc, "%s/TEMPLATE.lxc", APPARMOR_DIR "/libvirt");
 
     if (!virFileExists(template_qemu)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1038,9 +1026,8 @@ AppArmorSetChardevLabel(virSecurityManagerPtr mgr,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if (virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0 ||
-            virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0)
-            goto done;
+        virAsprintf(&in, "%s.in", dev_source->data.file.path);
+        virAsprintf(&out, "%s.out", dev_source->data.file.path);
         if (virFileExists(in)) {
             if (reload_profile(mgr, def, in, true) < 0)
                 goto done;
@@ -1104,8 +1091,7 @@ AppArmorSetPathLabel(virSecurityManagerPtr mgr,
     char *full_path = NULL;
 
     if (allowSubtree) {
-        if (virAsprintf(&full_path, "%s/{,**}", path) < 0)
-            return -1;
+        virAsprintf(&full_path, "%s/{,**}", path);
         rc = reload_profile(mgr, def, full_path, true);
         VIR_FREE(full_path);
     } else {
@@ -1128,7 +1114,6 @@ AppArmorSetFDLabel(virSecurityManagerPtr mgr,
                    virDomainDefPtr def,
                    int fd)
 {
-    int rc = -1;
     char *proc = NULL;
     char *fd_path = NULL;
 
@@ -1138,8 +1123,7 @@ AppArmorSetFDLabel(virSecurityManagerPtr mgr,
     if (!secdef || !secdef->imagelabel)
         return 0;
 
-    if (virAsprintf(&proc, "/proc/self/fd/%d", fd) == -1)
-        return rc;
+    virAsprintf(&proc, "/proc/self/fd/%d", fd);
 
     if (virFileResolveLink(proc, &fd_path) < 0) {
         /* it's a deleted file, presumably.  Ignore? */
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 4f646bc3b7..dfa402d544 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -302,10 +302,8 @@ virSecurityDACSetUserAndGroup(virSecurityManagerPtr mgr,
     priv->user = user;
     priv->group = group;
 
-    if (virAsprintf(&priv->baselabel, "+%u:+%u",
-                    (unsigned int)user,
-                    (unsigned int)group) < 0)
-        return -1;
+    virAsprintf(&priv->baselabel, "+%u:+%u", (unsigned int)user,
+                (unsigned int)group);
 
     return 0;
 }
@@ -439,10 +437,7 @@ virSecurityDACRememberLabel(virSecurityDACDataPtr priv G_GNUC_UNUSED,
     char *label = NULL;
     int ret = -1;
 
-    if (virAsprintf(&label, "+%u:+%u",
-                    (unsigned int)uid,
-                    (unsigned int)gid) < 0)
-        return -1;
+    virAsprintf(&label, "+%u:+%u", (unsigned int)uid, (unsigned int)gid);
 
     ret = virSecuritySetRememberedLabel(SECURITY_DAC_NAME, path, label);
     VIR_FREE(label);
@@ -1512,9 +1507,8 @@ virSecurityDACSetChardevLabelHelper(virSecurityManagerPtr mgr,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if (virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0 ||
-            virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0)
-            goto done;
+        virAsprintf(&in, "%s.in", dev_source->data.file.path);
+        virAsprintf(&out, "%s.out", dev_source->data.file.path);
         if (virFileExists(in) && virFileExists(out)) {
             if (virSecurityDACSetOwnership(mgr, NULL, in, user, group, remember) < 0 ||
                 virSecurityDACSetOwnership(mgr, NULL, out, user, group, remember) < 0)
@@ -1605,9 +1599,8 @@ virSecurityDACRestoreChardevLabelHelper(virSecurityManagerPtr mgr,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if (virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0 ||
-            virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0)
-            goto done;
+        virAsprintf(&out, "%s.out", dev_source->data.file.path);
+        virAsprintf(&in, "%s.in", dev_source->data.file.path);
         if (virFileExists(in) && virFileExists(out)) {
             if (virSecurityDACRestoreFileLabelInternal(mgr, NULL, out, recall) < 0 ||
                 virSecurityDACRestoreFileLabelInternal(mgr, NULL, in, recall) < 0)
@@ -2288,10 +2281,8 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr,
         }
         break;
     case VIR_DOMAIN_SECLABEL_DYNAMIC:
-        if (virAsprintf(&seclabel->label, "+%u:+%u",
-                        (unsigned int)priv->user,
-                        (unsigned int)priv->group) < 0)
-            return rc;
+        virAsprintf(&seclabel->label, "+%u:+%u", (unsigned int)priv->user,
+                    (unsigned int)priv->group);
         if (seclabel->label == NULL) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("cannot generate dac user and group id "
@@ -2342,8 +2333,7 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
 
     VIR_DEBUG("Getting DAC user and group on process '%d'", pid);
 
-    if (virAsprintf(&path, "/proc/%d", (int)pid) < 0)
-        goto cleanup;
+    virAsprintf(&path, "/proc/%d", (int)pid);
 
     if (lstat(path, &sb) < 0) {
         virReportSystemError(errno,
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index d80ec01c5d..47fc95351f 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -381,16 +381,14 @@ virSecuritySELinuxMCSFind(virSecurityManagerPtr mgr,
         VIR_DEBUG("Try cat %s:c%d,c%d", sens, c1 + catMin, c2 + catMin);
 
         if (c1 == c2) {
-            if (virAsprintf(&mcs, "%s:c%d", sens, catMin + c1) < 0)
-                return NULL;
+            virAsprintf(&mcs, "%s:c%d", sens, catMin + c1);
         } else {
             if (c1 > c2) {
                 int t = c1;
                 c1 = c2;
                 c2 = t;
             }
-            if (virAsprintf(&mcs, "%s:c%d,c%d", sens, catMin + c1, catMin + c2) < 0)
-                return NULL;
+            virAsprintf(&mcs, "%s:c%d,c%d", sens, catMin + c1, catMin + c2);
         }
 
         if (virHashLookup(data->mcs, mcs) == NULL)
@@ -2204,9 +2202,8 @@ virSecuritySELinuxSetHostdevCapsLabel(virSecurityManagerPtr mgr,
     switch (dev->source.caps.type) {
     case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE: {
         if (vroot) {
-            if (virAsprintf(&path, "%s/%s", vroot,
-                            dev->source.caps.u.storage.block) < 0)
-                return -1;
+            virAsprintf(&path, "%s/%s", vroot,
+                        dev->source.caps.u.storage.block);
         } else {
             path = g_strdup(dev->source.caps.u.storage.block);
         }
@@ -2217,9 +2214,8 @@ virSecuritySELinuxSetHostdevCapsLabel(virSecurityManagerPtr mgr,
 
     case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC: {
         if (vroot) {
-            if (virAsprintf(&path, "%s/%s", vroot,
-                            dev->source.caps.u.misc.chardev) < 0)
-                return -1;
+            virAsprintf(&path, "%s/%s", vroot,
+                        dev->source.caps.u.misc.chardev);
         } else {
             path = g_strdup(dev->source.caps.u.misc.chardev);
         }
@@ -2437,9 +2433,8 @@ virSecuritySELinuxRestoreHostdevCapsLabel(virSecurityManagerPtr mgr,
     switch (dev->source.caps.type) {
     case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE: {
         if (vroot) {
-            if (virAsprintf(&path, "%s/%s", vroot,
-                            dev->source.caps.u.storage.block) < 0)
-                return -1;
+            virAsprintf(&path, "%s/%s", vroot,
+                        dev->source.caps.u.storage.block);
         } else {
             path = g_strdup(dev->source.caps.u.storage.block);
         }
@@ -2450,9 +2445,8 @@ virSecuritySELinuxRestoreHostdevCapsLabel(virSecurityManagerPtr mgr,
 
     case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC: {
         if (vroot) {
-            if (virAsprintf(&path, "%s/%s", vroot,
-                            dev->source.caps.u.misc.chardev) < 0)
-                return -1;
+            virAsprintf(&path, "%s/%s", vroot,
+                        dev->source.caps.u.misc.chardev);
         } else {
             path = g_strdup(dev->source.caps.u.misc.chardev);
         }
@@ -2550,9 +2544,8 @@ virSecuritySELinuxSetChardevLabel(virSecurityManagerPtr mgr,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if ((virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0) ||
-            (virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0))
-            goto done;
+        virAsprintf(&in, "%s.in", dev_source->data.file.path);
+        virAsprintf(&out, "%s.out", dev_source->data.file.path);
         if (virFileExists(in) && virFileExists(out)) {
             if ((virSecuritySELinuxSetFilecon(mgr, in, imagelabel, true) < 0) ||
                 (virSecuritySELinuxSetFilecon(mgr, out, imagelabel, true) < 0)) {
@@ -2625,9 +2618,8 @@ virSecuritySELinuxRestoreChardevLabel(virSecurityManagerPtr mgr,
         break;
 
     case VIR_DOMAIN_CHR_TYPE_PIPE:
-        if ((virAsprintf(&out, "%s.out", dev_source->data.file.path) < 0) ||
-            (virAsprintf(&in, "%s.in", dev_source->data.file.path) < 0))
-            goto done;
+        virAsprintf(&out, "%s.out", dev_source->data.file.path);
+        virAsprintf(&in, "%s.in", dev_source->data.file.path);
         if (virFileExists(in) && virFileExists(out)) {
             if ((virSecuritySELinuxRestoreFileLabel(mgr, out, true) < 0) ||
                 (virSecuritySELinuxRestoreFileLabel(mgr, in, true) < 0)) {
@@ -3265,8 +3257,7 @@ virSecuritySELinuxSetTapFDLabel(virSecurityManagerPtr mgr,
     }
 
     /* Label /dev/tap.* devices only. Leave /dev/net/tun alone! */
-    if (virAsprintf(&proc, "/proc/self/fd/%d", fd) == -1)
-        goto cleanup;
+    virAsprintf(&proc, "/proc/self/fd/%d", fd);
 
     if (virFileResolveLink(proc, &fd_path) < 0) {
         virReportSystemError(errno,
@@ -3349,11 +3340,11 @@ virSecuritySELinuxGetSecurityMountOptions(virSecurityManagerPtr mgr,
         if (!secdef->imagelabel)
             secdef->imagelabel = virSecuritySELinuxGenImageLabel(mgr, def);
 
-        if (secdef->imagelabel &&
+        if (secdef->imagelabel) {
             virAsprintf(&opts,
                         ",context=\"%s\"",
-                        (const char*) secdef->imagelabel) < 0)
-            return NULL;
+                        (const char*) secdef->imagelabel);
+        }
     }
 
     if (!opts)
@@ -3411,10 +3402,7 @@ virSecuritySELinuxSetFileLabels(virSecurityManagerPtr mgr,
         return -1;
 
     while ((ret = virDirRead(dir, &ent, path)) > 0) {
-        if (virAsprintf(&filename, "%s/%s", path, ent->d_name) < 0) {
-            ret = -1;
-            break;
-        }
+        virAsprintf(&filename, "%s/%s", path, ent->d_name);
         ret = virSecuritySELinuxSetFilecon(mgr, filename,
                                            seclabel->imagelabel, true);
         VIR_FREE(filename);
@@ -3460,10 +3448,7 @@ virSecuritySELinuxRestoreFileLabels(virSecurityManagerPtr mgr,
         return -1;
 
     while ((ret = virDirRead(dir, &ent, path)) > 0) {
-        if (virAsprintf(&filename, "%s/%s", path, ent->d_name) < 0) {
-            ret = -1;
-            break;
-        }
+        virAsprintf(&filename, "%s/%s", path, ent->d_name);
         ret = virSecuritySELinuxRestoreFileLabel(mgr, filename, true);
         VIR_FREE(filename);
         if (ret < 0)
diff --git a/src/security/security_util.c b/src/security/security_util.c
index e6fbae7e34..5fb0a3aae5 100644
--- a/src/security/security_util.c
+++ b/src/security/security_util.c
@@ -63,7 +63,7 @@ virSecurityGetAttrName(const char *name G_GNUC_UNUSED)
 {
     char *ret = NULL;
 #ifdef XATTR_NAMESPACE
-    ignore_value(virAsprintf(&ret, XATTR_NAMESPACE".libvirt.security.%s", name));
+    virAsprintf(&ret, XATTR_NAMESPACE".libvirt.security.%s", name);
 #else
     errno = ENOSYS;
     virReportSystemError(errno, "%s",
@@ -78,7 +78,7 @@ virSecurityGetRefCountAttrName(const char *name G_GNUC_UNUSED)
 {
     char *ret = NULL;
 #ifdef XATTR_NAMESPACE
-    ignore_value(virAsprintf(&ret, XATTR_NAMESPACE".libvirt.security.ref_%s", name));
+    virAsprintf(&ret, XATTR_NAMESPACE".libvirt.security.ref_%s", name);
 #else
     errno = ENOSYS;
     virReportSystemError(errno, "%s",
@@ -93,7 +93,7 @@ static char *
 virSecurityGetTimestampAttrName(const char *name)
 {
     char *ret = NULL;
-    ignore_value(virAsprintf(&ret, XATTR_NAMESPACE ".libvirt.security.timestamp_%s", name));
+    virAsprintf(&ret, XATTR_NAMESPACE ".libvirt.security.timestamp_%s", name);
     return ret;
 }
 #else /* !XATTR_NAMESPACE */
@@ -120,7 +120,7 @@ virSecurityGetTimestamp(void)
         return NULL;
     }
 
-    ignore_value(virAsprintf(&ret, "%llu", boottime));
+    virAsprintf(&ret, "%llu", boottime);
     return ret;
 }
 
@@ -312,8 +312,7 @@ virSecurityGetRememberedLabel(const char *name,
     refcount--;
 
     if (refcount > 0) {
-        if (virAsprintf(&value, "%u", refcount) < 0)
-            return -1;
+        virAsprintf(&value, "%u", refcount);
 
         if (virFileSetXAttr(path, ref_name, value) < 0)
             return -1;
@@ -420,8 +419,7 @@ virSecuritySetRememberedLabel(const char *name,
             return -1;
     }
 
-    if (virAsprintf(&value, "%u", refcount) < 0)
-        return -1;
+    virAsprintf(&value, "%u", refcount);
 
     if (virFileSetXAttr(path, ref_name, value) < 0)
         return -1;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 7d7262ca39..3fe2da22ef 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -157,11 +157,7 @@ parserCommand(const char *profile_name, const char cmd)
 
     snprintf(flag, 3, "-%c", cmd);
 
-    if (virAsprintfQuiet(&profile, "%s/%s",
-                         APPARMOR_DIR "/libvirt", profile_name) < 0) {
-        vah_error(NULL, 0, _("profile name exceeds maximum length"));
-        return -1;
-    }
+    virAsprintfQuiet(&profile, "%s/%s", APPARMOR_DIR "/libvirt", profile_name);
 
     if (!virFileExists(profile)) {
         vah_error(NULL, 0, _("profile does not exist"));
@@ -217,17 +213,10 @@ update_include_file(const char *include_file, const char *included_files,
             return rc;
     }
 
-    if (append && virFileExists(include_file)) {
-        if (virAsprintfQuiet(&pcontent, "%s%s", existing, included_files) == -1) {
-            vah_error(NULL, 0, _("could not allocate memory for profile"));
-            goto cleanup;
-        }
-    } else {
-        if (virAsprintfQuiet(&pcontent, "%s%s", warning, included_files) == -1) {
-            vah_error(NULL, 0, _("could not allocate memory for profile"));
-            goto cleanup;
-        }
-    }
+    if (append && virFileExists(include_file))
+        virAsprintfQuiet(&pcontent, "%s%s", existing, included_files);
+    else
+        virAsprintfQuiet(&pcontent, "%s%s", warning, included_files);
 
     plen = strlen(pcontent);
     if (plen > MAX_FILE_LEN) {
@@ -301,11 +290,8 @@ create_profile(const char *profile, const char *profile_name,
         driver_name = virDomainVirtTypeToString(virtType);
     }
 
-    if (virAsprintfQuiet(&template, "%s/TEMPLATE.%s", APPARMOR_DIR "/libvirt",
-                         driver_name) < 0) {
-        vah_error(NULL, 0, _("template name exceeds maximum length"));
-        goto end;
-    }
+    virAsprintfQuiet(&template, "%s/TEMPLATE.%s", APPARMOR_DIR "/libvirt",
+                     driver_name);
 
     if (!virFileExists(template)) {
         vah_error(NULL, 0, _("template does not exist"));
@@ -328,18 +314,11 @@ create_profile(const char *profile, const char *profile_name,
     }
 
     /* '\nprofile <profile_name>\0' */
-    if (virAsprintfQuiet(&replace_name, "\nprofile %s", profile_name) == -1) {
-        vah_error(NULL, 0, _("could not allocate memory for profile name"));
-        goto clean_tcontent;
-    }
+    virAsprintfQuiet(&replace_name, "\nprofile %s", profile_name);
 
     /* '\n<profile_files>\n}\0' */
-    if ((virtType != VIR_DOMAIN_VIRT_LXC) &&
-            virAsprintfQuiet(&replace_files, "\n%s\n}", profile_files) == -1) {
-        vah_error(NULL, 0, _("could not allocate memory for profile files"));
-        VIR_FREE(replace_name);
-        goto clean_tcontent;
-    }
+    if (virtType != VIR_DOMAIN_VIRT_LXC)
+        virAsprintfQuiet(&replace_files, "\n%s\n}", profile_files);
 
     plen = tlen + strlen(replace_name) - strlen(template_name) + 1;
 
@@ -790,8 +769,7 @@ vah_add_path(virBufferPtr buf, const char *path, const char *perms, bool recursi
             vah_error(NULL, 0, _("could not find realpath"));
             goto cleanup;
         }
-        if (virAsprintfQuiet(&tmp, "%s%s", pathreal, pathtmp) < 0)
-            goto cleanup;
+        virAsprintfQuiet(&tmp, "%s%s", pathreal, pathtmp);
     }
 
     perms_new = g_strdup(perms);
@@ -858,19 +836,13 @@ vah_add_file_chardev(virBufferPtr buf,
 
     if (type == VIR_DOMAIN_CHR_TYPE_PIPE) {
         /* add the pipe input */
-        if (virAsprintfQuiet(&pipe_in, "%s.in", path) == -1) {
-            vah_error(NULL, 0, _("could not allocate memory"));
-            goto cleanup;
-        }
+        virAsprintfQuiet(&pipe_in, "%s.in", path);
 
         if (vah_add_file(buf, pipe_in, perms) != 0)
             goto clean_pipe_in;
 
         /* add the pipe output */
-        if (virAsprintfQuiet(&pipe_out, "%s.out", path) == -1) {
-            vah_error(NULL, 0, _("could not allocate memory"));
-            goto clean_pipe_in;
-        }
+        virAsprintfQuiet(&pipe_out, "%s.out", path);
 
         if (vah_add_file(buf, pipe_out, perms) != 0)
             goto clean_pipe_out;
@@ -963,10 +935,7 @@ get_files(vahControl * ctl)
 
     /* verify uuid is same as what we were given on the command line */
     virUUIDFormat(ctl->def->uuid, uuidstr);
-    if (virAsprintfQuiet(&uuid, "%s%s", AA_PREFIX, uuidstr) == -1) {
-        vah_error(ctl, 0, _("could not allocate memory"));
-        return rc;
-    }
+    virAsprintfQuiet(&uuid, "%s%s", AA_PREFIX, uuidstr);
 
     if (STRNEQ(uuid, ctl->uuid)) {
         vah_error(ctl, 0, _("given uuid does not match XML uuid"));
@@ -1463,13 +1432,8 @@ main(int argc, char **argv)
     if (vahParseArgv(ctl, argc, argv) != 0)
         vah_error(ctl, 1, _("could not parse arguments"));
 
-    if (virAsprintfQuiet(&profile, "%s/%s",
-                         APPARMOR_DIR "/libvirt", ctl->uuid) < 0)
-        vah_error(ctl, 0, _("could not allocate memory"));
-
-    if (virAsprintfQuiet(&include_file, "%s/%s.files",
-                         APPARMOR_DIR "/libvirt", ctl->uuid) < 0)
-        vah_error(ctl, 0, _("could not allocate memory"));
+    virAsprintfQuiet(&profile, "%s/%s", APPARMOR_DIR "/libvirt", ctl->uuid);
+    virAsprintfQuiet(&include_file, "%s/%s.files", APPARMOR_DIR "/libvirt", ctl->uuid);
 
     if (ctl->cmd == 'a') {
         rc = parserLoad(ctl->uuid);
@@ -1531,11 +1495,7 @@ main(int argc, char **argv)
         /* create the profile from TEMPLATE */
         if (ctl->cmd == 'c') {
             char *tmp = NULL;
-            if (virAsprintfQuiet(&tmp, "  #include <libvirt/%s.files>\n",
-                                 ctl->uuid) == -1) {
-                vah_error(ctl, 0, _("could not allocate memory"));
-                goto cleanup;
-            }
+            virAsprintfQuiet(&tmp, "  #include <libvirt/%s.files>\n", ctl->uuid);
 
             if (ctl->dryrun) {
                 vah_info(profile);
-- 
2.21.0

--
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]

  Powered by Linux