From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:a17:907:1627:b0:8ed:b3f:fd98 with SMTP id hb39csp840457ejc; Thu, 23 Feb 2023 07:42:30 -0800 (PST) X-Google-Smtp-Source: AK7set/ALfiT4WFeG5r+hTGhpTodo4wet9eEBqF5bVyju9GBe7mqkNrKrpxkf17m6e9EFN28oKPE X-Received: by 2002:a05:622a:1713:b0:3bf:a15e:a898 with SMTP id h19-20020a05622a171300b003bfa15ea898mr17369824qtk.18.1677166950645; Thu, 23 Feb 2023 07:42:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677166950; cv=none; d=google.com; s=arc-20160816; b=CtEPiZDNAEsTi2uL4Mg5wFxR0Awgtw0bbVgJdWwTQIw8B6dZzmI1Tr8v7oVNbUukb9 6iwzObM8Ejf4BQO1MBWCjDRGJPdjNIp5OkDKs+bSkazkyEhv5adGc5Aywx/o0YBtoTdR QQIfTHJTqPNUV8N9YiEbw+wtTG5ynpL3YeUo41uJZE6igau+q6kW+kj2I6KaMKIb4TG2 05B515E0P12oETI2EvyELsZ11enkOaPBJofDVvsOCh4H+FRKFUxow0Mh/LnhE51DhiNe 7jC69cSigqA8Ib2/0h58v/GCcWmnJWfREwdImG6Wt4OVwMkqc5zIhBmpw+uKW6dg4ZLl G7iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:dkim-signature; bh=Lryqtoi9kh4TElrlW23sYG/Tq/mjqxDg7fz7Tt0q534=; b=0sMJyabZ7BnyzPrlEJH0PEZHPxSNqk7H6ACDVcmXu07n1g9ozsamgMmgKc+8SFSjBt G8kQS/KzrZvzWOBgqoGGJtVBm8kACFj9NpFhLJyApS9xxHhEzsmX4bIgGllrXK6kKYY+ szjK4V49oZIFDG57rzKKCZFFAcAwjxwg4guAsEPGdiTiBNSOIA2l17B5lcoScUS2rCc6 L+WybNmyMDJ9IXl8o01iLFzB8jY8Jln2iK8qBXC9nwcRhpkEzUSJrOrYbfB01mgMF0R6 ybhiy+tu+lSmI02jNCtx9cV4g3zKYdHl4vM6CDwRI7vxNxaG0y+vEqhzkVRwLRVU5aIZ le+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JMa/t7og"; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v11-20020a05622a144b00b003b96ffcbb43si6524928qtx.673.2023.02.23.07.42.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Feb 2023 07:42:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JMa/t7og"; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVDjh-0003tu-0c; Thu, 23 Feb 2023 10:42:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVDjf-0003sa-JP for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:42:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVDje-0007Y0-3P for qemu-devel@nongnu.org; Thu, 23 Feb 2023 10:42:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677166936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lryqtoi9kh4TElrlW23sYG/Tq/mjqxDg7fz7Tt0q534=; b=JMa/t7ogynNXx8OiFHzhgz2qLTqBQnNElM3m+c2Q6XBp/NM/+YxBVbcXBvtlq15apiLKZl 1UHoPywUWmIBw0f8v3dB3LnsKKFXX8bwiyRrtkwQ+BUGPWMVV7jft5XTLxYZ/YytEf8pua wpz+J1agJ/YTRN1iVeQIkhOKwzAmeRE= 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-511-XT2M0A4CMHiqdkgAwv2cAQ-1; Thu, 23 Feb 2023 10:42:13 -0500 X-MC-Unique: XT2M0A4CMHiqdkgAwv2cAQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14E4F1C05EA2; Thu, 23 Feb 2023 15:42:13 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5683C15BAD; Thu, 23 Feb 2023 15:42:12 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id B919121E6A1F; Thu, 23 Feb 2023 16:42:11 +0100 (CET) From: Markus Armbruster To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-block@nongnu.org, =?utf-8?Q?C=C3=A9dric?= Le Goater Subject: Re: [RFC PATCH 5/5] hw/ppc/pnv_bmc: Simplify pnv_bmc_find() References: <20230216122524.67212-1-philmd@linaro.org> <20230216122524.67212-6-philmd@linaro.org> Date: Thu, 23 Feb 2023 16:42:11 +0100 In-Reply-To: <20230216122524.67212-6-philmd@linaro.org> ("Philippe =?utf-8?Q?Mathieu-Daud=C3=A9=22's?= message of "Thu, 16 Feb 2023 13:25:24 +0100") Message-ID: <871qmgs818.fsf@pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass client-ip=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: W7p63OeDvUbd Philippe Mathieu-Daud=C3=A9 writes: > ForeachArgs::name is only used once as TYPE_IPMI_BMC. > Since the penultimate commit, object_child_foreach_recursive()'s > handler takes an Error* argument and return a boolean. > We can directly pass ForeachArgs::obj as context, removing the > ForeachArgs structure. > > Signed-off-by: Philippe Mathieu-Daud=C3=A9 > --- > RFC: please double-check... > > hw/ppc/pnv_bmc.c | 25 +++++++++---------------- > 1 file changed, 9 insertions(+), 16 deletions(-) > > diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c > index 05acc88a55..566284469f 100644 > --- a/hw/ppc/pnv_bmc.c > +++ b/hw/ppc/pnv_bmc.c > @@ -278,36 +278,29 @@ IPMIBmc *pnv_bmc_create(PnvPnor *pnor) > return IPMI_BMC(obj); > } >=20=20 > -typedef struct ForeachArgs { > - const char *name; > - Object *obj; > -} ForeachArgs; > - > static bool bmc_find(Object *child, void *opaque, Error **errp) > { > - ForeachArgs *args =3D opaque; > + Object **obj =3D opaque; >=20=20 > - if (object_dynamic_cast(child, args->name)) { > - if (args->obj) { > - return false; > + if (object_dynamic_cast(child, TYPE_IPMI_BMC)) { > + if (*obj) { > + return true; Looks like you're changing return false to return true. Intendional? > } > - args->obj =3D child; > + *obj =3D child; > } > return true; > } >=20=20 > IPMIBmc *pnv_bmc_find(Error **errp) > { > - ForeachArgs args =3D { TYPE_IPMI_BMC, NULL }; > - int ret; > + Object *obj =3D NULL; >=20=20 > - ret =3D object_child_foreach_recursive(object_get_root(), bmc_find, > - &args, NULL); > - if (ret) { > + if (!object_child_foreach_recursive(object_get_root(), bmc_find, &ob= j, > + NULL)) { > error_setg(errp, "machine should have only one BMC device. " > "Use '-nodefaults'"); > return NULL; > } >=20=20 > - return args.obj ? IPMI_BMC(args.obj) : NULL; > + return IPMI_BMC(obj); > }