From nobody Sun Feb 8 14:59:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571753105; cv=none; d=zoho.com; s=zohoarc; b=ARHGiCSLvv8wcUBB+fsz/rg+YBu458yyzBwNuWrx5Xpx1gHtOHaOL01Uz9BrfzHLhIyMN3oKJCidiqTB+vK4mx1/NtAVs/0alHdLgHrY1P4K7ZcP5PSTXmAtbS9zXWy8QuiMKHOsYamVPmtxkBtUA1lBpAlbcpcVpE2UMPVbeAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571753105; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m+vAagpc7RpzlaE9kf/Wg4fowDFKxpylk5vv8610CPs=; b=k6EILSy4qnxDB4QXAl3Qh0vMhH1p1JmhCOtrpJDjK2FL+awLkmWc9c/SThHzfNjGSG0JbJbS1NJpST+DSIytjlpblejUaC/8wjnowBzEF9VvNWE+0kXPUckUNCHZgr2SJq3fnsL/6zVq7TX1tvR0tO9QmDbsOpap2x3faHHhcdc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1571753105725688.2607948079643; Tue, 22 Oct 2019 07:05:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-a6biTjoXOxOarggZmfggHA-1; Tue, 22 Oct 2019 09:58:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03B5F80183E; Tue, 22 Oct 2019 13:58:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD8F061F21; Tue, 22 Oct 2019 13:58:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7FA351803B4D; Tue, 22 Oct 2019 13:58:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9MDwesi001645 for ; Tue, 22 Oct 2019 09:58:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61E5E6012C; Tue, 22 Oct 2019 13:58:40 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE05D60161 for ; Tue, 22 Oct 2019 13:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571753104; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=m+vAagpc7RpzlaE9kf/Wg4fowDFKxpylk5vv8610CPs=; b=QpfmdudKsiuvlndYrxk2YttOwbnHCIQz1sl80jdprYwoXXxRyMg195HNoYp1g6Aq4WMWOj L7Zf27y0pd4RVU68RzI9ECxl5fOOTy1E0RenwJUQNIBjcaQbnoV/N7e+KbJZM1/c6hRMtW 8zg+oPnAu0tTeA3B2SSvX5BQ09IzjxM= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 15:57:17 +0200 Message-Id: <9a1c08356f212a90df88bb3ebf5ea292b7872eea.1571752582.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/75] lxc: Drop virAsprintf() and virAsprintfQuiet() retval checking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: a6biTjoXOxOarggZmfggHA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" These functions can't fail really. Drop checking of their retval then. Signed-off-by: Michal Privoznik --- src/lxc/lxc_container.c | 69 ++++++++++++++--------------------- src/lxc/lxc_controller.c | 79 +++++++++++++--------------------------- src/lxc/lxc_driver.c | 15 ++------ src/lxc/lxc_fuse.c | 10 ++--- src/lxc/lxc_monitor.c | 4 +- src/lxc/lxc_native.c | 11 ++---- src/lxc/lxc_process.c | 35 +++++------------- 7 files changed, 75 insertions(+), 148 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 88dc2e2bdf..090a22571d 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -682,9 +682,7 @@ static int lxcContainerPrepareRoot(virDomainDefPtr def, if (lxcContainerResolveSymlinks(root, false) < 0) return -1; =20 - if (virAsprintf(&dst, "%s/%s.root", - LXC_STATE_DIR, def->name) < 0) - return -1; + virAsprintf(&dst, "%s/%s.root", LXC_STATE_DIR, def->name); =20 tmp =3D root->dst; root->dst =3D dst; @@ -719,8 +717,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) goto err; } =20 - if (virAsprintf(&oldroot, "%s/.oldroot", root->src->path) < 0) - goto err; + virAsprintf(&oldroot, "%s/.oldroot", root->src->path); =20 if (virFileMakePath(oldroot) < 0) { virReportSystemError(errno, @@ -739,8 +736,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) } =20 /* Create a directory called 'new' in tmpfs */ - if (virAsprintf(&newroot, "%s/new", oldroot) < 0) - goto err; + virAsprintf(&newroot, "%s/new", oldroot); =20 if (virFileMakePath(newroot) < 0) { virReportSystemError(errno, @@ -925,8 +921,7 @@ static int lxcContainerMountBasicFS(bool userns_enabled, char *hostdir; int ret; =20 - if (virAsprintf(&hostdir, "/.oldroot%s", mnt->dst) < 0) - goto cleanup; + virAsprintf(&hostdir, "/.oldroot%s", mnt->dst); =20 ret =3D virFileIsMountPoint(hostdir); VIR_FREE(hostdir); @@ -1017,11 +1012,10 @@ static int lxcContainerMountProcFuse(virDomainDefPt= r def, =20 VIR_DEBUG("Mount /proc/meminfo stateDir=3D%s", stateDir); =20 - if ((ret =3D virAsprintf(&meminfo_path, - "/.oldroot/%s/%s.fuse/meminfo", - stateDir, - def->name)) < 0) - return ret; + virAsprintf(&meminfo_path, + "/.oldroot/%s/%s.fuse/meminfo", + stateDir, + def->name); =20 if ((ret =3D mount(meminfo_path, "/proc/meminfo", NULL, MS_BIND, NULL)) < 0) { @@ -1050,9 +1044,7 @@ static int lxcContainerMountFSDev(virDomainDefPtr def, =20 VIR_DEBUG("Mount /dev/ stateDir=3D%s", stateDir); =20 - if ((ret =3D virAsprintf(&path, "/.oldroot/%s/%s.dev", - stateDir, def->name)) < 0) - return ret; + virAsprintf(&path, "/.oldroot/%s/%s.dev", stateDir, def->name); =20 if (virFileMakePath("/dev") < 0) { virReportSystemError(errno, "%s", @@ -1086,9 +1078,7 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr = def, =20 VIR_DEBUG("Mount /dev/pts stateDir=3D%s", stateDir); =20 - if (virAsprintf(&path, "/.oldroot/%s/%s.devpts", - stateDir, def->name) < 0) - return ret; + virAsprintf(&path, "/.oldroot/%s/%s.devpts", stateDir, def->name); =20 if (virFileMakePath("/dev/pts") < 0) { virReportSystemError(errno, "%s", @@ -1140,8 +1130,7 @@ static int lxcContainerSetupDevices(char **ttyPaths, = size_t nttyPaths) =20 for (i =3D 0; i < nttyPaths; i++) { char *tty; - if (virAsprintf(&tty, "/dev/tty%zu", i+1) < 0) - return -1; + virAsprintf(&tty, "/dev/tty%zu", i + 1); =20 if (virFileBindMountDevice(ttyPaths[i], tty) < 0) { VIR_FREE(tty); @@ -1167,8 +1156,7 @@ static int lxcContainerMountFSBind(virDomainFSDefPtr = fs, =20 VIR_DEBUG("src=3D%s dst=3D%s", fs->src->path, fs->dst); =20 - if (virAsprintf(&src, "%s%s", srcprefix, fs->src->path) < 0) - goto cleanup; + virAsprintf(&src, "%s%s", srcprefix, fs->src->path); =20 if (stat(fs->dst, &st) < 0) { if (errno !=3D ENOENT) { @@ -1338,9 +1326,8 @@ static int lxcContainerMountFSBlockAuto(virDomainFSDe= fPtr fs, =20 /* First time around we use /etc/filesystems */ retry: - if (virAsprintf(&fslist, "%s%s", srcprefix, - tryProc ? "/proc/filesystems" : "/etc/filesystems") < = 0) - goto cleanup; + virAsprintf(&fslist, "%s%s", srcprefix, + tryProc ? "/proc/filesystems" : "/etc/filesystems"); =20 VIR_DEBUG("Open fslist %s", fslist); if (!(fp =3D fopen(fslist, "r"))) { @@ -1501,14 +1488,12 @@ static int lxcContainerMountFSBlock(virDomainFSDefP= tr fs, =20 VIR_DEBUG("src=3D%s dst=3D%s", fs->src->path, fs->dst); =20 - if (virAsprintf(&src, "%s%s", srcprefix, fs->src->path) < 0) - goto cleanup; + virAsprintf(&src, "%s%s", srcprefix, fs->src->path); =20 ret =3D lxcContainerMountFSBlockHelper(fs, src, srcprefix, sec_mount_o= ptions); =20 VIR_DEBUG("Done mounting filesystem ret=3D%d", ret); =20 - cleanup: VIR_FREE(src); return ret; } @@ -1522,9 +1507,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr= fs, =20 VIR_DEBUG("usage=3D%lld sec=3D%s", fs->usage, sec_mount_options); =20 - if (virAsprintf(&data, - "size=3D%lld%s", fs->usage, sec_mount_options) < 0) - goto cleanup; + virAsprintf(&data, "size=3D%lld%s", fs->usage, sec_mount_options); =20 if (virFileMakePath(fs->dst) < 0) { virReportSystemError(errno, @@ -1672,19 +1655,22 @@ static int lxcContainerUnmountForSharedRoot(const c= har *stateDir, =20 /* These filesystems are created by libvirt temporarily, they * shouldn't appear in container. */ - if (virAsprintf(&tmp, "%s/%s.dev", stateDir, domain) < 0 || - lxcContainerUnmountSubtree(tmp, false) < 0) + virAsprintf(&tmp, "%s/%s.dev", stateDir, domain); + + if (lxcContainerUnmountSubtree(tmp, false) < 0) goto cleanup; =20 VIR_FREE(tmp); - if (virAsprintf(&tmp, "%s/%s.devpts", stateDir, domain) < 0 || - lxcContainerUnmountSubtree(tmp, false) < 0) + virAsprintf(&tmp, "%s/%s.devpts", stateDir, domain); + + if (lxcContainerUnmountSubtree(tmp, false) < 0) goto cleanup; =20 #if WITH_FUSE VIR_FREE(tmp); - if (virAsprintf(&tmp, "%s/%s.fuse", stateDir, domain) < 0 || - lxcContainerUnmountSubtree(tmp, false) < 0) + virAsprintf(&tmp, "%s/%s.fuse", stateDir, domain); + + if (lxcContainerUnmountSubtree(tmp, false) < 0) goto cleanup; #endif =20 @@ -2246,9 +2232,8 @@ static int lxcContainerChild(void *data) const char *tty =3D argv->ttyPaths[0]; if (STRPREFIX(tty, "/dev/pts/")) tty +=3D strlen("/dev/pts/"); - if (virAsprintf(&ttyPath, "%s/%s.devpts/%s", - LXC_STATE_DIR, vmDef->name, tty) < 0) - goto cleanup; + virAsprintf(&ttyPath, "%s/%s.devpts/%s", LXC_STATE_DIR, vmDef->nam= e, + tty); } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("At least one tty is required")); diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 0c5b9e713d..56e30eeaa9 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -565,10 +565,11 @@ static int virLXCControllerAppendNBDPids(virLXCContro= llerPtr ctrl, size_t loops =3D 0; pid_t pid; =20 - if (!STRPREFIX(dev, "/dev/") || - virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5= ) < 0) + if (!STRPREFIX(dev, "/dev/")) goto cleanup; =20 + virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5); + /* Wait for the pid file to appear */ while (!virFileExists(pidpath)) { /* wait for 100ms before checking again, but don't do it for ever = */ @@ -945,9 +946,7 @@ static int virLXCControllerSetupServer(virLXCController= Ptr ctrl) virNetServerServicePtr svc =3D NULL; char *sockpath; =20 - if (virAsprintf(&sockpath, "%s/%s.sock", - LXC_STATE_DIR, ctrl->name) < 0) - return -1; + virAsprintf(&sockpath, "%s/%s.sock", LXC_STATE_DIR, ctrl->name); =20 if (!(srv =3D virNetServerNew("LXC", 1, 0, 0, 0, 1, @@ -1435,16 +1434,14 @@ static int virLXCControllerSetupUserns(virLXCContro= llerPtr ctrl) } =20 VIR_DEBUG("Setting up userns maps"); - if (virAsprintf(&uid_map, "/proc/%d/uid_map", ctrl->initpid) < 0) - goto cleanup; + virAsprintf(&uid_map, "/proc/%d/uid_map", ctrl->initpid); =20 if (virLXCControllerSetupUsernsMap(ctrl->def->idmap.uidmap, ctrl->def->idmap.nuidmap, uid_map) < 0) goto cleanup; =20 - if (virAsprintf(&gid_map, "/proc/%d/gid_map", ctrl->initpid) < 0) - goto cleanup; + virAsprintf(&gid_map, "/proc/%d/gid_map", ctrl->initpid); =20 if (virLXCControllerSetupUsernsMap(ctrl->def->idmap.gidmap, ctrl->def->idmap.ngidmap, @@ -1470,18 +1467,14 @@ static int virLXCControllerSetupDev(virLXCControlle= rPtr ctrl) mount_options =3D virSecurityManagerGetMountOptions(ctrl->securityMana= ger, ctrl->def); =20 - if (virAsprintf(&dev, "/%s/%s.dev", - LXC_STATE_DIR, ctrl->def->name) < 0) - goto cleanup; + virAsprintf(&dev, "/%s/%s.dev", LXC_STATE_DIR, ctrl->def->name); =20 /* * tmpfs is limited to 64kb, since we only have device nodes in there * and don't want to DOS the entire OS RAM usage */ =20 - if (virAsprintf(&opts, - "mode=3D755,size=3D65536%s", mount_options) < 0) - goto cleanup; + virAsprintf(&opts, "mode=3D755,size=3D65536%s", mount_options); =20 if (virFileSetupDev(dev, opts) < 0) goto cleanup; @@ -1521,9 +1514,8 @@ static int virLXCControllerPopulateDevices(virLXCCont= rollerPtr ctrl) =20 /* Populate /dev/ with a few important bits */ for (i =3D 0; i < G_N_ELEMENTS(devs); i++) { - if (virAsprintf(&path, "/%s/%s.dev/%s", - LXC_STATE_DIR, ctrl->def->name, devs[i].path) < 0) - goto cleanup; + virAsprintf(&path, "/%s/%s.dev/%s", LXC_STATE_DIR, ctrl->def->name, + devs[i].path); =20 dev_t dev =3D makedev(devs[i].maj, devs[i].min); if (mknod(path, S_IFCHR, dev) < 0 || @@ -1561,19 +1553,13 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefP= tr vmDef, mode_t mode; virDomainHostdevSubsysUSBPtr usbsrc =3D &def->source.subsys.u.usb; =20 - if (virAsprintf(&src, USB_DEVFS "/%03d/%03d", - usbsrc->bus, usbsrc->device) < 0) - goto cleanup; + virAsprintf(&src, USB_DEVFS "/%03d/%03d", usbsrc->bus, usbsrc->device); =20 - if (virAsprintf(&vroot, "/%s/%s.dev/bus/usb/", - LXC_STATE_DIR, vmDef->name) < 0) - goto cleanup; + virAsprintf(&vroot, "/%s/%s.dev/bus/usb/", LXC_STATE_DIR, vmDef->name); =20 - if (virAsprintf(&dstdir, "%s/%03d/", vroot, usbsrc->bus) < 0) - goto cleanup; + virAsprintf(&dstdir, "%s/%03d/", vroot, usbsrc->bus); =20 - if (virAsprintf(&dstfile, "%s/%03d", dstdir, usbsrc->device) < 0) - goto cleanup; + virAsprintf(&dstfile, "%s/%03d", dstdir, usbsrc->device); =20 if (stat(src, &sb) < 0) { virReportSystemError(errno, @@ -1647,10 +1633,8 @@ virLXCControllerSetupHostdevCapsStorage(virDomainDef= Ptr vmDef, while (*(path + len) =3D=3D '/') len++; =20 - if (virAsprintf(&dst, "/%s/%s.dev/%s", - LXC_STATE_DIR, vmDef->name, - strchr(path + len, '/')) < 0) - goto cleanup; + virAsprintf(&dst, "/%s/%s.dev/%s", LXC_STATE_DIR, vmDef->name, + strchr(path + len, '/')); =20 if (stat(dev, &sb) < 0) { virReportSystemError(errno, @@ -1725,10 +1709,8 @@ virLXCControllerSetupHostdevCapsMisc(virDomainDefPtr= vmDef, while (*(path + len) =3D=3D '/') len++; =20 - if (virAsprintf(&dst, "/%s/%s.dev/%s", - LXC_STATE_DIR, vmDef->name, - strchr(path + len, '/')) < 0) - goto cleanup; + virAsprintf(&dst, "/%s/%s.dev/%s", LXC_STATE_DIR, vmDef->name, + strchr(path + len, '/')); =20 if (stat(dev, &sb) < 0) { virReportSystemError(errno, @@ -1883,9 +1865,8 @@ static int virLXCControllerSetupDisk(virLXCController= Ptr ctrl, goto cleanup; } =20 - if (virAsprintf(&dst, "/%s/%s.dev/%s", - LXC_STATE_DIR, ctrl->def->name, def->dst) < 0) - goto cleanup; + virAsprintf(&dst, "/%s/%s.dev/%s", LXC_STATE_DIR, ctrl->def->name, + def->dst); =20 if (stat(def->src->path, &sb) < 0) { virReportSystemError(errno, @@ -2074,12 +2055,8 @@ lxcCreateTty(virLXCControllerPtr ctrl, int *ttymaste= r, * while glibc has to fstat(), fchmod(), and fchown() for older * kernels, we can skip those steps. ptyno shouldn't currently be * anything other than 0, but let's play it safe. */ - if ((virAsprintf(ttyName, "/dev/pts/%d", ptyno) < 0) || - (virAsprintf(ttyHostPath, "/%s/%s.devpts/%d", LXC_STATE_DIR, - ctrl->def->name, ptyno) < 0)) { - errno =3D ENOMEM; - goto cleanup; - } + virAsprintf(ttyName, "/dev/pts/%d", ptyno); + virAsprintf(ttyHostPath, "/%s/%s.devpts/%d", LXC_STATE_DIR, ctrl->def-= >name, ptyno); =20 ret =3D 0; =20 @@ -2135,11 +2112,8 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl) mount_options =3D virSecurityManagerGetMountOptions(ctrl->securityMana= ger, ctrl->def); =20 - if (virAsprintf(&devpts, "%s/%s.devpts", - LXC_STATE_DIR, ctrl->def->name) < 0 || - virAsprintf(&ctrl->devptmx, "%s/%s.devpts/ptmx", - LXC_STATE_DIR, ctrl->def->name) < 0) - goto cleanup; + virAsprintf(&devpts, "%s/%s.devpts", LXC_STATE_DIR, ctrl->def->name); + virAsprintf(&ctrl->devptmx, "%s/%s.devpts/ptmx", LXC_STATE_DIR, ctrl->= def->name); =20 if (virFileMakePath(devpts) < 0) { virReportSystemError(errno, @@ -2155,9 +2129,8 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl) =20 /* XXX should we support gid=3DX for X!=3D5 for distros which use * a different gid for tty? */ - if (virAsprintf(&opts, "newinstance,ptmxmode=3D0666,mode=3D0620,gid=3D= %u%s", - ptsgid, NULLSTR_EMPTY(mount_options)) < 0) - goto cleanup; + virAsprintf(&opts, "newinstance,ptmxmode=3D0666,mode=3D0620,gid=3D%u%s= ", ptsgid, + NULLSTR_EMPTY(mount_options)); =20 VIR_DEBUG("Mount devpts on %s type=3Dtmpfs flags=3D0x%x, opts=3D%s", devpts, MS_NOSUID, opts); diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 41a6a446bd..acaeae9311 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3788,9 +3788,7 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver, if (VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1) < 0) goto cleanup; =20 - if (virAsprintf(&file, - "/dev/%s", def->dst) < 0) - goto cleanup; + virAsprintf(&file, "/dev/%s", def->dst); =20 if (lxcDomainAttachDeviceMknod(driver, 0700 | S_IFBLK, @@ -3975,9 +3973,7 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDrive= rPtr driver, } =20 usbsrc =3D &def->source.subsys.u.usb; - if (virAsprintf(&src, "/dev/bus/usb/%03d/%03d", - usbsrc->bus, usbsrc->device) < 0) - goto cleanup; + virAsprintf(&src, "/dev/bus/usb/%03d/%03d", usbsrc->bus, usbsrc->devic= e); =20 if (!(usb =3D virUSBDeviceNew(usbsrc->bus, usbsrc->device, NULL))) goto cleanup; @@ -4313,8 +4309,7 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm, def =3D vm->def->disks[idx]; src =3D virDomainDiskGetSource(def); =20 - if (virAsprintf(&dst, "/dev/%s", def->dst) < 0) - goto cleanup; + virAsprintf(&dst, "/dev/%s", def->dst); =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICE= S)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -4452,9 +4447,7 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr d= river, } =20 usbsrc =3D &def->source.subsys.u.usb; - if (virAsprintf(&dst, "/dev/bus/usb/%03d/%03d", - usbsrc->bus, usbsrc->device) < 0) - goto cleanup; + virAsprintf(&dst, "/dev/bus/usb/%03d/%03d", usbsrc->bus, usbsrc->devic= e); =20 if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICE= S)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index b64b275a87..35dbad7986 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -47,8 +47,7 @@ static int lxcProcGetattr(const char *path, struct stat *= stbuf) virDomainDefPtr def =3D (virDomainDefPtr)context->private_data; =20 memset(stbuf, 0, sizeof(struct stat)); - if (virAsprintf(&mempath, "/proc/%s", path) < 0) - return -errno; + virAsprintf(&mempath, "/proc/%s", path); =20 res =3D 0; =20 @@ -251,8 +250,7 @@ static int lxcProcRead(const char *path G_GNUC_UNUSED, struct fuse_context *context =3D NULL; virDomainDefPtr def =3D NULL; =20 - if (virAsprintf(&hostpath, "/proc/%s", path) < 0) - return -errno; + virAsprintf(&hostpath, "/proc/%s", path); =20 context =3D fuse_get_context(); def =3D (virDomainDefPtr)context->private_data; @@ -307,9 +305,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def) if (virMutexInit(&fuse->lock) < 0) goto cleanup2; =20 - if (virAsprintf(&fuse->mountpoint, "%s/%s.fuse/", LXC_STATE_DIR, - def->name) < 0) - goto cleanup1; + virAsprintf(&fuse->mountpoint, "%s/%s.fuse/", LXC_STATE_DIR, def->name= ); =20 if (virFileMakePath(fuse->mountpoint) < 0) { virReportSystemError(errno, _("Cannot create %s"), diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c index 028e401236..1983af135e 100644 --- a/src/lxc/lxc_monitor.c +++ b/src/lxc/lxc_monitor.c @@ -151,9 +151,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm, if (!(mon =3D virObjectLockableNew(virLXCMonitorClass))) return NULL; =20 - if (virAsprintf(&sockpath, "%s/%s.sock", - socketdir, vm->def->name) < 0) - goto error; + virAsprintf(&sockpath, "%s/%s.sock", socketdir, vm->def->name); =20 if (!(mon->client =3D virNetClientNewUNIX(sockpath, false, NULL))) goto error; diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 5df09a849e..c7cf2c4b0e 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -265,8 +265,7 @@ lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab) return -1; =20 if (fstab->dst[0] !=3D '/') { - if (virAsprintf(&dst, "/%s", fstab->dst) < 0) - goto cleanup; + virAsprintf(&dst, "/%s", fstab->dst); } else { dst =3D g_strdup(fstab->dst); } @@ -492,9 +491,8 @@ lxcAddNetworkDefinition(lxcNetworkParseData *data) * on the host */ if (isVlan && data->vlanid) { VIR_FREE(hostdev->source.caps.u.net.ifname); - if (virAsprintf(&hostdev->source.caps.u.net.ifname, - "%s.%s", data->link, data->vlanid) < 0) - goto error; + virAsprintf(&hostdev->source.caps.u.net.ifname, "%s.%s", + data->link, data->vlanid); } =20 hostdev->source.caps.u.net.ip.ips =3D data->ips; @@ -950,8 +948,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfVal= uePtr value, void *data) goto cleanup; } =20 - if (virAsprintf(&path, "/dev/block/%s", parts[0]) < 0) - goto cleanup; + virAsprintf(&path, "/dev/block/%s", parts[0]); =20 /* Do we already have a device definition for this path? * Get that device or create a new one */ diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 450053d163..2ec5762856 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -138,8 +138,7 @@ lxcProcessRemoveDomainStatus(virLXCDriverConfigPtr cfg, char ebuf[1024]; char *file =3D NULL; =20 - if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) < 0) - return; + virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name); =20 if (unlink(file) < 0 && errno !=3D ENOENT && errno !=3D ENOTDIR) VIR_WARN("Failed to remove domain XML for %s: %s", @@ -419,10 +418,8 @@ static int virLXCProcessSetupNamespaceName(virConnectP= tr conn, int ns_type, cons goto cleanup; } =20 - if (virAsprintf(&path, "/proc/%lld/ns/%s", - (long long int)priv->initpid, - nsInfoLocal[ns_type]) < 0) - goto cleanup; + virAsprintf(&path, "/proc/%lld/ns/%s", (long long int)priv->initpid, + nsInfoLocal[ns_type]); =20 if ((fd =3D open(path, O_RDONLY)) < 0) { virReportSystemError(errno, @@ -443,10 +440,7 @@ static int virLXCProcessSetupNamespacePID(int ns_type,= const char *name) int fd; char *path; =20 - if (virAsprintf(&path, "/proc/%s/ns/%s", - name, - nsInfoLocal[ns_type]) < 0) - return -1; + virAsprintf(&path, "/proc/%s/ns/%s", name, nsInfoLocal[ns_type]); fd =3D open(path, O_RDONLY); VIR_FREE(path); if (fd < 0) { @@ -470,8 +464,7 @@ static int virLXCProcessSetupNamespaceNet(int ns_type, = const char *name) return -1; } =20 - if (virAsprintf(&path, "%s/netns/%s", RUNSTATEDIR, name) < 0) - return -1; + virAsprintf(&path, "%s/netns/%s", RUNSTATEDIR, name); fd =3D open(path, O_RDONLY); VIR_FREE(path); if (fd < 0) { @@ -632,8 +625,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, =20 /* Make sure all net definitions will have a name in the container= */ if (!net->ifname_guest) { - if (virAsprintf(&net->ifname_guest, "eth%zu", niface) < 0) - goto cleanup; + virAsprintf(&net->ifname_guest, "eth%zu", niface); niface++; } } @@ -757,9 +749,7 @@ virLXCProcessGetNsInode(pid_t pid, struct stat sb; int ret =3D -1; =20 - if (virAsprintf(&path, "/proc/%lld/ns/%s", - (long long)pid, nsname) < 0) - goto cleanup; + virAsprintf(&path, "/proc/%lld/ns/%s", (long long)pid, nsname); =20 if (stat(path, &sb) < 0) { virReportSystemError(errno, @@ -984,9 +974,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, for (i =3D 0; i < VIR_LXC_DOMAIN_NAMESPACE_LAST; i++) { if (nsInheritFDs[i] > 0) { char *tmp =3D NULL; - if (virAsprintf(&tmp, "--share-%s", - nsInfoLocal[i]) < 0) - goto error; + virAsprintf(&tmp, "--share-%s", nsInfoLocal[i]); virCommandAddArg(cmd, tmp); virCommandAddArgFormat(cmd, "%d", nsInheritFDs[i]); virCommandPassFD(cmd, nsInheritFDs[i], 0); @@ -1269,9 +1257,7 @@ int virLXCProcessStart(virConnectPtr conn, vm->def->resource =3D res; } =20 - if (virAsprintf(&logfile, "%s/%s.log", - cfg->logDir, vm->def->name) < 0) - goto cleanup; + virAsprintf(&logfile, "%s/%s.log", cfg->logDir, vm->def->name); =20 if (!(pidfile =3D virPidFileBuildPath(cfg->stateDir, vm->def->name))) goto cleanup; @@ -1358,8 +1344,7 @@ int virLXCProcessStart(virConnectPtr conn, vm->def->consoles[i]->source->data.file.path =3D ttyPath; =20 VIR_FREE(vm->def->consoles[i]->info.alias); - if (virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i= ) < 0) - goto cleanup; + virAsprintf(&vm->def->consoles[i]->info.alias, "console%zu", i); } =20 VIR_DEBUG("Setting up Interfaces"); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list