From nobody Thu Mar 28 16:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1630933995; cv=none; d=zohomail.com; s=zohoarc; b=HhD3o9YcFZn/CIwYWALVPcff2TUXJdxe5pqF4K6qpxwAjY2HiYl3/ofvOR7qlHCIMp9XVSCXeRO3zSRwkIsUpqWeK/6ajzS1gzqjo/MaBoJ17IUNB8iWxc/JEZ9DU2GKbDrJXrQcvyeiJxmpWdlBwKi4t70rRiLs76sEyoINul8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630933995; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=I1MNouDSC7fxYhhdIhx93M0OQIzSI4vyUE1myuPZtZY=; b=AWCFYfyG70FCMolFudv3HB5SJqP5qkInI8ZQ6TanW259C8AT0luKs+ugaEURe3oi0N9ra78Lo0mdeiwoBEKRz1vhoikKfv4HGs9s3FISxJOm8I5LymzvMwGTmXpU7zyHtqVXpq+7yob793VezJLNvJubHoffi7gjeC3vB1ep8Us= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630933995686555.7679242595999; Mon, 6 Sep 2021 06:13:15 -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-292-955zHgbFNvifHMaEgbStUQ-1; Mon, 06 Sep 2021 09:13:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA6FA835DE8; Mon, 6 Sep 2021 13:13:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BD1219711; Mon, 6 Sep 2021 13:13:07 +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 D33F04EA7A; Mon, 6 Sep 2021 13:13:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 186DD5D8027009 for ; Mon, 6 Sep 2021 09:13:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 429FE1F5; Mon, 6 Sep 2021 13:13:05 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id BFBB419711 for ; Mon, 6 Sep 2021 13:13:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630933994; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=I1MNouDSC7fxYhhdIhx93M0OQIzSI4vyUE1myuPZtZY=; b=ZI7pplTNaMpCGQX/62T9Z0itefoG0C8CWUaT1Vta3oZ99PWIkR2H04pr5Nf4Lhe/EqAryd ZYz0kbWDjPxckkjObUP2pGuIB+4E7dR5reBxR9hTAPgBTFH7TpCD1d11p+qF7tf+V8OuwR fp9YR3uFXlGmURg7bEqq6BnsW6L4Xf4= X-MC-Unique: 955zHgbFNvifHMaEgbStUQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu_driver: Don't check for g_strdup_printf() retval Date: Mon, 6 Sep 2021 15:12:59 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630933997647100001 Content-Type: text/plain; charset="utf-8" The g_strdup_printf() function can't fail really. There's no need to check for its return value. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_driver.c | 49 +++++++++--------------------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cbd48b1849..2ea67b941e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -357,13 +357,7 @@ qemuDomainSnapshotLoad(virDomainObj *vm, =20 priv =3D vm->privateData; =20 - if (!(snapDir =3D g_strdup_printf("%s/%s", baseDir, vm->def->name))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to allocate memory for " - "snapshot directory for domain %s"), - vm->def->name); - goto cleanup; - } + snapDir =3D g_strdup_printf("%s/%s", baseDir, vm->def->name); =20 VIR_INFO("Scanning for snapshots for domain %s in %s", vm->def->name, snapDir); @@ -379,11 +373,7 @@ qemuDomainSnapshotLoad(virDomainObj *vm, kill the whole process */ VIR_INFO("Loading snapshot file '%s'", entry->d_name); =20 - if (!(fullpath =3D g_strdup_printf("%s/%s", snapDir, entry->d_name= ))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to allocate memory for path")); - continue; - } + fullpath =3D g_strdup_printf("%s/%s", snapDir, entry->d_name); =20 if (virFileReadAll(fullpath, 1024*1024*1, &xmlStr) < 0) { /* Nothing we can do here, skip this one */ @@ -464,13 +454,7 @@ qemuDomainCheckpointLoad(virDomainObj *vm, virObjectLock(vm); priv =3D vm->privateData; =20 - if (!(chkDir =3D g_strdup_printf("%s/%s", baseDir, vm->def->name))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to allocate memory for " - "checkpoint directory for domain %s"), - vm->def->name); - goto cleanup; - } + chkDir =3D g_strdup_printf("%s/%s", baseDir, vm->def->name); =20 VIR_INFO("Scanning for checkpoints for domain %s in %s", vm->def->name, chkDir); @@ -486,11 +470,7 @@ qemuDomainCheckpointLoad(virDomainObj *vm, kill the whole process */ VIR_INFO("Loading checkpoint file '%s'", entry->d_name); =20 - if (!(fullpath =3D g_strdup_printf("%s/%s", chkDir, entry->d_name)= )) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Failed to allocate memory for path")); - continue; - } + fullpath =3D g_strdup_printf("%s/%s", chkDir, entry->d_name); =20 if (virFileReadAll(fullpath, 1024*1024*1, &xmlStr) < 0) { /* Nothing we can do here, skip this one */ @@ -626,8 +606,7 @@ qemuStateInitialize(bool privileged, if (!(qemu_driver->config =3D cfg =3D virQEMUDriverConfigNew(privilege= d, root))) goto error; =20 - if (!(driverConf =3D g_strdup_printf("%s/qemu.conf", cfg->configBaseDi= r))) - goto error; + driverConf =3D g_strdup_printf("%s/qemu.conf", cfg->configBaseDir); =20 if (virQEMUDriverConfigLoadFile(cfg, driverConf, privileged) < 0) goto error; @@ -2953,13 +2932,9 @@ qemuDomainSave(virDomainPtr dom, const char *path) static char * qemuDomainManagedSavePath(virQEMUDriver *driver, virDomainObj *vm) { - char *ret; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); =20 - if (!(ret =3D g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->nam= e))) - return NULL; - - return ret; + return g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->name); } =20 static int @@ -3461,8 +3436,7 @@ qemuDomainScreenshot(virDomainPtr dom, } } =20 - if (!(tmp =3D g_strdup_printf("%s/qemu.screendump.XXXXXX", cfg->cacheD= ir))) - goto endjob; + tmp =3D g_strdup_printf("%s/qemu.screendump.XXXXXX", cfg->cacheDir); =20 if ((tmp_fd =3D g_mkstemp_full(tmp, O_RDWR | O_CLOEXEC, S_IRUSR | S_IW= USR)) =3D=3D -1) { virReportSystemError(errno, _("g_mkstemp(\"%s\") failed"), tmp); @@ -5296,8 +5270,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriver *driver, bool threadAdded =3D false; bool objectAdded =3D false; =20 - if (!(alias =3D g_strdup_printf("iothread%u", iothread_id))) - return -1; + alias =3D g_strdup_printf("iothread%u", iothread_id); =20 if (qemuMonitorCreateObjectProps(&props, "iothread", alias, NULL) < 0) goto cleanup; @@ -5429,8 +5402,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriver *driver, int new_niothreads =3D 0; qemuMonitorIOThreadInfo **new_iothreads =3D NULL; =20 - if (!(alias =3D g_strdup_printf("iothread%u", iothread_id))) - return -1; + alias =3D g_strdup_printf("iothread%u", iothread_id); =20 qemuDomainObjEnterMonitor(driver, vm); =20 @@ -10716,8 +10688,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto endjob; =20 - if (!(tmp =3D g_strdup_printf("%s/qemu.mem.XXXXXX", cfg->cacheDir))) - goto endjob; + tmp =3D g_strdup_printf("%s/qemu.mem.XXXXXX", cfg->cacheDir); =20 /* Create a temporary filename. */ if ((fd =3D g_mkstemp_full(tmp, O_RDWR | O_CLOEXEC, S_IRUSR | S_IWUSR)= ) =3D=3D -1) { --=20 2.31.1