From nobody Mon Sep 16 19:41:01 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=1684154075; cv=none; d=zohomail.com; s=zohoarc; b=HyRYwW/CKkKpDWAG+FJ9Ox+44jlMln6WG/X1JavYVZLfFBG8RQeEYm0vLecjj2OF/WOro3uypkzTc0+PNs6XJXXUag2zUp5INzQPzumxAkudjY+Zs63a7oIfHTDYsv84NW29xiiZeObDImBGizza3Hu5sUWP/1S9J8vt2dTvIqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684154075; 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=b1IiTaxY0PiEpzhqHesxKKLPbCnb0vUo6s6/ZEkfKnY=; b=hFBwMI3RH7ihZuBzqg1DeY/YTTjDIer/HNCHd1m6h4CQ9mCbNdrFW6i4L9EiO5HfG+afGS0kJz9BQ5ln/Kglvy/jAV/B59+skfI0i5YfhM2p36nuQpqjuFzDFxKOuJffEl4qYOuXwl8jq2O6kmJX+10uPkLZqoJ9aIFvMQAAxjU= 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 1684154075471710.6773561077973; Mon, 15 May 2023 05:34:35 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-2CAbsC03MZGmAo9fs-EwLg-1; Mon, 15 May 2023 08:34:30 -0400 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 3FD0F182463B; Mon, 15 May 2023 12:34:17 +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 F13692024CDC; Mon, 15 May 2023 12:34:15 +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 D752919465A2; Mon, 15 May 2023 12:34:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DAE39194658C for ; Mon, 15 May 2023 12:34:14 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D0D301410F23; Mon, 15 May 2023 12:34:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A93414171B8 for ; Mon, 15 May 2023 12:34:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684154074; 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=b1IiTaxY0PiEpzhqHesxKKLPbCnb0vUo6s6/ZEkfKnY=; b=drY+vdtyflGNW3SXLnd10R2nFxjEr3b+2ihjsfR9zMZSCEmO2Bs+btXlee0ReElzJTxsr8 d29uiEWzDZdH+dl1h6VzadjkVMvtFWbt2q+NhCwuJdQxN9IeTN6EnGAKNPubPraV6caLgu PWG/6Ec+wccoY/PJhrFb7cQYQGxdQug= X-MC-Unique: 2CAbsC03MZGmAo9fs-EwLg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/3] virDomainBackupDefAssignStore: Restructure control flow Date: Mon, 15 May 2023 14:34:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1684154076519100005 Content-Type: text/plain; charset="utf-8" Return early for errors instead of using 'else' branches. Signed-off-by: Peter Krempa --- src/conf/backup_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 4a8c05dca9..013c08cd6e 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -422,17 +422,19 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDef = *disk, _("disk '%1$s' has no media"), disk->name); return -1; } - } else if (!disk->store) { - if (virStorageSourceGetActualType(src) =3D=3D VIR_STORAGE_TYPE_FIL= E) { - disk->store =3D virStorageSourceNew(); - disk->store->type =3D VIR_STORAGE_TYPE_FILE; - disk->store->path =3D g_strdup_printf("%s.%s", src->path, suff= ix); - } else { + } + + if (!disk->store) { + if (virStorageSourceGetActualType(src) !=3D VIR_STORAGE_TYPE_FILE)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("refusing to generate file name for disk '%1$= s'"), disk->name); return -1; } + + disk->store =3D virStorageSourceNew(); + disk->store->type =3D VIR_STORAGE_TYPE_FILE; + disk->store->path =3D g_strdup_printf("%s.%s", src->path, suffix); } return 0; --=20 2.40.1