From nobody Wed May 1 17:51: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=1636730575; cv=none; d=zohomail.com; s=zohoarc; b=eUulhgoFGtgzFqpKNHuVssTgAu+VAx+Yjl9BIXRs22ukQ8emBYXreYRKJwexMbo4it+pTP8Nc7h11HF36a1G3qisOz0D6mbjhnZifNrG4k4W0LBgiHg+e0a9nK0nwPr9p5muDT7p1AtNiApR+txizTtD5/+iQwrkw42TemO+wZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636730575; 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=+PlLVj9IJrwlhJ7bsMPHIvq42R9XishmtBsgE2ZYUow=; b=MDi3oDbDD30L0hI6kuzO2et/cFyx3QLiiee806y8swPU96ao/i8Sy1lqaHAwbxxGN6++kYu10IQDapNXYDSPHjPvdLJ1ZHO+CPx6iC96hLb9ZWT1yniRoeyAFBiBnAhjYSDD/wJ/cXjy0WA9cv4bVLXbYVWSUsWLOWLXggSVSlY= 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 1636730574730625.7160977482278; Fri, 12 Nov 2021 07:22:54 -0800 (PST) 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-96-pDAGm4IvOg63ECkPEFkfRQ-1; Fri, 12 Nov 2021 10:22:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3CE2425C8; Fri, 12 Nov 2021 15:22:46 +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 5E8211002391; Fri, 12 Nov 2021 15:22:46 +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 D80D74E9F5; Fri, 12 Nov 2021 15:22:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ACFMh4u014361 for ; Fri, 12 Nov 2021 10:22:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7871D60C4A; Fri, 12 Nov 2021 15:22:43 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id F33D760C17 for ; Fri, 12 Nov 2021 15:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636730573; 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=+PlLVj9IJrwlhJ7bsMPHIvq42R9XishmtBsgE2ZYUow=; b=W+dVAjvJlHCHFYZF7L04PKsgvurbZ2mi19hbejFhGb/w8j0WpTrlRUnVoi+d28dnN4CYGZ w51Gp71D/5NQ1PyQYkDz0BHmb+Ftxy2Rd5Dho6oBRbM++N2g0A3joG8HHXr4ePItHvTU8X gerY6gd1gGpo4uFyvUBPGQWk8jbSZ/E= X-MC-Unique: pDAGm4IvOg63ECkPEFkfRQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] virNetDevVPortProfileParse: Use g_autofree Date: Fri, 12 Nov 2021 16:22:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.22 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: 1636730577130100001 Content-Type: text/plain; charset="utf-8" Explicit calls to VIR_FREE() can be dropped then. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Krist=C3=ADna Hanicov=C3=A1 --- src/conf/netdev_vport_profile_conf.c | 30 ++++++++++------------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_p= rofile_conf.c index d98ce098df..dfffc4dd70 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -29,14 +29,14 @@ virNetDevVPortProfile * virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags) { - char *virtPortType; - char *virtPortManagerID =3D NULL; - char *virtPortTypeID =3D NULL; - char *virtPortTypeIDVersion =3D NULL; - char *virtPortInstanceID =3D NULL; - char *virtPortProfileID =3D NULL; - char *virtPortInterfaceID =3D NULL; - virNetDevVPortProfile *virtPort =3D NULL; + g_autofree char *virtPortType =3D NULL; + g_autofree char *virtPortManagerID =3D NULL; + g_autofree char *virtPortTypeID =3D NULL; + g_autofree char *virtPortTypeIDVersion =3D NULL; + g_autofree char *virtPortInstanceID =3D NULL; + g_autofree char *virtPortProfileID =3D NULL; + g_autofree char *virtPortInterfaceID =3D NULL; + g_autofree virNetDevVPortProfile *virtPort =3D NULL; xmlNodePtr cur =3D node->children; =20 virtPort =3D g_new0(virNetDevVPortProfile, 1); @@ -178,20 +178,10 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned = int flags) if (virNetDevVPortProfileCheckNoExtras(virtPort) < 0) goto error; =20 - cleanup: - VIR_FREE(virtPortManagerID); - VIR_FREE(virtPortTypeID); - VIR_FREE(virtPortTypeIDVersion); - VIR_FREE(virtPortInstanceID); - VIR_FREE(virtPortProfileID); - VIR_FREE(virtPortType); - VIR_FREE(virtPortInterfaceID); - - return virtPort; + return g_steal_pointer(&virtPort); =20 error: - VIR_FREE(virtPort); - goto cleanup; + return NULL; } =20 =20 --=20 2.32.0 From nobody Wed May 1 17:51: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=1636730584; cv=none; d=zohomail.com; s=zohoarc; b=kvx+Azirp6FlvpifH8cMsrczjptC59g0uXKzmQmVIgYtFR6n+Kh+kKdk47lxyBs6v76YJcFHzHoIYsK9u1sFqbfSzW/X2TmMxEAoDLw5u2i0T5AjbbMbuRQfQanep3w6nBSqTwP3Iurm3wkFhLSU7YyiSJP8hzozVeiOZ5jo22s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636730584; 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=OlbREZKyJ33bqJ5s55LuExLBdznEi73vYtz7ALFcLTE=; b=h5CitD6ROtwGprUrpSwz7Lpf3B1LysqbXef4FljdXxOhStVWyL0R3OasuojsgXZe9XkINJv1Sn39CsX1ehQPL/9Ixm7mN9J0URRB10q/eqVx+O8q6yqdspYAxk2MuvVg1kMzD1BbwcevyZLnM/n0ZI0s0IIEiEiLL4gWhR81pa0= 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 1636730584526289.46683394468846; Fri, 12 Nov 2021 07:23:04 -0800 (PST) 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-206-birSCH0IPd6AHAJu8kmXLg-1; Fri, 12 Nov 2021 10:22:59 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFF02100CFB3; Fri, 12 Nov 2021 15:22:54 +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 CBFE55D6D5; Fri, 12 Nov 2021 15:22:54 +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 9C84A1832DD6; Fri, 12 Nov 2021 15:22:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ACFMiwf014373 for ; Fri, 12 Nov 2021 10:22:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4BEC560C4A; Fri, 12 Nov 2021 15:22:44 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6BB060C17 for ; Fri, 12 Nov 2021 15:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636730583; 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=OlbREZKyJ33bqJ5s55LuExLBdznEi73vYtz7ALFcLTE=; b=a8/czDLY72uMPsOl5JO8Ill+nxabdb/CxIjmYszyYCpsEMJ91NqWC5fuM2RFqJJ+dIXd2s Lz30NfXImjifTfOqzx7B5JSsWLCjag5c+AzKItAeyWtImlATyoEnqJ6GRmjqtyXwrjd8cT /+xsqDAt9BKmoSaLmAmv5y2m2MjoZBc= X-MC-Unique: birSCH0IPd6AHAJu8kmXLg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] examples/dommigrate: Don't set retval in usage() Date: Fri, 12 Nov 2021 16:22:33 +0100 Message-Id: <8b03dcef2bf2dac3f42490472a4273db1757576d.1636730459.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.15 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: 1636730584913100003 Content-Type: text/plain; charset="utf-8" The usage() function should just print expected arguments. Make the function return void then. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Krist=C3=ADna Hanicov=C3=A1 --- examples/c/domain/dommigrate.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/c/domain/dommigrate.c b/examples/c/domain/dommigrate.c index 60cfb3fb83..b1641efb9a 100644 --- a/examples/c/domain/dommigrate.c +++ b/examples/c/domain/dommigrate.c @@ -26,11 +26,10 @@ #include =20 =20 -static int -usage(char *prgn, int ret) +static void +usage(char *prgn) { printf("Usage: %s \n", prgn); - return ret; } =20 int @@ -42,7 +41,7 @@ main(int argc, char *argv[]) virDomainPtr dom =3D NULL; =20 if (argc < 4) { - ret =3D usage(argv[0], 1); + usage(argv[0]); goto out; } =20 --=20 2.32.0 From nobody Wed May 1 17:51: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=1636730585; cv=none; d=zohomail.com; s=zohoarc; b=MELZaHzyiVVrp/onrRS6kCGwx6uS6XL2r63kiT7HO2D50YR3BGWLNe01kYpjb3paFOxD0nCNQ9D5ir2gKpfGrVzLpLYhQzgAMrZA+R9ypuZqZLyvDrBA31htlZLrRQlJ5vbwsA0JHsCoDxG2AYs/TIlUCMWz6pbJpbJ08NDLIv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636730585; 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=RuZlbqUM1k3kPabzaWhPWHiWOneNSmDQjWux5PspNIc=; b=aGkQsSJgT+Cl2iN+eON6/PdcgKnGmTcuKDO5kPXldOVunagR+Y8L7SQPvHVMrIhzpzGJoQh4MEJdEE59XECp/w7/wj5QeI4/2jAtUkrGR6elY8KiQ75Bzy26NviupxstgpE8NuhkYUQYCf4YRQJ5zN4dQ0FDwQ6232kWirMs358= 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 1636730585468276.3137078287532; Fri, 12 Nov 2021 07:23:05 -0800 (PST) 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-66-OxdcH2DiM96zMg7q1ZD2tA-1; Fri, 12 Nov 2021 10:23:02 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4C9019251A1; Fri, 12 Nov 2021 15:22:57 +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 A645960C05; Fri, 12 Nov 2021 15:22:57 +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 7B5511832DD9; Fri, 12 Nov 2021 15:22:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ACFMjTM014387 for ; Fri, 12 Nov 2021 10:22:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1F59460C5F; Fri, 12 Nov 2021 15:22:45 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A34660C4A for ; Fri, 12 Nov 2021 15:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636730584; 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=RuZlbqUM1k3kPabzaWhPWHiWOneNSmDQjWux5PspNIc=; b=X0Ywi3iGMz+NTU5dkEkxfMOWtl7NKNaqDSIWya3vq4oRGJDdFwwEUjYFAcG5XJ1bPXxjQO bso6Sj38IB96BkzhprbzQv1MFj+nXt3Jj66TjByW3DiThBZYydhpC7nux/kTSWwq2Hg7kq knVO5iFeC3zgYZi42F0U6n+qMYEuyYo= X-MC-Unique: OxdcH2DiM96zMg7q1ZD2tA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] examples/dommigrate: Make retval portable Date: Fri, 12 Nov 2021 16:22:34 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.12 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: 1636730587107100001 Content-Type: text/plain; charset="utf-8" Currently, the dommigrate example returns 0 or 1 for success or failure state, respectively. Except for a few cases where it forgot to change the @ret variable just before jumping onto the 'cleanup' label. Making the code follow our usual pattern (initialize @ret to an error value and set it to success value only at the end) fixes those cases. Also, using EXIT_SUCCESS and EXIT_FAILURE is more portable (even though on my system they are just an alias to values the example already uses). Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Krist=C3=ADna Hanicov=C3=A1 --- examples/c/domain/dommigrate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/c/domain/dommigrate.c b/examples/c/domain/dommigrate.c index b1641efb9a..3d32ada6d3 100644 --- a/examples/c/domain/dommigrate.c +++ b/examples/c/domain/dommigrate.c @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) { char *src_uri, *dst_uri, *domname; - int ret =3D 0; + int ret =3D EXIT_FAILURE; virConnectPtr conn =3D NULL; virDomainPtr dom =3D NULL; =20 @@ -52,7 +52,6 @@ main(int argc, char *argv[]) printf("Attempting to connect to the source hypervisor...\n"); conn =3D virConnectOpenAuth(src_uri, virConnectAuthPtrDefault, 0); if (!conn) { - ret =3D 1; fprintf(stderr, "No connection to the source hypervisor: %s.\n", virGetLastErrorMessage()); goto out; @@ -74,6 +73,7 @@ main(int argc, char *argv[]) } =20 printf("Migration finished with success.\n"); + ret =3D EXIT_SUCCESS; =20 cleanup: if (dom !=3D NULL) --=20 2.32.0 From nobody Wed May 1 17:51:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1636730653; cv=none; d=zohomail.com; s=zohoarc; b=RLutMuSprrWL7JnAzcN39pLNuHVlB3NOCDkPKudu4VMv+y5vLWm5jdvLZ4XQIBCye+qZ8oUHigP/vYlu/p4FlWXdev2sRT79TOCKXsXNSMdfcu+ai7WJj4j3r55x8pZMOB6Hypu3kxLSZdFot8VkNRAQ40af3v0uO9/GzyUx1eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636730653; 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=kpyAzvRlfGq8UXNn1TSU+wmaH5reqNyCEcZ6uU6e3jk=; b=ZYAROgbE6JT08NcRbAMqZTgGZUEw7voUw52q5jOIyntks0aGt9Th0sHIM5YvGRmBnGuUN2XId9RxJQYlNKnNOVUeWPrhEG7qRrGnGLd5XsaSizlGoz+Mb4mFaWpVkj1v1msvN45CzzkXbhv77mxQdPXtvQT4ojaa2igEtcskyHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1636730653088550.1653074121361; Fri, 12 Nov 2021 07:24:13 -0800 (PST) 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-249-Ap39GcDTPeq3uH2nDE4H6A-1; Fri, 12 Nov 2021 10:23:00 -0500 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 CD50281C6DE; Fri, 12 Nov 2021 15:22:54 +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 AFFB16784A; Fri, 12 Nov 2021 15:22:54 +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 7EAF74EA30; Fri, 12 Nov 2021 15:22:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1ACFMjW3014396 for ; Fri, 12 Nov 2021 10:22:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id E768360C5F; Fri, 12 Nov 2021 15:22:45 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB3160C4A for ; Fri, 12 Nov 2021 15:22:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636730652; 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=kpyAzvRlfGq8UXNn1TSU+wmaH5reqNyCEcZ6uU6e3jk=; b=GnOUyZhjyW9ppAof39DLfgAOecMz5xdUUrAPeIF/Qe0dkFmy7mwqG5SQj25hbFfqWDtysJ kO6rV1aoQg65Nes7iDk7baO2jPR21GUiffnqvn82MjRo2iEZhzag8ubikdeUh/hoZJbm+B GEiBzUxrgeg0MDz5k1ruGYAO5KIf050= X-MC-Unique: Ap39GcDTPeq3uH2nDE4H6A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virsh: Remove unnecessary else branches Date: Fri, 12 Nov 2021 16:22:35 +0100 Message-Id: <334a7fbb4383df1ce173513ce9ecbb05ffa5f65e.1636730459.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.79 on 10.5.11.11 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: 1636730655599100001 Content-Type: text/plain; charset="utf-8" In a few cases we call a public API, wrapped in an if() statement with both branches written out explicitly. The error branch jumps onto cleanup label, while the successful prints out a message. Right after these ifs there's 'ret =3D true;' and the cleanup label. The code is a bit more readable if only the error branch is kept and printing happens at the same level as setting the ret variable. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Krist=C3=ADna Hanicov=C3=A1 --- tools/virsh-nodedev.c | 5 ++--- tools/virsh-volume.c | 32 +++++++++++++++----------------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 1ad8db7a3f..424865962f 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -1024,13 +1024,12 @@ cmdNodeDeviceUndefine(vshControl *ctl, const vshCmd= *cmd G_GNUC_UNUSED) if (!dev) goto cleanup; =20 - if (virNodeDeviceUndefine(dev, 0) =3D=3D 0) { - vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value= ); - } else { + if (virNodeDeviceUndefine(dev, 0) < 0) { vshError(ctl, _("Failed to undefine node device '%s'"), device_val= ue); goto cleanup; } =20 + vshPrintExtra(ctl, _("Undefined node device '%s'\n"), device_value); ret =3D true; cleanup: return ret; diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 4c8e841701..12773d900b 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -411,14 +411,14 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if ((vol =3D virStorageVolCreateXML(pool, buffer, flags))) { - vshPrintExtra(ctl, _("Vol %s created from %s\n"), - virStorageVolGetName(vol), from); - ret =3D true; - } else { + if (!(vol =3D virStorageVolCreateXML(pool, buffer, flags))) { vshError(ctl, _("Failed to create vol from %s"), from); + goto cleanup; } =20 + vshPrintExtra(ctl, _("Vol %s created from %s\n"), + virStorageVolGetName(vol), from); + ret =3D true; cleanup: return ret; } @@ -489,14 +489,13 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) =20 newvol =3D virStorageVolCreateXMLFrom(pool, buffer, inputvol, flags); =20 - if (newvol !=3D NULL) { - vshPrintExtra(ctl, _("Vol %s created from input vol %s\n"), - virStorageVolGetName(newvol), virStorageVolGetName(i= nputvol)); - } else { + if (!newvol) { vshError(ctl, _("Failed to create vol from %s"), from); goto cleanup; } =20 + vshPrintExtra(ctl, _("Vol %s created from input vol %s\n"), + virStorageVolGetName(newvol), virStorageVolGetName(input= vol)); ret =3D true; cleanup: return ret; @@ -1147,20 +1146,19 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (virStorageVolResize(vol, capacity, flags) =3D=3D 0) { - vshPrintExtra(ctl, - delta ? _("Size of volume '%s' successfully changed = by %s\n") - : _("Size of volume '%s' successfully changed to %s\= n"), - virStorageVolGetName(vol), capacityStr); - ret =3D true; - } else { + if (virStorageVolResize(vol, capacity, flags) < 0) { vshError(ctl, delta ? _("Failed to change size of volume '%s' by %s") : _("Failed to change size of volume '%s' to %s"), virStorageVolGetName(vol), capacityStr); - ret =3D false; + goto cleanup; } =20 + vshPrintExtra(ctl, + delta ? _("Size of volume '%s' successfully changed by %= s\n") + : _("Size of volume '%s' successfully changed to %s\n"), + virStorageVolGetName(vol), capacityStr); + ret =3D true; cleanup: return ret; } --=20 2.32.0