From nobody Sun Feb 8 03:57:58 2026 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1518713604410753.1632760377458; Thu, 15 Feb 2018 08:53:24 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2461F6E784; Thu, 15 Feb 2018 16:53:23 +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 106705D741; Thu, 15 Feb 2018 16:53:14 +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 D6B01244A7; Thu, 15 Feb 2018 16:53:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1FGiDn3025957 for ; Thu, 15 Feb 2018 11:44:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id E18542024CAA; Thu, 15 Feb 2018 16:44:13 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 830492024CA8; Thu, 15 Feb 2018 16:44:13 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 15 Feb 2018 16:43:43 +0000 Message-Id: <20180215164347.11538-39-berrange@redhat.com> In-Reply-To: <20180215164347.11538-1-berrange@redhat.com> References: <20180215164347.11538-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 38/42] daemon: add default: case to all switch statements 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: , Content-Type: text/plain; charset="utf-8" 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 15 Feb 2018 16:53:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Even if the compiler has validated that all enum constants have case statements in a switch, it is not safe to omit a default: case statement. When assigning a value to a variable / struct field that is defined with an enum type, nothing prevents an invalid value being assigned. So defensive code must assume existance of invalid values and thus all switches should have a default: case. Signed-off-by: Daniel P. Berrang=C3=A9 --- daemon/libvirtd.c | 4 ++-- daemon/remote.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index c5bb12b8ce..4944633c57 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -290,9 +290,9 @@ static int daemonErrorLogFilter(virErrorPtr err, int pr= iority) case VIR_ERR_NO_SERVER: case VIR_ERR_NO_CLIENT: return VIR_LOG_DEBUG; + default: + return priority; } - - return priority; } =20 =20 diff --git a/daemon/remote.c b/daemon/remote.c index 6de4bd00d4..51740e7b10 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3288,6 +3288,10 @@ remoteDispatchAuthList(virNetServerPtr server, case VIR_NET_SERVER_SERVICE_AUTH_SASL: ret->types.types_val[0] =3D REMOTE_AUTH_SASL; break; + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected auth method %d"), auth); + goto cleanup; } =20 rv =3D 0; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list