From nobody Mon Feb 9 01:49:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1681908411; cv=none; d=zohomail.com; s=zohoarc; b=R2otAXER932P2eCp83POcO4RGKEltdYDrlUeap0Dsdjvvxw10nKqvlQy4IxdG0uNi7eQ/8RQ3lY4j6cV/BoV8vmy7BRFmJba7YPhY3yKW4xRnCoRsFjVsFp3jix8/kpCDOKrep0YNuJUXtNxVKmiXJvtgMYq5/actLBhdMgNhR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681908411; 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=lf36IoUj1w0/MpDbyx0tmi8I6cgLj7d5FKGIqftUT9A=; b=a8p/ay1H/ewk8mxsn1/x+WYo6nLdWqyQdx7iQ6otQwIsryQ53JHkbMEXUYAr5G6AAbfSBFa0ozrcRAOjmRNjOzPWhKtyS6dnJV/JxvYD4Giikdtn2lSaB3vHGkARZIq43d/reOhYY2yFcM3hAFmhKCCm6RzvSrVKwiE2N6gIzZc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1681908411909437.87376488819143; Wed, 19 Apr 2023 05:46:51 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-53-XGukwj8COl6toTBiDPbcyw-1; Wed, 19 Apr 2023 08:46:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ECF0C185A790; Wed, 19 Apr 2023 12:46:45 +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 96B252166B33; Wed, 19 Apr 2023 12:46:45 +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 7AC4219465B1; Wed, 19 Apr 2023 12:46:45 +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 C0E8119466DF for ; Wed, 19 Apr 2023 12:04:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B0526492B07; Wed, 19 Apr 2023 12:04:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35DBB492B0F for ; Wed, 19 Apr 2023 12:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681908410; 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=lf36IoUj1w0/MpDbyx0tmi8I6cgLj7d5FKGIqftUT9A=; b=Qces+pfFD8K9MVu6k+H7rfUfbtJoZofIe6OS+g0qVU/sKUH49T4nFYVLQMtjAs/mfimwFc 623WX9QdI6ZP5vuEVj10MDof9Co5Txv59JW5nz+6De3ds6EY+6N86mBFeHlr1Bqoo7BBwa nwrwkoEGJCT5RGo4JjwZtNiHTRGh+c4= X-MC-Unique: XGukwj8COl6toTBiDPbcyw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 05/25] util: virtypedparam: Simplify error handling in virTypedParamListAdd* Date: Wed, 19 Apr 2023 14:04:22 +0200 Message-Id: <060518a1ff30564ad6b67f77b13edac7f3ecdac0.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.6 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: 1681908413319100001 Content-Type: text/plain; charset="utf-8" Don't check the return value of 'virTypedParamListExtend' which will always be a valid pointer and 'virTypedParameterAssignValue' always returns 0. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander --- src/util/virtypedparam.c | 46 +++++++++++++--------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index f325f3b012..1a1a34fdb2 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -245,7 +245,7 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr = param, } -static int +static void virTypedParameterAssignValue(virTypedParameterPtr param, virTypedParameterType type, ...) @@ -255,8 +255,6 @@ virTypedParameterAssignValue(virTypedParameterPtr param, va_start(ap, type); virTypedParameterAssignValueVArgs(param, type, ap, true); va_end(ap); - - return 0; } @@ -776,13 +774,11 @@ virTypedParamListAddInt(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value) < 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -798,13 +794,11 @@ virTypedParamListAddUInt(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value) < 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -820,13 +814,11 @@ virTypedParamListAddLLong(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value) < = 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -842,13 +834,11 @@ virTypedParamListAddULLong(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value) <= 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -864,13 +854,11 @@ virTypedParamListAddString(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value) <= 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -886,13 +874,11 @@ virTypedParamListAddBoolean(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value) = < 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); @@ -908,13 +894,11 @@ virTypedParamListAddDouble(virTypedParamList *list, const char *namefmt, ...) { - virTypedParameterPtr par; + virTypedParameterPtr par =3D virTypedParamListExtend(list); va_list ap; int ret; - if (!(par =3D virTypedParamListExtend(list)) || - virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value) <= 0) - return -1; + virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value); va_start(ap, namefmt); ret =3D virTypedParamSetNameVPrintf(par, namefmt, ap); --=20 2.39.2