From nobody Sat Feb 7 08:54:51 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 ARC-Seal: i=1; a=rsa-sha256; t=1568913219; cv=none; d=zoho.com; s=zohoarc; b=YQNKm8NQEW+LocAPTN1KAQKa+XjLdisTNFx3XhBkgJrkJ5Bpkj8g5ttWzQY0/Kr0it5bCKdkErecgIt7srvaNe2lgyy6dJvtykAUJawoiKo56LRhZ2KZmeX57QvjCpr9so//d81Vb2ZeFI0naPkXh6DOBTXwcOdAL5QEyGxWQxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568913219; 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:ARC-Authentication-Results; bh=NBLHt++VfykjWVy0SjYcrdoq7PBmP8uEhCMuhV1dyPI=; b=Hp4D/F1UtAlo+1GztTK64bOY2vl6FuRPgAk0ZkE2/TNUWJg/n3td/5HhClXF6xYXrR69h/x2wPONFI28uYsgoJ4AwP32ADmH+9u9GxO1b0QBl0XgC/p0Jy1gxhvNzVBob2EGCTWCWJRhQYZwfvOI3EaNKn/FgBC9HWdA0T0kTNc= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568913219827355.8330731755698; Thu, 19 Sep 2019 10:13:39 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F0C2A91762; Thu, 19 Sep 2019 17:13:36 +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 C76435D6B0; Thu, 19 Sep 2019 17:13:36 +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 7E5504EE6A; Thu, 19 Sep 2019 17:13:36 +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 x8JHDW3u004582 for ; Thu, 19 Sep 2019 13:13:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1AE0660C18; Thu, 19 Sep 2019 17:13:32 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 981BB60BF1 for ; Thu, 19 Sep 2019 17:13:31 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 19:13:06 +0200 Message-Id: <1135716c792a1e9729dcbe68d078904cf5280da1.1568911535.git.pkrempa@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 Subject: [libvirt] [PATCH 03/22] util: typedparam: Move and unexport virTypedParameterAssignFromStr 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-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 19 Sep 2019 17:13:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function is only used as a helper in virTypedParamsAddFromString. Make it static and move it to virtypedparam-public.c. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 - src/util/virtypedparam-public.c | 95 +++++++++++++++++++++++++++++++++ src/util/virtypedparam.c | 93 -------------------------------- src/util/virtypedparam.h | 6 --- 4 files changed, 95 insertions(+), 100 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 39812227aa..8af9e7c95e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3229,7 +3229,6 @@ virTPMSwtpmSetupFeatureTypeFromString; # util/virtypedparam.h virTypedParameterAssign; -virTypedParameterAssignFromStr; virTypedParameterToString; virTypedParameterTypeFromString; virTypedParameterTypeToString; diff --git a/src/util/virtypedparam-public.c b/src/util/virtypedparam-publi= c.c index 585e851f38..fb7f178c6c 100644 --- a/src/util/virtypedparam-public.c +++ b/src/util/virtypedparam-public.c @@ -25,6 +25,101 @@ #define VIR_FROM_THIS VIR_FROM_NONE +/* Assign name, type, and convert the argument from a const string. + * In case of a string, the string is copied. + * Return 0 on success, -1 after an error message on failure. */ +static int +virTypedParameterAssignFromStr(virTypedParameterPtr param, + const char *name, + int type, + const char *val) +{ + int ret =3D -1; + + if (!val) { + virReportError(VIR_ERR_INVALID_ARG, _("NULL value for field '%s'"), + name); + goto cleanup; + } + + if (virStrcpyStatic(param->field, name) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, _("Field name '%s' too long= "), + name); + goto cleanup; + } + + param->type =3D type; + switch (type) { + case VIR_TYPED_PARAM_INT: + if (virStrToLong_i(val, NULL, 10, ¶m->value.i) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid value for field '%s': expected int"), + name); + goto cleanup; + } + break; + case VIR_TYPED_PARAM_UINT: + if (virStrToLong_ui(val, NULL, 10, ¶m->value.ui) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid value for field '%s': " + "expected unsigned int"), + name); + goto cleanup; + } + break; + case VIR_TYPED_PARAM_LLONG: + if (virStrToLong_ll(val, NULL, 10, ¶m->value.l) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid value for field '%s': " + "expected long long"), + name); + goto cleanup; + } + break; + case VIR_TYPED_PARAM_ULLONG: + if (virStrToLong_ull(val, NULL, 10, ¶m->value.ul) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid value for field '%s': " + "expected unsigned long long"), + name); + goto cleanup; + } + break; + case VIR_TYPED_PARAM_DOUBLE: + if (virStrToDouble(val, NULL, ¶m->value.d) < 0) { + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid value for field '%s': " + "expected double"), + name); + goto cleanup; + } + break; + case VIR_TYPED_PARAM_BOOLEAN: + if (STRCASEEQ(val, "true") || STREQ(val, "1")) { + param->value.b =3D true; + } else if (STRCASEEQ(val, "false") || STREQ(val, "0")) { + param->value.b =3D false; + } else { + virReportError(VIR_ERR_INVALID_ARG, + _("Invalid boolean value for field '%s'"), name= ); + goto cleanup; + } + break; + case VIR_TYPED_PARAM_STRING: + if (VIR_STRDUP(param->value.s, val) < 0) + goto cleanup; + break; + default: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected type %d for field %s"), type, name); + goto cleanup; + } + + ret =3D 0; + cleanup: + return ret; +} + /* The following APIs are public and their signature may never change. */ /** diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index acf8c39602..d9f8203796 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -260,99 +260,6 @@ virTypedParameterAssign(virTypedParameterPtr param, co= nst char *name, return ret; } -/* Assign name, type, and convert the argument from a const string. - * In case of a string, the string is copied. - * Return 0 on success, -1 after an error message on failure. */ -int -virTypedParameterAssignFromStr(virTypedParameterPtr param, const char *nam= e, - int type, const char *val) -{ - int ret =3D -1; - - if (!val) { - virReportError(VIR_ERR_INVALID_ARG, _("NULL value for field '%s'"), - name); - goto cleanup; - } - - if (virStrcpyStatic(param->field, name) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, _("Field name '%s' too long= "), - name); - goto cleanup; - } - - param->type =3D type; - switch (type) { - case VIR_TYPED_PARAM_INT: - if (virStrToLong_i(val, NULL, 10, ¶m->value.i) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid value for field '%s': expected int"), - name); - goto cleanup; - } - break; - case VIR_TYPED_PARAM_UINT: - if (virStrToLong_ui(val, NULL, 10, ¶m->value.ui) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid value for field '%s': " - "expected unsigned int"), - name); - goto cleanup; - } - break; - case VIR_TYPED_PARAM_LLONG: - if (virStrToLong_ll(val, NULL, 10, ¶m->value.l) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid value for field '%s': " - "expected long long"), - name); - goto cleanup; - } - break; - case VIR_TYPED_PARAM_ULLONG: - if (virStrToLong_ull(val, NULL, 10, ¶m->value.ul) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid value for field '%s': " - "expected unsigned long long"), - name); - goto cleanup; - } - break; - case VIR_TYPED_PARAM_DOUBLE: - if (virStrToDouble(val, NULL, ¶m->value.d) < 0) { - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid value for field '%s': " - "expected double"), - name); - goto cleanup; - } - break; - case VIR_TYPED_PARAM_BOOLEAN: - if (STRCASEEQ(val, "true") || STREQ(val, "1")) { - param->value.b =3D true; - } else if (STRCASEEQ(val, "false") || STREQ(val, "0")) { - param->value.b =3D false; - } else { - virReportError(VIR_ERR_INVALID_ARG, - _("Invalid boolean value for field '%s'"), name= ); - goto cleanup; - } - break; - case VIR_TYPED_PARAM_STRING: - if (VIR_STRDUP(param->value.s, val) < 0) - goto cleanup; - break; - default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected type %d for field %s"), type, name); - goto cleanup; - } - - ret =3D 0; - cleanup: - return ret; -} - /** * virTypedParamsReplaceString: diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index f9d22b24fb..cad6953f5d 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -85,12 +85,6 @@ int virTypedParameterAssign(virTypedParameterPtr param, = const char *name, int type, /* TYPE arg */ ...) ATTRIBUTE_RETURN_CHECK; -int virTypedParameterAssignFromStr(virTypedParameterPtr param, - const char *name, - int type, - const char *val) - ATTRIBUTE_RETURN_CHECK; - int virTypedParamsReplaceString(virTypedParameterPtr *params, int *nparams, const char *name, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list