From patchwork Thu Feb 16 12:25:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 654029 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp321268wrr; Thu, 16 Feb 2023 04:27:54 -0800 (PST) X-Google-Smtp-Source: AK7set/F2ioWn8FzuRNPnoTMXHN2WGXH96xCs+6slsf/P/vcmHZqIGlMlZGF9ogHGnWOGKNgg+fl X-Received: by 2002:ac8:59d4:0:b0:3ba:18c2:99e7 with SMTP id f20-20020ac859d4000000b003ba18c299e7mr9703297qtf.45.1676550474457; Thu, 16 Feb 2023 04:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676550474; cv=none; d=google.com; s=arc-20160816; b=wcBhP7/6bNFc7rqaLqwOjSGL52f29/joeaB0/+FDa9Kqu+llsDbGjUpctEF+CkIuzN y8+QJyI9pdg7pJdeExmW3doizr+LcpHgzZnHo8wGVvNpmG1cswd6LEjBZyb9XBQll9uS ZGu5UZr9yyjL44OjI9UsYVWU5fKl0pJXKNXDZdybLBKxb8w8lEQSo10Iiut54UFOBRUt 83wzgbV96zYuMRiE/G/hW90GWQoK2F++qh4ijG45UWtWAbvhAAu/A48vKbJSz11E74OV 4uJQZnLQ+V25BDBhC/40gDqwYMOR4GWcJCFKRjOGRjiUvr2CCb8pDB555aaAPbZA8n8w TULg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J9tFPN4rdCw1nxfX8ah3wia3JiRf2r85XcvwPt3k03s=; b=dxWkNg63snj0SsG5G0PuqT/Oh39QeXudR66+QGXdnPzETDK6wcSraMgXdbid87lCGI OT3KpKRQ+u2FH2dk6p6gRo1qSxpvK+NYCg2YGZpn+Uh0Mp5iqvcehDrybVgmK0N1xgkj W78hIppwzp64eu6yvFX75SPivQy0qyIlYDiO9f0iD8pt5aI36bTqa2GzRybHlKrezOR1 ljCQS5seOUdEfVn4zV27F2GT54HE4qJsobjvObrqZ/ARu2dYg0M2Tab0Sb26u2mfSrO/ FVDseWh3WcMr6WtpX66sxq6nhQc1j0HlrClKqS0ckTNn1q+HmKZ9cHYd349qPvHF5tsq XSZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VSStNVY4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d203-20020ae9efd4000000b0071f0cdc8de1si1435325qkg.660.2023.02.16.04.27.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Feb 2023 04:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=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=@linaro.org header.s=google header.b=VSStNVY4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSdKq-0002qT-2p; Thu, 16 Feb 2023 07:26:00 -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 1pSdKn-0002p0-Vp for qemu-devel@nongnu.org; Thu, 16 Feb 2023 07:25:57 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSdKl-0008Bx-U3 for qemu-devel@nongnu.org; Thu, 16 Feb 2023 07:25:57 -0500 Received: by mail-wm1-x32b.google.com with SMTP id s13-20020a05600c45cd00b003ddca7a2bcbso1489038wmo.3 for ; Thu, 16 Feb 2023 04:25:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=J9tFPN4rdCw1nxfX8ah3wia3JiRf2r85XcvwPt3k03s=; b=VSStNVY4wyoxHRBnEZUdC/a8liXCq2B5GZbeXSvysmyHNULFGw+ueEaWQGs4PvMtTp BtAJFnhU8mgmmKZbCpdrD+K6Yz8chWrE/g5p/ixc9rV4356aizfYaru6I6a7YmUWc+Re tiAulQGM2prRHTZGoPyTyfbZR+Gu5fF+MmQYRGb0CGLeIK3DfTcOjOMHrQSjfNO20ogk NYx+QP3pg9ADZnZQ21CXeouaw3wNxOTV6LSrlpG9l5sN7cIpuxwj0KAPyz56cNXvLwvq 0UhX/88uibER7N484m2RI29YOi6GDy1kff1htF9xxDAKJuSZpq189dDcE6UlZCc2u8+E X5Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=J9tFPN4rdCw1nxfX8ah3wia3JiRf2r85XcvwPt3k03s=; b=nZAQYf229/DWMKDx4ZA3d6nINnW7Iy+x7v31iWiQpX9+e6pHnQlBYz2TjMOaKNeWAj a+zpRf9SWDxJBKQX49jVlBFBw0f9oBZYV+eIKwgq954HsyiEPCCoGd8Ictkah7Ml6cka 7UwJeUtEoSBrzyT29J5adg+hX0W2Sxs7mS3OGH87pQ+k0zAKuaWRhQZNlhVk5tp0tza/ xuq0eZZzEhlAsUaIAaKaN6+x01HM25m0d2YTshqaN4HeTPD5osd6MqKqehZhs8Y6DSRD 6ywDIKVQA/F4/pZL9qJtVfO7OeoAS50NxXmXQk8qKfyx5doiiRi28qswYHlMtlLH99C8 MeEg== X-Gm-Message-State: AO0yUKUDXfmeEQG5O4SDKVBmsZ10Z1Z+LWpnET9MUkzsbHzEqoAVWFQC m1CiATUOBlzS0ozgVgzAK9n/Idjur3rLo+F1 X-Received: by 2002:a05:600c:4d12:b0:3e2:1636:766a with SMTP id u18-20020a05600c4d1200b003e21636766amr655997wmp.9.1676550354304; Thu, 16 Feb 2023 04:25:54 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id e1-20020a05600c4e4100b003e0015c8618sm5280146wmq.6.2023.02.16.04.25.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Feb 2023 04:25:53 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [RFC PATCH 5/5] hw/ppc/pnv_bmc: Simplify pnv_bmc_find() Date: Thu, 16 Feb 2023 13:25:24 +0100 Message-Id: <20230216122524.67212-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230216122524.67212-1-philmd@linaro.org> References: <20230216122524.67212-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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); } -typedef struct ForeachArgs { - const char *name; - Object *obj; -} ForeachArgs; - static bool bmc_find(Object *child, void *opaque, Error **errp) { - ForeachArgs *args = opaque; + Object **obj = opaque; - if (object_dynamic_cast(child, args->name)) { - if (args->obj) { - return false; + if (object_dynamic_cast(child, TYPE_IPMI_BMC)) { + if (*obj) { + return true; } - args->obj = child; + *obj = child; } return true; } IPMIBmc *pnv_bmc_find(Error **errp) { - ForeachArgs args = { TYPE_IPMI_BMC, NULL }; - int ret; + Object *obj = NULL; - ret = object_child_foreach_recursive(object_get_root(), bmc_find, - &args, NULL); - if (ret) { + if (!object_child_foreach_recursive(object_get_root(), bmc_find, &obj, + NULL)) { error_setg(errp, "machine should have only one BMC device. " "Use '-nodefaults'"); return NULL; } - return args.obj ? IPMI_BMC(args.obj) : NULL; + return IPMI_BMC(obj); }