From nobody Sun May 19 15:16:55 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713433909; cv=none; d=zohomail.com; s=zohoarc; b=Wq6hJ1s5jsx5vo6YRLvPrdnPejsL5NoLccm0DCfnZYJQjXSevKJYK7IG2P6j5XARLk8GcTgdMi8+j6Xsx6F85fj/rnd2OpYfMfzxjaE7lgRM1OaOObTYrxHYOcLyfTtjj6KfPVznyLMQE0NhAR2y9e1H0u3dqygtbNaI64DZBi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713433909; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EWlX4HLYXhSZyZvlg8FWYa9CVXuBwnDaxQvqeUOPXS8=; b=Ks2qU6s+6qEZSqJXpy/cH22lM798efuV2gHay0wCcRobpQm13DQnNaf/oCCnK9n5WiwWBCrNZAZ6Lq2KSygTPT01Vxrp6NK8HBcLbSVMr1Ow/C5qV5hKEVNKyetVUVJs2TAWzOK/u6OZiQik6J/1iKOzLjqd6xAfkr9j9V7ob7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713433909604147.1809837676666; Thu, 18 Apr 2024 02:51:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxOPk-0002Nb-C6; Thu, 18 Apr 2024 05:50:44 -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 1rxOPg-0002Kt-5M for qemu-devel@nongnu.org; Thu, 18 Apr 2024 05:50:40 -0400 Received: from mgamail.intel.com ([192.198.163.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxOPe-0000aD-62 for qemu-devel@nongnu.org; Thu, 18 Apr 2024 05:50:39 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 02:50:34 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 18 Apr 2024 02:50:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713433838; x=1744969838; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y+y8pbPG6aAYtksMSfCcD9zV1UGDITyzpAQD1vynnmE=; b=fRXx/ICByeYSmqj/oAAeKDjx4RL2tH/P4TYnf4WgdOLiJS2oH6z8lbgx tECGoZK3g1+josO/jazG14z3I2g8dvrYQJE/988SyWBXWC3WlhxEbhUrG EK3v2yyCjLkqOPcezJSiu5USej1uPl/e9I0g3Ca5lyj7jnvqriwt2q7I4 G/nTCw5ZJGGAeHUOJbR2s+QZDTe3+vGSQzDoQ2nwsOPpQhWa1ZfzuOnZP 8QpQZj1PoExwqr3/mwMeA/kh49UGWVyIAIVx7/GjAZ6B1/4O/ooGX+9nU WjLHqmFifrj+62fvcoYjLYL5IXldJ5h4ia4qceVI7F8sZda7RDgpmc2jz g==; X-CSE-ConnectionGUID: HwwD7+3BTqKkQN0CCMoNvQ== X-CSE-MsgGUID: 1nNLKCs+T++axV5oVPRslg== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8837592" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="8837592" X-CSE-ConnectionGUID: KzSb7/g4SSS6AvmZ8ThkqQ== X-CSE-MsgGUID: 7xwLRKhYSEWwrkZYpW+52g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="27507000" From: Zhao Liu To: Jonathan Cameron , Fan Ni , "Michael S . Tsirkin" , Marcel Apfelbaum Cc: qemu-devel@nongnu.org, Markus Armbruster , Zhao Liu Subject: [PATCH 1/3] hw/cxl/cxl-cdat: Make ct3_load_cdat() return boolean Date: Thu, 18 Apr 2024 18:04:31 +0800 Message-Id: <20240418100433.1085447-2-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418100433.1085447-1-zhao1.liu@linux.intel.com> References: <20240418100433.1085447-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=192.198.163.17; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713433910621100001 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As error.h suggested, the best practice for callee is to return something to indicate success / failure. So make ct3_load_cdat() return boolean, and this is the preparation for cxl_doe_cdat_init() returning boolean. Suggested-by: Markus Armbruster Signed-off-by: Zhao Liu Acked-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/cxl/cxl-cdat.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index 551545f7823b..b3e496857a77 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -111,7 +111,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **er= rp) cdat->entry =3D g_steal_pointer(&cdat_st); } =20 -static void ct3_load_cdat(CDATObject *cdat, Error **errp) +static bool ct3_load_cdat(CDATObject *cdat, Error **errp) { g_autofree CDATEntry *cdat_st =3D NULL; g_autofree uint8_t *buf =3D NULL; @@ -127,11 +127,11 @@ static void ct3_load_cdat(CDATObject *cdat, Error **e= rrp) &file_size, &error)) { error_setg(errp, "CDAT: File read failed: %s", error->message); g_error_free(error); - return; + return false; } if (file_size < sizeof(CDATTableHeader)) { error_setg(errp, "CDAT: File too short"); - return; + return false; } i =3D sizeof(CDATTableHeader); num_ent =3D 1; @@ -139,19 +139,19 @@ static void ct3_load_cdat(CDATObject *cdat, Error **e= rrp) hdr =3D (CDATSubHeader *)(buf + i); if (i + sizeof(CDATSubHeader) > file_size) { error_setg(errp, "CDAT: Truncated table"); - return; + return false; } cdat_len_check(hdr, errp); i +=3D hdr->length; if (i > file_size) { error_setg(errp, "CDAT: Truncated table"); - return; + return false; } num_ent++; } if (i !=3D file_size) { error_setg(errp, "CDAT: File length mismatch"); - return; + return false; } =20 cdat_st =3D g_new0(CDATEntry, num_ent); @@ -185,6 +185,7 @@ static void ct3_load_cdat(CDATObject *cdat, Error **err= p) cdat->entry_len =3D num_ent; cdat->entry =3D g_steal_pointer(&cdat_st); cdat->buf =3D g_steal_pointer(&buf); + return true; } =20 void cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp) --=20 2.34.1 From nobody Sun May 19 15:16:55 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713433898; cv=none; d=zohomail.com; s=zohoarc; b=nn5+fdUz4KCoo6NoXQaw6JjcsJG9hgZEeLfFy5WM5Kv8Vpz0ldEbBIafbylWqLaQYWoSzu/YwOQt1RlBMlHVZIA2rvsmOLuQnpRTlqpH5Dz5PF5HYaqq1uNbVnGAc0XOPkM2ugnKQp/aJQWTM4lBsV8wGRc6UYA36XVR6i2Cdes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713433898; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iMk/UzavXh+O1u0Iq3ET7jVsXZ5XuP6xNLrKXmKP8EE=; b=Z+XTjehvaQf6J5G2ny5xDgp/NvoF+pvgZg11QzACaNyr5h3M0ujzcTil/7JT5qL/EYyUjVbEohcSiGNWmVIg7w2JTf5AZ+u3dzQ5ryojWJA4hRGmjNGUhQwIZckhmccQ92I0uvUulNKp1ebzkXq7wQ1bpBo5NWQL1FmK9Y26NQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713433898878794.4133551956509; Thu, 18 Apr 2024 02:51:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxOPi-0002Md-EM; Thu, 18 Apr 2024 05:50:42 -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 1rxOPg-0002LB-Sy for qemu-devel@nongnu.org; Thu, 18 Apr 2024 05:50:40 -0400 Received: from mgamail.intel.com ([192.198.163.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxOPf-0000bx-AN for qemu-devel@nongnu.org; Thu, 18 Apr 2024 05:50:40 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 02:50:36 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 18 Apr 2024 02:50:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713433839; x=1744969839; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=67wYxFpR0HmgfUT+8PMx6saVlYwoggN34mvmll1aXh4=; b=LOkJ/VSK9kGet20izNreLXcW2PVgJhvShqihTMxnHYH2TP6OFYjHa7zp mCtUvU6XmCnG7m6iSpBMfQaJMOqQuJS7nERmgXZIFRAnjYmIhfkR+c9bc e5E+0DoIyjMTcdbpOGfGaFs6ejvS1LLGG3nlQreBmt5ThVh7oJSLeYLu1 U/l4libfIJ/5O8tLHk/JfTU9LGMrD1xCANnDJZM1l4PUYpcXxgTdcYvOr 9Ccubfp2uCzgk4Aw2Oz3r35Z3+Ttskhg9eFPjg8hMfrvqPg+uzr0vVEQj pmoYDq5ysymAj69aYeATZ0p7Tu9z8ZRZCWyA4uoaqysYRssPkcdXzZKFj g==; X-CSE-ConnectionGUID: nQK3/9opRXaH2IQG+QjmBQ== X-CSE-MsgGUID: y+aL9H5US3WH8JZD2ByTIQ== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8837602" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="8837602" X-CSE-ConnectionGUID: xSWiApeISRSI0Nr6w2Sh/g== X-CSE-MsgGUID: bza7xcyYRiOrrFZA55Lfog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="27507019" From: Zhao Liu To: Jonathan Cameron , Fan Ni , "Michael S . Tsirkin" , Marcel Apfelbaum Cc: qemu-devel@nongnu.org, Markus Armbruster , Zhao Liu Subject: [PATCH 2/3] hw/cxl/cxl-cdat: Make ct3_build_cdat() return boolean Date: Thu, 18 Apr 2024 18:04:32 +0800 Message-Id: <20240418100433.1085447-3-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418100433.1085447-1-zhao1.liu@linux.intel.com> References: <20240418100433.1085447-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=192.198.163.17; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713433900588100003 Content-Type: text/plain; charset="utf-8" From: Zhao Liu As error.h suggested, the best practice for callee is to return something to indicate success / failure. So make ct3_build_cdat() return boolean, and this is the preparation for cxl_doe_cdat_init() returning boolean. Suggested-by: Markus Armbruster Signed-off-by: Zhao Liu Acked-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/cxl/cxl-cdat.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index b3e496857a77..e7bc1380bfbf 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -44,7 +44,7 @@ static void cdat_len_check(CDATSubHeader *hdr, Error **er= rp) } } =20 -static void ct3_build_cdat(CDATObject *cdat, Error **errp) +static bool ct3_build_cdat(CDATObject *cdat, Error **errp) { g_autofree CDATTableHeader *cdat_header =3D NULL; g_autofree CDATEntry *cdat_st =3D NULL; @@ -58,7 +58,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) cdat_header =3D g_malloc0(sizeof(*cdat_header)); if (!cdat_header) { error_setg(errp, "Failed to allocate CDAT header"); - return; + return false; } =20 cdat->built_buf_len =3D cdat->build_cdat_table(&cdat->built_buf, @@ -67,14 +67,14 @@ static void ct3_build_cdat(CDATObject *cdat, Error **er= rp) if (cdat->built_buf_len <=3D 0) { /* Build later as not all data available yet */ cdat->to_update =3D true; - return; + return true; } cdat->to_update =3D false; =20 cdat_st =3D g_malloc0(sizeof(*cdat_st) * (cdat->built_buf_len + 1)); if (!cdat_st) { error_setg(errp, "Failed to allocate CDAT entry array"); - return; + return false; } =20 /* Entry 0 for CDAT header, starts with Entry 1 */ @@ -109,6 +109,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **er= rp) cdat_st[0].length =3D sizeof(*cdat_header); cdat->entry_len =3D 1 + cdat->built_buf_len; cdat->entry =3D g_steal_pointer(&cdat_st); + return true; } =20 static bool ct3_load_cdat(CDATObject *cdat, Error **errp) --=20 2.34.1 From nobody Sun May 19 15:16:55 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1713433920; cv=none; d=zohomail.com; s=zohoarc; b=gs8ArRJoo7BgQlBmH56dKdyu6YMcOxGpuxShZuhlmw8KiwHNFfmAPS16eHYowhfiLiIL2U2rNixT5T6KmpsV5tJtpEfVo3hHNDs9k8o68qapVtr6arSvneGk3nMVVPvP2SBXwcOf512WwqZqRlMP8s/IoheaBmYKGVxVQbUdrio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713433920; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NYHeYaKWab+yBNE7Atz0itlYwcSi1xVsu3Mc+3BA+2I=; b=G7XIIydlIx+OwWBVRx8RElPiJacq+cb8vKjj3OUarGOreC43kI+cHYkbs7XS/T1+G/P0Uh7FuNtsz8BgTkxb69OTvt67RBTVOHbhyOvosNFb4DZGfwsGk9fMcPgYcpoUwDM8q13aNtsCOFAfl7EPeLxLpkEuXbvbr1/UnQlItew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713433920931505.0629776031724; Thu, 18 Apr 2024 02:52:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxOPk-0002Nh-ID; Thu, 18 Apr 2024 05:50:44 -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 1rxOPi-0002MI-6o for qemu-devel@nongnu.org; Thu, 18 Apr 2024 05:50:42 -0400 Received: from mgamail.intel.com ([192.198.163.17]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxOPg-0000aD-Il for qemu-devel@nongnu.org; Thu, 18 Apr 2024 05:50:41 -0400 Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 02:50:38 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by fmviesa003.fm.intel.com with ESMTP; 18 Apr 2024 02:50:36 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713433840; x=1744969840; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lbPQJi6mKHN3eHLyUnR9ZyEzQusJyhNv4/DgxwHqZeo=; b=V29vtrMqXPuxDfuVvrwM7600EmyIosl9Mywy7KG85cnrfq4wD6czEjeS GGSJBM7LsoNoAbTICrhpFByjJIdxQ9ar1COtlGODRnE3Kk4nteb49jc04 6CjVFyD9c6EdeMXGUlJNZnu30mI3KVMU09YBu/lqTNQfVhVRDBhb4tfGz 3HtPIMjDqxGOfgDrufPyxu93niu4D/xN6Cqbp0jtRnlGcuOYLKwWVLNAG OCv8X39RR6UmNvqXyy20IbuQv4/kQj/2lQNlNcCQX8Izqu6yD7lIQ4H+R Z4In7bDOanuUS7Xv1rl8Noh+pWIBYt5Tlu/hImt7gU5J3sUUI/6trb38m g==; X-CSE-ConnectionGUID: T4gF78TiQ7+r20Q5XAQLWA== X-CSE-MsgGUID: e0MKVOHoTZ2pAnR4vnFOjA== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8837609" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="8837609" X-CSE-ConnectionGUID: SLTL1c/PQsKDo57QFAAwZA== X-CSE-MsgGUID: weLucs5dT8ScFG3wHcvIQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="27507038" From: Zhao Liu To: Jonathan Cameron , Fan Ni , "Michael S . Tsirkin" , Marcel Apfelbaum Cc: qemu-devel@nongnu.org, Markus Armbruster , Zhao Liu Subject: [PATCH 3/3] hw/cxl/cxl-cdat: Make cxl_doe_cdat_init() return boolean Date: Thu, 18 Apr 2024 18:04:33 +0800 Message-Id: <20240418100433.1085447-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418100433.1085447-1-zhao1.liu@linux.intel.com> References: <20240418100433.1085447-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=192.198.163.17; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -59 X-Spam_score: -6.0 X-Spam_bar: ------ X-Spam_report: (-6.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.719, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1713433922913100003 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/cxl/cxl-cdat.c | 6 +++--- hw/mem/cxl_type3.c | 3 +-- hw/pci-bridge/cxl_upstream.c | 3 +-- include/hw/cxl/cxl_component.h | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index e7bc1380bfbf..959a55518e65 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 **e= rrp) return true; } =20 -void cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp) +bool cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp) { CDATObject *cdat =3D &cxl_cstate->cdat; =20 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); } } =20 diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index b0a7e9f11b64..3e42490b6ce8 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 **err= p) cxl_cstate->cdat.build_cdat_table =3D ct3_build_cdat_table; cxl_cstate->cdat.free_cdat_table =3D ct3_free_cdat_table; cxl_cstate->cdat.private =3D ct3d; - cxl_doe_cdat_init(cxl_cstate, errp); - if (*errp) { + if (!cxl_doe_cdat_init(cxl_cstate, errp)) { goto err_free_special_ops; } =20 diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index 783fa6adac19..e51221a5f334 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 =3D build_cdat_table; cxl_cstate->cdat.free_cdat_table =3D free_default_cdat_table; cxl_cstate->cdat.private =3D d; - cxl_doe_cdat_init(cxl_cstate, errp); - if (*errp) { + if (!cxl_doe_cdat_init(cxl_cstate, errp)) { goto err_cap; } =20 diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 5012fab6f763..945ee6ffd045 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); =20 -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); =20 --=20 2.34.1