From nobody Mon Feb 9 01:50:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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=1571752761; cv=none; d=zoho.com; s=zohoarc; b=RdHRP5FoIQB1ecj3VwiyRPCI1lMgmi1fb3ZPMbWH73pry3kuaU3nhdLxRjmsd+4ASd8bdz9fkfGbjNlrTtDhS0jj3gHKaRNDSaG/HtR8fgHLxovzSwfT2PANKlZDf0p0zdhGy3NwyWn2To26kQe4oU2NQWsTYfs3VBSupixhmOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571752761; 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=0gZfrdlAOxFy5Pf702OoLRlu1kvYMSNddsenmML9Xq8=; b=LNvYsLGJwxPftRRv9uZZlEOFRVll4jD2rD3+pmmbI5SoiDqL222RJcvuGs+/zOvxTfPHefvwD/n9eIX6PWLrdZQ+MGNoxS/VTY3zxGJNF6PST0jT6b4LZT0hjLpcy22TebmDngmJdv0Dz8cZfUoBKqdeKeS/SD61QeEc6QlKK48= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1571752761632903.8957662136738; Tue, 22 Oct 2019 06:59:21 -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-233-j6ExWGCSOzm0Jnro2gtaWQ-1; Tue, 22 Oct 2019 09:59:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CBB605EF; Tue, 22 Oct 2019 13:59:12 +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 A37BC60166; Tue, 22 Oct 2019 13:59:12 +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 5F5C81800B74; Tue, 22 Oct 2019 13:59:12 +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 x9MDxB2l001888 for ; Tue, 22 Oct 2019 09:59:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7BE766012E; Tue, 22 Oct 2019 13:59:11 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04B1E60466 for ; Tue, 22 Oct 2019 13:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571752760; 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=0gZfrdlAOxFy5Pf702OoLRlu1kvYMSNddsenmML9Xq8=; b=L2cnLKp1oxdoRcebHlcvDZasc1PR3iVnpwLX6wpSI0C9rrfYCK9YLOkRDnfmQVBF1I/kb5 cD1pS4tY37CrW3UYFC9BwUiBpu1w04RLIbFDCg+aVv/hfQynrlgABkGMMbeitDzOl5owMa IDWywJrXZfgGOXqnJugLzrbxOYicIkw= From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 22 Oct 2019 15:57:31 +0200 Message-Id: <019421e919497aad3bfc3a863be9d8f8d8ce9b3a.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 27/75] vbox: 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.11 X-MC-Unique: j6ExWGCSOzm0Jnro2gtaWQ-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/vbox/vbox_XPCOMCGlue.c | 3 +- src/vbox/vbox_common.c | 62 +++++++++++++++-------------------- src/vbox/vbox_network.c | 13 +++----- src/vbox/vbox_snapshot_conf.c | 18 ++++------ src/vbox/vbox_storage.c | 5 ++- src/vbox/vbox_tmpl.c | 32 ++++++++---------- 6 files changed, 53 insertions(+), 80 deletions(-) diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index a20b1c2a36..09768d5d38 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -85,8 +85,7 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreM= issing, PFNVBOXGETXPCOMCFUNCTIONS pfnGetFunctions; =20 if (dir !=3D NULL) { - if (virAsprintf(&name, "%s/%s", dir, DYNLIB_NAME) < 0) - return -1; + virAsprintf(&name, "%s/%s", dir, DYNLIB_NAME); =20 if (!virFileExists(name)) { if (!ignoreMissing) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 475b3a3147..6ffa43addc 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1770,13 +1770,12 @@ vboxAttachUSB(virDomainDefPtr def, vboxDriverPtr da= ta, IMachine *machine) /* Zero pad for nice alignment when fewer than 9999 * devices. */ - if (virAsprintf(&filtername, "filter%04zu", i) >=3D 0) { - VBOX_UTF8_TO_UTF16(filtername, &filternameUtf16); - VIR_FREE(filtername); - gVBoxAPI.UIUSBCommon.CreateDeviceFilter(USBCommon, - filternameUtf16, - &filter); - } + virAsprintf(&filtername, "filter%04zu", i); + VBOX_UTF8_TO_UTF16(filtername, &filternameUtf16); + VIR_FREE(filtername); + gVBoxAPI.UIUSBCommon.CreateDeviceFilter(USBCommon, + filternameUtf16, + &filter); VBOX_UTF16_FREE(filternameUtf16); =20 if (!filter) @@ -2127,10 +2126,9 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMa= chine *machine, vboxIID *iid if (guiPresent) { if (guiDisplay) { char *displayutf8; - if (virAsprintf(&displayutf8, "DISPLAY=3D%s", guiDisplay) >=3D= 0) { - VBOX_UTF8_TO_UTF16(displayutf8, &env); - VIR_FREE(displayutf8); - } + virAsprintf(&displayutf8, "DISPLAY=3D%s", guiDisplay); + VBOX_UTF8_TO_UTF16(displayutf8, &env); + VIR_FREE(displayutf8); VIR_FREE(guiDisplay); } =20 @@ -2140,10 +2138,9 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMa= chine *machine, vboxIID *iid if (sdlPresent) { if (sdlDisplay) { char *displayutf8; - if (virAsprintf(&displayutf8, "DISPLAY=3D%s", sdlDisplay) >=3D= 0) { - VBOX_UTF8_TO_UTF16(displayutf8, &env); - VIR_FREE(displayutf8); - } + virAsprintf(&displayutf8, "DISPLAY=3D%s", sdlDisplay); + VBOX_UTF8_TO_UTF16(displayutf8, &env); + VIR_FREE(displayutf8); VIR_FREE(sdlDisplay); } =20 @@ -4619,8 +4616,7 @@ vboxSnapshotRedefine(virDomainPtr dom, } VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName); =20 - if (virAsprintf(&nameTmpUse, "%s.vbox", machineName) < 0) - goto cleanup; + virAsprintf(&nameTmpUse, "%s.vbox", machineName); machineLocationPath =3D virStringReplace(settingsFilePath_Utf8, nameTm= pUse, ""); if (machineLocationPath =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -4636,9 +4632,8 @@ vboxSnapshotRedefine(virDomainPtr dom, goto cleanup; } if (snapshotMachineDesc->currentSnapshot !=3D NULL) { - if (virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", machineLo= cationPath, - snapshotMachineDesc->currentSnapshot) < 0) - goto cleanup; + virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", + machineLocationPath, snapshotMachineDesc->currentSnaps= hot); snapshotFileExists =3D virFileExists(currentSnapshotXmlFilePath); } =20 @@ -5206,8 +5201,8 @@ vboxSnapshotRedefine(virDomainPtr dom, vboxIIDUnalloc(&parentiid); VBOX_UTF8_TO_UTF16("VDI", &formatUtf16); =20 - if (virAsprintf(&newLocationUtf8, "%sfakedisk-%d.vdi", machine= LocationPath, it) < 0) - goto cleanup; + virAsprintf(&newLocationUtf8, "%sfakedisk-%d.vdi", + machineLocationPath, it); VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation); rc =3D gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj, formatUtf16, @@ -5305,8 +5300,8 @@ vboxSnapshotRedefine(virDomainPtr dom, * next define. This file is saved as "'machineLocation'/snapshot-= 'uuid'.xml" */ VIR_FREE(currentSnapshotXmlFilePath); - if (virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", machineLo= cationPath, snapshotMachineDesc->currentSnapshot) < 0) - goto cleanup; + virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", + machineLocationPath, snapshotMachineDesc->currentSnaps= hot); char *snapshotContent =3D virDomainSnapshotDefFormat(NULL, def, data->caps, data->xmlopt, @@ -6893,8 +6888,7 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) goto cleanup; } VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName); - if (virAsprintf(&nameTmpUse, "%s.vbox", machineName) < 0) - goto cleanup; + virAsprintf(&nameTmpUse, "%s.vbox", machineName); machineLocationPath =3D virStringReplace(settingsFilepath, nameTmpUse,= ""); if (machineLocationPath =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -6978,9 +6972,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapsho= tPtr snapshot) VBOX_UTF16_FREE(locationUtf16); VBOX_UTF8_TO_UTF16("VDI", &formatUtf16); =20 - if (virAsprintf(&newLocationUtf8, "%sfakedisk-%s-%d.vdi", - machineLocationPath, def->parent.parent_na= me, it) < 0) - goto cleanup; + virAsprintf(&newLocationUtf8, "%sfakedisk-%s-%d.vdi", + machineLocationPath, def->parent.parent_name, = it); VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation); rc =3D gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj, formatUtf16, @@ -7383,17 +7376,14 @@ vboxDomainScreenshot(virDomainPtr dom, return NULL; } =20 - if ((privileged && virAsprintf(&cacheDir, "%s/cache/libvirt", LOCALSTA= TEDIR) < 0) || - (!privileged && !(cacheDir =3D virGetUserCacheDirectory()))) { + if (privileged) { + virAsprintf(&cacheDir, "%s/cache/libvirt", LOCALSTATEDIR); + } else if (!(cacheDir =3D virGetUserCacheDirectory())) { VBOX_RELEASE(machine); return NULL; } =20 - if (virAsprintf(&tmp, "%s/vbox.screendump.XXXXXX", cacheDir) < 0) { - VBOX_RELEASE(machine); - VIR_FREE(cacheDir); - return NULL; - } + virAsprintf(&tmp, "%s/vbox.screendump.XXXXXX", cacheDir); =20 if ((tmp_fd =3D mkostemp(tmp, O_CLOEXEC)) =3D=3D -1) { virReportSystemError(errno, _("mkostemp(\"%s\") failed"), tmp); diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 9e632ab709..a942587bcb 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -432,8 +432,8 @@ vboxNetworkDefineCreateXML(virConnectPtr conn, const ch= ar *xml, bool start) =20 VBOX_UTF16_TO_UTF8(networkInterfaceNameUtf16, &networkInterfaceNameUtf= 8); =20 - if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", networ= kInterfaceNameUtf8) < 0) - goto cleanup; + virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", + networkInterfaceNameUtf8); =20 VBOX_UTF8_TO_UTF16(networkNameUtf8, &networkNameUtf16); =20 @@ -588,8 +588,7 @@ vboxNetworkUndefineDestroy(virNetworkPtr network, bool = removeinterface) * show up in the net-list in virsh */ =20 - if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", networ= k->name) < 0) - goto cleanup; + virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", network->n= ame); =20 VBOX_UTF8_TO_UTF16(network->name, &networkInterfaceNameUtf16); =20 @@ -693,8 +692,7 @@ static int vboxNetworkCreate(virNetworkPtr network) * server by giving the machine static IP */ =20 - if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", networ= k->name) < 0) - goto cleanup; + virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", network->n= ame); =20 VBOX_UTF8_TO_UTF16(network->name, &networkInterfaceNameUtf16); =20 @@ -791,8 +789,7 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr networ= k, unsigned int flags) def->ips =3D ipdef; def->nips =3D 1; =20 - if (virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", networ= k->name) < 0) - goto cleanup; + virAsprintf(&networkNameUtf8, "HostInterfaceNetworking-%s", network->n= ame); =20 VBOX_UTF8_TO_UTF16(network->name, &networkInterfaceNameUtf16); =20 diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 8cdfb35357..8c92d8797b 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -84,8 +84,7 @@ virVBoxSnapshotConfCreateVBoxSnapshotConfHardDiskPtr(xmlN= odePtr diskNode, } if (location[0] !=3D '/') { /*The location is a relative path, so we must change it into an ab= solute one. */ - if (virAsprintf(&tmp, "%s%s", machineLocation, location) < 0) - goto cleanup; + virAsprintf(&tmp, "%s%s", machineLocation, location); hardDisk->location =3D g_strdup(tmp); } else { hardDisk->location =3D g_strdup(location); @@ -331,8 +330,7 @@ virVBoxSnapshotConfCreateHardDiskNode(virVBoxSnapshotCo= nfHardDiskPtr hardDisk) size_t i =3D 0; char *uuid =3D NULL; xmlNodePtr ret =3D xmlNewNode(NULL, BAD_CAST "HardDisk"); - if (virAsprintf(&uuid, "{%s}", hardDisk->uuid) < 0) - goto cleanup; + virAsprintf(&uuid, "{%s}", hardDisk->uuid); =20 if (xmlNewProp(ret, BAD_CAST "uuid", BAD_CAST uuid) =3D=3D NULL) goto cleanup; @@ -378,8 +376,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, char **secondRegex =3D NULL; int secondRegexResult =3D 0; =20 - if (virAsprintf(&uuid, "{%s}", snapshot->uuid) < 0) - goto cleanup; + virAsprintf(&uuid, "{%s}", snapshot->uuid); =20 if (xmlNewProp(node, BAD_CAST "uuid", BAD_CAST uuid) =3D=3D NULL) goto cleanup; @@ -400,8 +397,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, goto cleanup; if (secondRegexResult < 1) goto cleanup; - if (virAsprintf(&timeStamp, "%sT%sZ", firstRegex[0], secondRegex[0]) <= 0) - goto cleanup; + virAsprintf(&timeStamp, "%sT%sZ", firstRegex[0], secondRegex[0]); =20 if (xmlNewProp(node, BAD_CAST "timeStamp", BAD_CAST timeStamp) =3D=3D = NULL) goto cleanup; @@ -1073,8 +1069,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chinePtr machine, } =20 if (machine->currentSnapshot !=3D NULL) { - if (virAsprintf(¤tSnapshot, "{%s}", machine->currentSnapshot= ) < 0) - goto cleanup; + virAsprintf(¤tSnapshot, "{%s}", machine->currentSnapshot); if (!xmlNewProp(machineNode, BAD_CAST "currentSnapshot", BAD_CAST = currentSnapshot)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Error in xmlNewProp")); @@ -1111,8 +1106,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chinePtr machine, if (secondRegexResult < 1) goto cleanup; =20 - if (virAsprintf(&timeStamp, "%sT%sZ", firstRegex[0], secondRegex[0]) <= 0) - goto cleanup; + virAsprintf(&timeStamp, "%sT%sZ", firstRegex[0], secondRegex[0]); if (!xmlNewProp(machineNode, BAD_CAST "lastStateChange", BAD_CAST time= Stamp)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("Error in xmlNewProp")); diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index c7bea2c219..8cd1b20628 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -448,9 +448,8 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, } =20 /* If target.path isn't given, use default path ~/.VirtualBox/image_na= me */ - if (def->target.path =3D=3D NULL && - virAsprintf(&def->target.path, "%s/.VirtualBox/%s", virGetUserDire= ctory(), def->name) < 0) - goto cleanup; + if (!def->target.path) + virAsprintf(&def->target.path, "%s/.VirtualBox/%s", virGetUserDire= ctory(), def->name); VBOX_UTF8_TO_UTF16(def->target.path, &hddNameUtf16); =20 if (!hddFormatUtf16 || !hddNameUtf16) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 72011199cf..88e7deaea0 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -613,29 +613,23 @@ _virtualboxCreateMachine(vboxDriverPtr data, virDomai= nDefPtr def, IMachine **mac { vboxIID iid =3D VBOX_IID_INITIALIZER; PRUnichar *machineNameUtf16 =3D NULL; + char *createFlags =3D NULL; + PRUnichar *createFlagsUtf16 =3D NULL; nsresult rc =3D -1; =20 VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16); vboxIIDFromUUID(&iid, def->uuid); - { - char *createFlags =3D NULL; - PRUnichar *createFlagsUtf16 =3D NULL; - - if (virAsprintf(&createFlags, - "UUID=3D%s,forceOverwrite=3D0", uuidstr) < 0) - goto cleanup; - VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16); - rc =3D data->vboxObj->vtbl->CreateMachine(data->vboxObj, - NULL, - machineNameUtf16, - 0, - nsnull, - nsnull, - createFlagsUtf16, - machine); - cleanup: - VIR_FREE(createFlags); - } + virAsprintf(&createFlags, "UUID=3D%s,forceOverwrite=3D0", uuidstr); + VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16); + rc =3D data->vboxObj->vtbl->CreateMachine(data->vboxObj, + NULL, + machineNameUtf16, + 0, + nsnull, + nsnull, + createFlagsUtf16, + machine); + VIR_FREE(createFlags); VBOX_UTF16_FREE(machineNameUtf16); vboxIIDUnalloc(&iid); return rc; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list