These functions can't fail really. Drop checking of their retval then. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- 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; - if (virAsprintf(&dst, "%s/%s.root", - LXC_STATE_DIR, def->name) < 0) - return -1; + virAsprintf(&dst, "%s/%s.root", LXC_STATE_DIR, def->name); tmp = root->dst; root->dst = dst; @@ -719,8 +717,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) goto err; } - if (virAsprintf(&oldroot, "%s/.oldroot", root->src->path) < 0) - goto err; + virAsprintf(&oldroot, "%s/.oldroot", root->src->path); if (virFileMakePath(oldroot) < 0) { virReportSystemError(errno, @@ -739,8 +736,7 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root) } /* Create a directory called 'new' in tmpfs */ - if (virAsprintf(&newroot, "%s/new", oldroot) < 0) - goto err; + virAsprintf(&newroot, "%s/new", oldroot); if (virFileMakePath(newroot) < 0) { virReportSystemError(errno, @@ -925,8 +921,7 @@ static int lxcContainerMountBasicFS(bool userns_enabled, char *hostdir; int ret; - if (virAsprintf(&hostdir, "/.oldroot%s", mnt->dst) < 0) - goto cleanup; + virAsprintf(&hostdir, "/.oldroot%s", mnt->dst); ret = virFileIsMountPoint(hostdir); VIR_FREE(hostdir); @@ -1017,11 +1012,10 @@ static int lxcContainerMountProcFuse(virDomainDefPtr def, VIR_DEBUG("Mount /proc/meminfo stateDir=%s", stateDir); - if ((ret = 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); if ((ret = mount(meminfo_path, "/proc/meminfo", NULL, MS_BIND, NULL)) < 0) { @@ -1050,9 +1044,7 @@ static int lxcContainerMountFSDev(virDomainDefPtr def, VIR_DEBUG("Mount /dev/ stateDir=%s", stateDir); - if ((ret = virAsprintf(&path, "/.oldroot/%s/%s.dev", - stateDir, def->name)) < 0) - return ret; + virAsprintf(&path, "/.oldroot/%s/%s.dev", stateDir, def->name); if (virFileMakePath("/dev") < 0) { virReportSystemError(errno, "%s", @@ -1086,9 +1078,7 @@ static int lxcContainerMountFSDevPTS(virDomainDefPtr def, VIR_DEBUG("Mount /dev/pts stateDir=%s", stateDir); - if (virAsprintf(&path, "/.oldroot/%s/%s.devpts", - stateDir, def->name) < 0) - return ret; + virAsprintf(&path, "/.oldroot/%s/%s.devpts", stateDir, def->name); if (virFileMakePath("/dev/pts") < 0) { virReportSystemError(errno, "%s", @@ -1140,8 +1130,7 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths) for (i = 0; i < nttyPaths; i++) { char *tty; - if (virAsprintf(&tty, "/dev/tty%zu", i+1) < 0) - return -1; + virAsprintf(&tty, "/dev/tty%zu", i + 1); if (virFileBindMountDevice(ttyPaths[i], tty) < 0) { VIR_FREE(tty); @@ -1167,8 +1156,7 @@ static int lxcContainerMountFSBind(virDomainFSDefPtr fs, VIR_DEBUG("src=%s dst=%s", fs->src->path, fs->dst); - if (virAsprintf(&src, "%s%s", srcprefix, fs->src->path) < 0) - goto cleanup; + virAsprintf(&src, "%s%s", srcprefix, fs->src->path); if (stat(fs->dst, &st) < 0) { if (errno != ENOENT) { @@ -1338,9 +1326,8 @@ static int lxcContainerMountFSBlockAuto(virDomainFSDefPtr fs, /* 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"); VIR_DEBUG("Open fslist %s", fslist); if (!(fp = fopen(fslist, "r"))) { @@ -1501,14 +1488,12 @@ static int lxcContainerMountFSBlock(virDomainFSDefPtr fs, VIR_DEBUG("src=%s dst=%s", fs->src->path, fs->dst); - if (virAsprintf(&src, "%s%s", srcprefix, fs->src->path) < 0) - goto cleanup; + virAsprintf(&src, "%s%s", srcprefix, fs->src->path); ret = lxcContainerMountFSBlockHelper(fs, src, srcprefix, sec_mount_options); VIR_DEBUG("Done mounting filesystem ret=%d", ret); - cleanup: VIR_FREE(src); return ret; } @@ -1522,9 +1507,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs, VIR_DEBUG("usage=%lld sec=%s", fs->usage, sec_mount_options); - if (virAsprintf(&data, - "size=%lld%s", fs->usage, sec_mount_options) < 0) - goto cleanup; + virAsprintf(&data, "size=%lld%s", fs->usage, sec_mount_options); if (virFileMakePath(fs->dst) < 0) { virReportSystemError(errno, @@ -1672,19 +1655,22 @@ static int lxcContainerUnmountForSharedRoot(const char *stateDir, /* 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; 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; #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 @@ -2246,9 +2232,8 @@ static int lxcContainerChild(void *data) const char *tty = argv->ttyPaths[0]; if (STRPREFIX(tty, "/dev/pts/")) tty += 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->name, + 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(virLXCControllerPtr ctrl, size_t loops = 0; pid_t pid; - if (!STRPREFIX(dev, "/dev/") || - virAsprintf(&pidpath, "/sys/devices/virtual/block/%s/pid", dev + 5) < 0) + if (!STRPREFIX(dev, "/dev/")) goto cleanup; + 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(virLXCControllerPtr ctrl) virNetServerServicePtr svc = NULL; char *sockpath; - if (virAsprintf(&sockpath, "%s/%s.sock", - LXC_STATE_DIR, ctrl->name) < 0) - return -1; + virAsprintf(&sockpath, "%s/%s.sock", LXC_STATE_DIR, ctrl->name); if (!(srv = virNetServerNew("LXC", 1, 0, 0, 0, 1, @@ -1435,16 +1434,14 @@ static int virLXCControllerSetupUserns(virLXCControllerPtr ctrl) } 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); if (virLXCControllerSetupUsernsMap(ctrl->def->idmap.uidmap, ctrl->def->idmap.nuidmap, uid_map) < 0) goto cleanup; - if (virAsprintf(&gid_map, "/proc/%d/gid_map", ctrl->initpid) < 0) - goto cleanup; + virAsprintf(&gid_map, "/proc/%d/gid_map", ctrl->initpid); if (virLXCControllerSetupUsernsMap(ctrl->def->idmap.gidmap, ctrl->def->idmap.ngidmap, @@ -1470,18 +1467,14 @@ static int virLXCControllerSetupDev(virLXCControllerPtr ctrl) mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager, ctrl->def); - 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); /* * tmpfs is limited to 64kb, since we only have device nodes in there * and don't want to DOS the entire OS RAM usage */ - if (virAsprintf(&opts, - "mode=755,size=65536%s", mount_options) < 0) - goto cleanup; + virAsprintf(&opts, "mode=755,size=65536%s", mount_options); if (virFileSetupDev(dev, opts) < 0) goto cleanup; @@ -1521,9 +1514,8 @@ static int virLXCControllerPopulateDevices(virLXCControllerPtr ctrl) /* Populate /dev/ with a few important bits */ for (i = 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); dev_t dev = makedev(devs[i].maj, devs[i].min); if (mknod(path, S_IFCHR, dev) < 0 || @@ -1561,19 +1553,13 @@ virLXCControllerSetupHostdevSubsysUSB(virDomainDefPtr vmDef, mode_t mode; virDomainHostdevSubsysUSBPtr usbsrc = &def->source.subsys.u.usb; - if (virAsprintf(&src, USB_DEVFS "/%03d/%03d", - usbsrc->bus, usbsrc->device) < 0) - goto cleanup; + virAsprintf(&src, USB_DEVFS "/%03d/%03d", usbsrc->bus, usbsrc->device); - 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); - if (virAsprintf(&dstdir, "%s/%03d/", vroot, usbsrc->bus) < 0) - goto cleanup; + virAsprintf(&dstdir, "%s/%03d/", vroot, usbsrc->bus); - if (virAsprintf(&dstfile, "%s/%03d", dstdir, usbsrc->device) < 0) - goto cleanup; + virAsprintf(&dstfile, "%s/%03d", dstdir, usbsrc->device); if (stat(src, &sb) < 0) { virReportSystemError(errno, @@ -1647,10 +1633,8 @@ virLXCControllerSetupHostdevCapsStorage(virDomainDefPtr vmDef, while (*(path + len) == '/') len++; - 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, '/')); if (stat(dev, &sb) < 0) { virReportSystemError(errno, @@ -1725,10 +1709,8 @@ virLXCControllerSetupHostdevCapsMisc(virDomainDefPtr vmDef, while (*(path + len) == '/') len++; - 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, '/')); if (stat(dev, &sb) < 0) { virReportSystemError(errno, @@ -1883,9 +1865,8 @@ static int virLXCControllerSetupDisk(virLXCControllerPtr ctrl, goto cleanup; } - 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); if (stat(def->src->path, &sb) < 0) { virReportSystemError(errno, @@ -2074,12 +2055,8 @@ lxcCreateTty(virLXCControllerPtr ctrl, int *ttymaster, * 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 = ENOMEM; - goto cleanup; - } + virAsprintf(ttyName, "/dev/pts/%d", ptyno); + virAsprintf(ttyHostPath, "/%s/%s.devpts/%d", LXC_STATE_DIR, ctrl->def->name, ptyno); ret = 0; @@ -2135,11 +2112,8 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl) mount_options = virSecurityManagerGetMountOptions(ctrl->securityManager, ctrl->def); - 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); if (virFileMakePath(devpts) < 0) { virReportSystemError(errno, @@ -2155,9 +2129,8 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl) /* XXX should we support gid=X for X!=5 for distros which use * a different gid for tty? */ - if (virAsprintf(&opts, "newinstance,ptmxmode=0666,mode=0620,gid=%u%s", - ptsgid, NULLSTR_EMPTY(mount_options)) < 0) - goto cleanup; + virAsprintf(&opts, "newinstance,ptmxmode=0666,mode=0620,gid=%u%s", ptsgid, + NULLSTR_EMPTY(mount_options)); VIR_DEBUG("Mount devpts on %s type=tmpfs flags=0x%x, opts=%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; - if (virAsprintf(&file, - "/dev/%s", def->dst) < 0) - goto cleanup; + virAsprintf(&file, "/dev/%s", def->dst); if (lxcDomainAttachDeviceMknod(driver, 0700 | S_IFBLK, @@ -3975,9 +3973,7 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver, } usbsrc = &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->device); if (!(usb = virUSBDeviceNew(usbsrc->bus, usbsrc->device, NULL))) goto cleanup; @@ -4313,8 +4309,7 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm, def = vm->def->disks[idx]; src = virDomainDiskGetSource(def); - if (virAsprintf(&dst, "/dev/%s", def->dst) < 0) - goto cleanup; + virAsprintf(&dst, "/dev/%s", def->dst); if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -4452,9 +4447,7 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver, } usbsrc = &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->device); if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) { 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 = (virDomainDefPtr)context->private_data; memset(stbuf, 0, sizeof(struct stat)); - if (virAsprintf(&mempath, "/proc/%s", path) < 0) - return -errno; + virAsprintf(&mempath, "/proc/%s", path); res = 0; @@ -251,8 +250,7 @@ static int lxcProcRead(const char *path G_GNUC_UNUSED, struct fuse_context *context = NULL; virDomainDefPtr def = NULL; - if (virAsprintf(&hostpath, "/proc/%s", path) < 0) - return -errno; + virAsprintf(&hostpath, "/proc/%s", path); context = fuse_get_context(); def = (virDomainDefPtr)context->private_data; @@ -307,9 +305,7 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def) if (virMutexInit(&fuse->lock) < 0) goto cleanup2; - 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); 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 = virObjectLockableNew(virLXCMonitorClass))) return NULL; - if (virAsprintf(&sockpath, "%s/%s.sock", - socketdir, vm->def->name) < 0) - goto error; + virAsprintf(&sockpath, "%s/%s.sock", socketdir, vm->def->name); if (!(mon->client = 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; if (fstab->dst[0] != '/') { - if (virAsprintf(&dst, "/%s", fstab->dst) < 0) - goto cleanup; + virAsprintf(&dst, "/%s", fstab->dst); } else { dst = 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); } hostdev->source.caps.u.net.ip.ips = data->ips; @@ -950,8 +948,7 @@ lxcBlkioDeviceWalkCallback(const char *name, virConfValuePtr value, void *data) goto cleanup; } - if (virAsprintf(&path, "/dev/block/%s", parts[0]) < 0) - goto cleanup; + virAsprintf(&path, "/dev/block/%s", parts[0]); /* 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 = NULL; - if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name) < 0) - return; + virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def->name); if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR) VIR_WARN("Failed to remove domain XML for %s: %s", @@ -419,10 +418,8 @@ static int virLXCProcessSetupNamespaceName(virConnectPtr conn, int ns_type, cons goto cleanup; } - 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]); if ((fd = open(path, O_RDONLY)) < 0) { virReportSystemError(errno, @@ -443,10 +440,7 @@ static int virLXCProcessSetupNamespacePID(int ns_type, const char *name) int fd; char *path; - 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 = 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; } - if (virAsprintf(&path, "%s/netns/%s", RUNSTATEDIR, name) < 0) - return -1; + virAsprintf(&path, "%s/netns/%s", RUNSTATEDIR, name); fd = open(path, O_RDONLY); VIR_FREE(path); if (fd < 0) { @@ -632,8 +625,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn, /* 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 = -1; - if (virAsprintf(&path, "/proc/%lld/ns/%s", - (long long)pid, nsname) < 0) - goto cleanup; + virAsprintf(&path, "/proc/%lld/ns/%s", (long long)pid, nsname); if (stat(path, &sb) < 0) { virReportSystemError(errno, @@ -984,9 +974,7 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, for (i = 0; i < VIR_LXC_DOMAIN_NAMESPACE_LAST; i++) { if (nsInheritFDs[i] > 0) { char *tmp = 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 = res; } - if (virAsprintf(&logfile, "%s/%s.log", - cfg->logDir, vm->def->name) < 0) - goto cleanup; + virAsprintf(&logfile, "%s/%s.log", cfg->logDir, vm->def->name); if (!(pidfile = virPidFileBuildPath(cfg->stateDir, vm->def->name))) goto cleanup; @@ -1358,8 +1344,7 @@ int virLXCProcessStart(virConnectPtr conn, vm->def->consoles[i]->source->data.file.path = ttyPath; 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); } VIR_DEBUG("Setting up Interfaces"); -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list