From nobody Tue Dec 16 16:24:02 2025 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=1675869605; cv=none; d=zohomail.com; s=zohoarc; b=R8HiGuJLTD5gsvshsRwauMXGvAUmUu7xTuSEPpkgTTlEc5Dg60dSPnvenufYCYSnf9BnmUXjj8jk6LVY3I0DK/dsyjAbah8uzqOyA3k2iPMLrmvksZkAzdcHvvmr8wNqJyHWcleP1btl6B7KRYIPGp3aQvEwQg7PIDH/n4i0ORc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675869605; 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=ID+LrXA1eUWUGsB2wlA9MNK3VWfkRltDzCjRwLW3TTk=; b=AAwYmcUleZp0o/fNc78yzCPis3hmc0rphGwyHlWxlk1q2RcFNmJ9mT9nQjldt/ar+I/1VhTW9Q8q95pjOwDYNbUd+oKWOxgRT9wWu7RqTyfwLp6fSIBNNvPc8DcTZFLfn38L4VgLcSfgVyMHvuEI1xcrxjXILWg2Szyar9pL9HI= 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 167586960558782.17463861882118; Wed, 8 Feb 2023 07:20:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-466-jOMkNom9O1einmbz5dMepg-1; Wed, 08 Feb 2023 10:19:23 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1929238173DC; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 021022026D4B; Wed, 8 Feb 2023 15:19:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2423B194658F; Wed, 8 Feb 2023 15:19:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0091F19465BA for ; Wed, 8 Feb 2023 15:19:17 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E8464492B00; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.40.23.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E231492C3E for ; Wed, 8 Feb 2023 15:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675869604; 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=ID+LrXA1eUWUGsB2wlA9MNK3VWfkRltDzCjRwLW3TTk=; b=IQzQzqcE1+h1N6scRPdKYYyQgbYYPXbdKcOxYPFoHWbGlmXPqkvQYdrIOvtV4phd1PBAG+ 5VGXdI4aps24Mi4OFO/Wo+hFnfLAGOvowyjsbzM6f8HM0v7bmOvUKafKN4M11jafRutslB supSoTuhr4uB+nZkwinncToh3/e7qTE= X-MC-Unique: jOMkNom9O1einmbz5dMepg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/8] Drop checks for virURIFormat() retval Date: Wed, 8 Feb 2023 16:19:08 +0100 Message-Id: <2dc53c9f9df1044a79acf500a75e6e9fdceb4bb6.1675869425.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: 1675869607401100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The virURIFormat() function either returns a string, or aborts (on OOM). There's no way this function can return NULL (as of v7.2.0-rc1~277). Therefore, it doesn't make sense to check its retval against NULL. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/admin/libvirt-admin.c | 6 +----- src/libvirt-host.c | 10 +--------- src/qemu/qemu_block.c | 3 +-- src/qemu/qemu_migration.c | 3 +-- src/remote/remote_driver.c | 3 --- src/storage/storage_backend_gluster.c | 6 +----- src/util/viruri.c | 2 +- tests/viruritest.c | 3 +-- 8 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/admin/libvirt-admin.c b/src/admin/libvirt-admin.c index 6baaea4ff2..1786a283e5 100644 --- a/src/admin/libvirt-admin.c +++ b/src/admin/libvirt-admin.c @@ -427,17 +427,13 @@ virAdmConnectIsAlive(virAdmConnectPtr conn) char * virAdmConnectGetURI(virAdmConnectPtr conn) { - char *uri =3D NULL; VIR_DEBUG("conn=3D%p", conn); =20 virResetLastError(); =20 virCheckAdmConnectReturn(conn, NULL); =20 - if (!(uri =3D virURIFormat(conn->uri))) - virDispatchError(NULL); - - return uri; + return virURIFormat(conn->uri); } =20 /** diff --git a/src/libvirt-host.c b/src/libvirt-host.c index c02222346c..a2ba347d54 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -313,21 +313,13 @@ virConnectGetHostname(virConnectPtr conn) char * virConnectGetURI(virConnectPtr conn) { - char *name; VIR_DEBUG("conn=3D%p", conn); =20 virResetLastError(); =20 virCheckConnectReturn(conn, NULL); =20 - if (!(name =3D virURIFormat(conn->uri))) - goto error; - - return name; - - error: - virDispatchError(conn); - return NULL; + return virURIFormat(conn->uri); } =20 =20 diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index c218262691..4c06565e0f 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -407,8 +407,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSource *sr= c, if (!(uri =3D qemuBlockStorageSourceGetURI(src))) return NULL; =20 - if (!(uristr =3D virURIFormat(uri))) - return NULL; + uristr =3D virURIFormat(uri); =20 if (!onlytarget) { if (src->auth) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f36bb49be5..2720f0b083 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3777,8 +3777,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver, /* Send well-formed URI only if uri_in was well-formed */ if (well_formed_uri) { uri->port =3D port; - if (!(*uri_out =3D virURIFormat(uri))) - goto cleanup; + *uri_out =3D virURIFormat(uri); } else { *uri_out =3D g_strdup_printf("%s:%d", uri_in, port); } diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 9fc73f6d88..2e08ff246f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -843,9 +843,6 @@ doRemoteOpen(virConnectPtr conn, name =3D virURIFormat(&tmpuri); =20 VIR_FREE(tmpuri.query); - - if (!name) - goto failed; } } } else { diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 1fe21b4a2b..bdf91e8bd5 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -195,11 +195,7 @@ virStorageBackendGlusterSetMetadata(virStorageBackendG= lusterState *state, =20 tmp =3D state->uri->path; state->uri->path =3D g_strdup_printf("/%s", path); - if (!(vol->target.path =3D virURIFormat(state->uri))) { - VIR_FREE(state->uri->path); - state->uri->path =3D tmp; - return -1; - } + vol->target.path =3D virURIFormat(state->uri); VIR_FREE(state->uri->path); state->uri->path =3D tmp; =20 diff --git a/src/util/viruri.c b/src/util/viruri.c index 4afdd30c59..54db0bda06 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -194,7 +194,7 @@ virURIParse(const char *uri) * Wrapper for xmlSaveUri * * This function constructs back everything that @ref virURIParse - * changes after parsing + * changes after parsing. It aborts on error. * * @returns the constructed uri as a string */ diff --git a/tests/viruritest.c b/tests/viruritest.c index cd6ce57371..705e0d5c6e 100644 --- a/tests/viruritest.c +++ b/tests/viruritest.c @@ -118,8 +118,7 @@ static int testURIParse(const void *args) VIR_FREE(uri->query); uri->query =3D virURIFormatParams(uri); =20 - if (!(uristr =3D virURIFormat(uri))) - return -1; + uristr =3D virURIFormat(uri); =20 if (STRNEQ(uristr, data->uri_out)) { VIR_TEST_DEBUG("URI did not roundtrip, expect '%s', actual '%s'", --=20 2.39.1