From patchwork Thu Apr 25 11:01:47 2024 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: 792038 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1320955wrq; Thu, 25 Apr 2024 04:06:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCURowdwtxapLRxTJ1zFuXu4sG8cZbtK0jNk78lD6czWYXPK+04btDxvOjwWuPtONzrU2FSLQQRQoIqtLt/W3wPo X-Google-Smtp-Source: AGHT+IHvkNF0D8NMOi8xHHqrkAT/sBm7ZjIgHyevbr1spVkN7dWQDWxVKz7HL+A+mP6l1UQLiG+W X-Received: by 2002:a05:6102:11e5:b0:47c:abf:385 with SMTP id e5-20020a05610211e500b0047c0abf0385mr6047296vsg.4.1714043169860; Thu, 25 Apr 2024 04:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714043169; cv=none; d=google.com; s=arc-20160816; b=RKS3ZeRBzgr7dDQxHn6xNPMCI47PsglKn7iDqfHO+sD1jO3VKY4srYrg5ZcuFGuTw7 1qs9uSNJv8Yd7PRdDZCeYN7qPyUtalXysi/aYptiA0uGKNAB/5cU4PCuei4ySPpT1bwE zMgkR1NQkBhSQRQ5r2N7vMAnkhCqF76jd7skOgquo+jvM7JWCcyYaRsNhYro1hyEZ0uh isi/UDAffjeL/mUfnbYO79eg0YZyWO88BkU2QcjAzu7jhnccaN7idaG+2Jwg1GlEs7zG 9Gj+MW60r6k6JNDuK3V045kIn08J0A2A94e/sqkBDOFb+2ckIu5DdBVblGjfcndgM0UL f24A== 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=pvunkSj/8Waxads7PhZ8ZQlWRsJ6KI6vMAUvxRYx65M=; fh=5LOWqTNvnFRd1twfDZuFQ28UZFUxKcuuynE60ceoAJg=; b=MxyQubxHidHnfT/Q3rlc04Dxn0ncxDa6I8H3wUhrG9Z+NNF4sX66D3yCyT+mUH4WPu 6poXuTgg0mlWasjKF3+8xekPiqM/N6tAhO5zqSKv2dPXYW7OfqzuyBfBOz8JhGmeJPnE hSWsijlVV1XLPY4uiUE2Dc/aHEB4erm5zubSMq41P7RpgokzqGa91TXY4VPsGXC4aJex i7qTGWlR5BvPGXoFWGysbKmV8AqRarWq7sq9NGTtYdk8Bm+hHREQduuZxMHC2g5Adm/G hddgd01yGMx8HBdlRieBLK6vua0huGOWuLCKv1bu9oZCZqqF4b5I3T5FRif+L8XAQQr1 0BNw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gL9a3tea; 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 if6-20020a0561022c8600b0047bcba2f1b6si2547640vsb.757.2024.04.25.04.06.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 04:06:09 -0700 (PDT) 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=gL9a3tea; 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 1rzwtw-0001c3-FK; Thu, 25 Apr 2024 07:04:28 -0400 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 1rzwtB-00009T-2S for qemu-devel@nongnu.org; Thu, 25 Apr 2024 07:03:57 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzwss-0000DG-7b for qemu-devel@nongnu.org; Thu, 25 Apr 2024 07:03:26 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-41adf3580dbso5031725e9.0 for ; Thu, 25 Apr 2024 04:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714043000; x=1714647800; darn=nongnu.org; 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=pvunkSj/8Waxads7PhZ8ZQlWRsJ6KI6vMAUvxRYx65M=; b=gL9a3tea7yE6jcdX6zkmxwDmR6RkxmQKGR0W8cbgks1HpM55Kl2q+Fh5rDjzchqYhY ibf6gTSzByxXyHNx3UMizX1IL+oJfoPpgfewwNEdFKYZRg6DDQgrJ/yQlBA/QOFsOT30 mPK+d1+VuHN3r3++vGimHOahyjN386AlBBbee1h9kn3SpQcpFESm/DIQ2CK8kNho5nJp 24zHp3k6m2azSmBCFVEiiXKCNsLNVXUwhFGki3EhncgbEJir3NyRHAhCd1U1V8o6lkEQ 70rEdMd1hXHJQieDioZs0cKc08yQlROsxMFvwpfcpDfkKuMuvWWevUqvtOohZZGXyXHp nHHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714043000; x=1714647800; 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=pvunkSj/8Waxads7PhZ8ZQlWRsJ6KI6vMAUvxRYx65M=; b=QQdsw8uMFram+rWtSsd2xHY5tLXOhcqonDaDahwOrbol0Fu/T443cS02g/JjsiSRp5 QuhS7O1Oge2Qz4lCt522wPKJyfjH/aYqQFT9CXRICqdWt8DLxSkuYrLVzWeQQcz0iF/L oVIxNqhR09y3sNl+5YfJ/Vk76//YGz+M1sYXOoiJ1KH8fugmWdKdz6w9lmEDwjMaZJun awx7dIeVVV5LfqW4PqrlkyxYzhN783ujna2MswwdJECS59yl2Ml0mXdF5T6C1kuxCQuh 3bNDP00rk9ioyZxBHbeN+sgPh9hG9ta4CqxxiMi9/QyTNPv0hCM4i+dd9RwcL1Sqbxwm KgUw== X-Gm-Message-State: AOJu0YwAulEvWGbCiWP690K3rXoUrr8+FB2n+U2Ze48OcsWoZKTFaL3Y IcPgQvJ43tcs1f7cxtDAC6ZfNgnvbb+KFDqdwo9qirDyufiMNnd2d6QQ1AWyOA8NdESGJ2eLS41 J X-Received: by 2002:a05:600c:3554:b0:415:ff48:59fc with SMTP id i20-20020a05600c355400b00415ff4859fcmr2033033wmq.8.1714043000386; Thu, 25 Apr 2024 04:03:20 -0700 (PDT) Received: from localhost.localdomain ([92.88.170.77]) by smtp.gmail.com with ESMTPSA id k41-20020a05600c1ca900b00417e8be070csm27334682wms.9.2024.04.25.04.03.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 25 Apr 2024 04:03:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Zhao Liu , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jonathan Cameron , Jonathan Cameron , Fan Ni , "Michael S. Tsirkin" , Marcel Apfelbaum Subject: [PULL 14/22] hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean Date: Thu, 25 Apr 2024 13:01:47 +0200 Message-ID: <20240425110157.20328-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240425110157.20328-1-philmd@linaro.org> References: <20240425110157.20328-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 From: Zhao Liu As error.h suggested, the best practice for callee is to return something to indicate success / failure. With returned boolean, there's no need to dereference @errp to check failure case. Suggested-by: Markus Armbruster Signed-off-by: Zhao Liu Reviewed-by: Philippe Mathieu-Daudé Acked-by: Jonathan Cameron Message-ID: <20240418100433.1085447-4-zhao1.liu@linux.intel.com> Signed-off-by: Philippe Mathieu-Daudé --- include/hw/cxl/cxl_component.h | 2 +- hw/cxl/cxl-cdat.c | 6 +++--- hw/mem/cxl_type3.c | 3 +-- hw/pci-bridge/cxl_upstream.c | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 5012fab6f7..945ee6ffd0 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -273,7 +273,7 @@ hwaddr cxl_decode_ig(int ig); CXLComponentState *cxl_get_hb_cstate(PCIHostState *hb); bool cxl_get_hb_passthrough(PCIHostState *hb); -void cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp); +bool cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp); void cxl_doe_cdat_release(CXLComponentState *cxl_cstate); void cxl_doe_cdat_update(CXLComponentState *cxl_cstate, Error **errp); diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index e7bc1380bf..959a55518e 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -189,14 +189,14 @@ static bool ct3_load_cdat(CDATObject *cdat, Error **errp) return true; } -void cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp) +bool cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp) { CDATObject *cdat = &cxl_cstate->cdat; if (cdat->filename) { - ct3_load_cdat(cdat, errp); + return ct3_load_cdat(cdat, errp); } else { - ct3_build_cdat(cdat, errp); + return ct3_build_cdat(cdat, errp); } } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index b0a7e9f11b..3e42490b6c 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -705,8 +705,7 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) cxl_cstate->cdat.build_cdat_table = ct3_build_cdat_table; cxl_cstate->cdat.free_cdat_table = ct3_free_cdat_table; cxl_cstate->cdat.private = ct3d; - cxl_doe_cdat_init(cxl_cstate, errp); - if (*errp) { + if (!cxl_doe_cdat_init(cxl_cstate, errp)) { goto err_free_special_ops; } diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index 783fa6adac..e51221a5f3 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -338,8 +338,7 @@ static void cxl_usp_realize(PCIDevice *d, Error **errp) cxl_cstate->cdat.build_cdat_table = build_cdat_table; cxl_cstate->cdat.free_cdat_table = free_default_cdat_table; cxl_cstate->cdat.private = d; - cxl_doe_cdat_init(cxl_cstate, errp); - if (*errp) { + if (!cxl_doe_cdat_init(cxl_cstate, errp)) { goto err_cap; }