From nobody Sat Feb 7 05:53:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1620315160; cv=none; d=zohomail.com; s=zohoarc; b=DM0BSXydLfkQdG81zg8DqYaSS8Gc5QHbpB8HqQZxLYgrYXQe2QrMpW2kJ+LPHVNO1EJZSHoIhuyD0mNggrS1yQv0QH9z06EkYfD9McYfDqqOdNJelL/JOnNErQhqZgOkQrqyev7TShGIgMXojsvQxWP729yDk4zyCfEoJA/8ScQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620315160; 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=S/2zyZ5WPF7AjIbmusAZlFZU8lxwFGgA4v0gp7ZW9s0=; b=ZvGMTtM8bPQSBNGztdgBdBXslR7bXpL+RLDfMQu5cL1OAa+M1p/Jr6qGhgYQJglnBWIs2PFhn62b7Dfcg5+kX2jjWKpF5ABpbd+N+9xZcICIPmtFmoH9qS2cWl9nsFHiIDs1UhdSCeNKS7eU14myD4vBIac3erbbLnBK+pjcb0Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620315160065214.97359734251393; Thu, 6 May 2021 08:32:40 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-Mgp-h85SNHizn_0kg0p7ew-1; Thu, 06 May 2021 11:31:38 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id F02DB6D5B2; Thu, 6 May 2021 15:31:29 +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 D21D65D6AC; Thu, 6 May 2021 15:31:29 +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 958915535E; Thu, 6 May 2021 15:31:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 146FVN94011452 for ; Thu, 6 May 2021 11:31:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id BE5C81045E8C; Thu, 6 May 2021 15:31:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2EFC010190A7 for ; Thu, 6 May 2021 15:31:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620315158; 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=S/2zyZ5WPF7AjIbmusAZlFZU8lxwFGgA4v0gp7ZW9s0=; b=QigO+RX3c/FsK3mtUqSu80bqy8IFmRiuNltNoInsE5uL5JZim92YaBR7mBwQghz+SxgDbs 8FDcg3MbvX2cYIPkZ2ta40dXu/Mmp135eV4bgI3u+3gk1KMsE7EoZ9aM8mUjDH77p32Q5M HVRgUA9qP+OnE2iejThguaLZo8b9MWA= X-MC-Unique: Mgp-h85SNHizn_0kg0p7ew-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/17] virXMLPropTristateSwitch: Always initialize '@result' Date: Thu, 6 May 2021 17:31:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Compilers aren't able to see whether @result is set or not and thus don't warn of a potential use of uninitialized value. Always set @result to prevent uninitialized use. In two cases the code needed to be adjusted to preserve functionality. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 10 ++++++++-- src/util/virxml.c | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ea99a4c40a..ce0ffc60ef 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17443,12 +17443,15 @@ virDomainFeaturesDefParse(virDomainDef *def, case VIR_DOMAIN_FEATURE_PVSPINLOCK: case VIR_DOMAIN_FEATURE_VMPORT: case VIR_DOMAIN_FEATURE_SMM: { - virTristateSwitch state =3D VIR_TRISTATE_SWITCH_ON; + virTristateSwitch state; if (virXMLPropTristateSwitch(nodes[i], "state", VIR_XML_PROP_NONE, &state) < 0) return -1; + if (state =3D=3D VIR_TRISTATE_SWITCH_ABSENT) + state =3D VIR_TRISTATE_SWITCH_ON; + def->features[val] =3D state; break; } @@ -17770,7 +17773,7 @@ virDomainFeaturesDefParse(virDomainDef *def, return -1; for (i =3D 0; i < n; i++) { - virTristateSwitch state =3D VIR_TRISTATE_SWITCH_ON; + virTristateSwitch state; int val =3D virDomainProcessCapsFeatureTypeFromString((const char = *)nodes[i]->name); if (val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -17783,6 +17786,9 @@ virDomainFeaturesDefParse(virDomainDef *def, &state) < 0) return -1; + if (state =3D=3D VIR_TRISTATE_SWITCH_ABSENT) + state =3D VIR_TRISTATE_SWITCH_ON; + def->caps_features[val] =3D state; } VIR_FREE(nodes); diff --git a/src/util/virxml.c b/src/util/virxml.c index d9bc5199b3..8e28629e9a 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -630,6 +630,8 @@ virXMLPropTristateBool(xmlNodePtr node, * @result: The returned value * * Convenience function to return value of an on / off attribute. + * In case when the property is missing @result is initialized to + * VIR_TRISTATE_SWITCH_ABSENT. * * Returns 1 in case of success in which case @result is set, * or 0 if the attribute is not present, @@ -643,6 +645,8 @@ virXMLPropTristateSwitch(xmlNodePtr node, { flags |=3D VIR_XML_PROP_NONZERO; + *result =3D VIR_TRISTATE_SWITCH_ABSENT; + return virXMLPropEnumInternal(node, name, virTristateSwitchTypeFromStr= ing, flags, result); } --=20 2.30.2