From nobody Mon Feb 9 19:53:22 2026 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=1681907299; cv=none; d=zohomail.com; s=zohoarc; b=H35ESQBZAGDRdn3NpP2BGWBe14lrmVF+clMw+mZ3GyaNcc7bsMHxiXE1qrCNtrvNAmLMuxuikXJMUJBA7mNRCbHqZu2N1IxBamZhrJIPu9dkS81z+QLvQ5S3wCxwiHB5mSO94MlHKiG2AiCuwPdU/cnXHuZuuWV9BmfOFn5IsD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907299; 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=olbgSJf75mkjQFe41L6peJmnrfQVs9O4OJ89sNkVPM8=; b=Y9+KYVCNEjMf2gW37ydZBc3pEm928IcoEd/sogK8jSRp9bLeE8SjunIoV8n9+YLaHbmCHV04cflsOmJSvuSRduwkK1iZuQ0gmlLSGGQeE+yPvv7cZ17FhhyHh18AbdwINFqmQRC1sEvUkERG9/PZngjdEbRvgsFQXncEM2+7zd4= 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 1681907299379361.0142537545562; Wed, 19 Apr 2023 05:28:19 -0700 (PDT) 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-240-ah_hvYc3PcehDARz6RaFnw-1; Wed, 19 Apr 2023 08:28:14 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 23F212814252; Wed, 19 Apr 2023 12:28:12 +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 9706B4014E80; Wed, 19 Apr 2023 12:28:11 +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 6398819465B1; Wed, 19 Apr 2023 12:28:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BFAE119465BD for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 355D0492B0E; Wed, 19 Apr 2023 12:04:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8DFB8492B07 for ; Wed, 19 Apr 2023 12:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907298; 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=olbgSJf75mkjQFe41L6peJmnrfQVs9O4OJ89sNkVPM8=; b=chYSX4Xyd7UUxu/V5D7Yt+gt9qVB31OLo7XNKBbbnakQmun44V3Sh4PIV55oKyqrQ4frIK En0pQB2F/AAZ4Uu6rU91WtlH+FzgsgHGqM12+64Zkl6tiiclhhuLURTVbq/Vszejift193 Iy4T0eX2KtKOoBg5EYcadUMGfIa1wjw= X-MC-Unique: ah_hvYc3PcehDARz6RaFnw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 02/25] util: virtypedparam: Use proper enum type for all switch() statements Date: Wed, 19 Apr 2023 14:04:19 +0200 Message-Id: <77c0948dd8416a018fbd09857c2614fe9beecbc6.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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.2 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: 1681907300251100001 Content-Type: text/plain; charset="utf-8" Ensure that all switch statements in this module use the proper type in switch() statements to ensure complier protections. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 0cca16053d..974ec51a79 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -170,7 +170,7 @@ virTypedParameterToString(virTypedParameterPtr param) { char *value =3D NULL; - switch (param->type) { + switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: value =3D g_strdup_printf("%d", param->value.i); break; @@ -192,6 +192,7 @@ virTypedParameterToString(virTypedParameterPtr param) case VIR_TYPED_PARAM_STRING: value =3D g_strdup(param->value.s); break; + case VIR_TYPED_PARAM_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %1$d for field %2$s"), @@ -204,7 +205,7 @@ virTypedParameterToString(virTypedParameterPtr param) static int virTypedParameterAssignValueVArgs(virTypedParameterPtr param, - int type, + virTypedParameterType type, va_list ap, bool copystr) { @@ -238,6 +239,7 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, if (!param->value.s) param->value.s =3D g_strdup(""); break; + case VIR_TYPED_PARAM_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected type %1$d for field %2$s"), type, @@ -559,7 +561,7 @@ virTypedParamsDeserialize(struct _virTypedParameterRemo= te *remote_params, } param->type =3D remote_param->value.type; - switch (param->type) { + switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: param->value.i =3D remote_param->value.remote_typed_param_value.i; @@ -587,6 +589,7 @@ virTypedParamsDeserialize(struct _virTypedParameterRemo= te *remote_params, case VIR_TYPED_PARAM_STRING: param->value.s =3D g_strdup(remote_param->value.remote_typed_p= aram_value.s); break; + case VIR_TYPED_PARAM_LAST: default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %1$d"), param->type); @@ -670,7 +673,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, * depending on the calling side, i.e. server or client */ val->field =3D g_strdup(param->field); val->value.type =3D param->type; - switch (param->type) { + switch ((virTypedParameterType) param->type) { case VIR_TYPED_PARAM_INT: val->value.remote_typed_param_value.i =3D param->value.i; break; @@ -692,6 +695,7 @@ virTypedParamsSerialize(virTypedParameterPtr params, case VIR_TYPED_PARAM_STRING: val->value.remote_typed_param_value.s =3D g_strdup(param->valu= e.s); break; + case VIR_TYPED_PARAM_LAST: default: virReportError(VIR_ERR_RPC, _("unknown parameter type: %1$d"), param->type); --=20 2.39.2