From nobody Mon Apr 29 03:51:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498652712761731.2024361102915; Wed, 28 Jun 2017 05:25:12 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4C0977F404; Wed, 28 Jun 2017 12:25:10 +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 22A7D89E54; Wed, 28 Jun 2017 12:25:10 +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 C0CA64A492; Wed, 28 Jun 2017 12:25:09 +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 v5SCNEAh010588 for ; Wed, 28 Jun 2017 08:23:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6144489E49; Wed, 28 Jun 2017 12:23:14 +0000 (UTC) Received: from andariel.redhat.com (ovpn-204-24.brq.redhat.com [10.40.204.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A6A289A9A; Wed, 28 Jun 2017 12:23:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4C0977F404 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4C0977F404 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 28 Jun 2017 14:23:09 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH] util: netdevbridge: Refactor error handling in virNetDevBridgeCreate 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Jun 2017 12:25:10 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Replace the switch statement with a simpler if statement. This also removes the fallthrough path that coverity was complaining about. Reviewed-by: John Ferlan --- src/util/virnetdevbridge.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index 11b03b426..cfb7ebae9 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -468,22 +468,17 @@ virNetDevBridgeCreate(const char *brname) if (resp->nlmsg_len < NLMSG_LENGTH(sizeof(*err))) goto malformed_resp; - switch (err->error) { - case 0: - break; - case -EOPNOTSUPP: + if (err->error < 0) { # if defined(HAVE_STRUCT_IFREQ) && defined(SIOCBRADDBR) - /* fallback to ioctl if netlink doesn't support creating - * bridges - */ - rc =3D virNetDevBridgeCreateWithIoctl(brname); - goto cleanup; + if (err->error =3D=3D -EOPNOTSUPP) { + /* fallback to ioctl if netlink doesn't support creating + * bridges + */ + rc =3D virNetDevBridgeCreateWithIoctl(brname); + goto cleanup; + } # endif - /* intentionally fall through if virNetDevBridgeCreateWithIoct= l() - * isn't available. - */ - ATTRIBUTE_FALLTHROUGH; - default: + virReportSystemError(-err->error, _("error creating bridge interface %s"), brname); --=20 2.12.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list