From patchwork Thu Apr 25 11:01:45 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: 792045 Delivered-To: patch@linaro.org Received: by 2002:a5d:4884:0:b0:346:15ad:a2a with SMTP id g4csp1322489wrq; Thu, 25 Apr 2024 04:09:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXX5oWi3M8y+iuZte8gqKFzMpmDhaP9ph4yidxQfNem4zSi0FFHnSEGOs4g//N+8b3XuG1gul2Ca2zLSoCponyT X-Google-Smtp-Source: AGHT+IF69lz2Y0xKJubIXodIn71lxglFmfVuDvvnyGQ+GRIRSjXET019fUDECSJZT25vU4/pI6ve X-Received: by 2002:a0c:fcca:0:b0:69b:5c93:524a with SMTP id i10-20020a0cfcca000000b0069b5c93524amr6555871qvq.23.1714043367796; Thu, 25 Apr 2024 04:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714043367; cv=none; d=google.com; s=arc-20160816; b=hvY40niiK6WACsJIcqMQxe2e+mmz65xa3Hd2Wyt7pe94mhiMST8yEvr0UFp3pOOEEu 1S9aBv0EF81/8oPoWs9Ke2+OrhR5Uxnfh9yWQV2LCvHXt/r/JEjrExyGUiRLulV3PuJx drDwHFftFSYWNyV6NTN0PueleW25oYtI/P8sdDazr/XceJcNOVcorAAl5bun07vy5zMg pgcwc51W9Uw41P0ZZMjbvLYyMLnGG7uTFrcJbbtMvwXEvS1qyhGTnNDO57BoBH5kWRc3 GWR1q6Z8MUYO8DmXS6gCqXPUGpb7rM+xCzBnE2PBfeHW97Q+7W7mSQ6jXBrKeCHxUl5g s0pQ== 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=LU/r9zSSWOAgtXVFmIxCt1qMAeFSfB+B8bTVtMRUbL4=; fh=0/JVPH+45iPmEYqun5BjBLfJZs9+cI7lPo8sZDfCyNA=; b=h3BhFrjhTHx3ihjj1ZX7Fv5N2+wYZfp7wrD6/mABPFDoFqvCd2Z6WlNxZY+uu+whjr 8adwMiPy5oNFbUBrucSIej0WF/BUdrT9qc4GVuUO7FaI+c65qhs/LS9UIajhxGdYgOsg cX6jqAcsNGCFDVEUtt1Vy+U9YILHtP4k2wDjYX6qlfH/56nY0gOqtdlTNEVUEIZza5GK UzILd7K7fTCkRWj/Kz/9LSk5qUuFo73h5LwJzGgM4Hluuw0XGNbY6yyiYccwqyKyHqwf aX5lHVqjdTq2zduMRa78mKzNuXcWSV6c2pgyg0yp0Agqk8DEfFb6JHAQ1647k3niy64S h0OA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WrXR9xds; 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 y7-20020a0cec07000000b006a09702cdcdsi2788388qvo.485.2024.04.25.04.09.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 04:09:27 -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=WrXR9xds; 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 1rzwtv-0001UA-Am; Thu, 25 Apr 2024 07:04:27 -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 1rzwsn-0008VP-MQ for qemu-devel@nongnu.org; Thu, 25 Apr 2024 07:03:38 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzwsk-00007H-AO for qemu-devel@nongnu.org; Thu, 25 Apr 2024 07:03:16 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2def8e5ae60so4591341fa.2 for ; Thu, 25 Apr 2024 04:03:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714042989; x=1714647789; 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=LU/r9zSSWOAgtXVFmIxCt1qMAeFSfB+B8bTVtMRUbL4=; b=WrXR9xds2luym4J6tztK66DnJaf/wuj2yu2EDa583PaxoSFJwEWk1s2L1aNchIx+/r bbR9UZz7iFtrCvMuaaKDwy3TZsSwGW9zzUFnkKUtVogRlNYkQ18amTlZR9yb/pPExQ2j fjGvhqmzFGItbBbAjuHVlaCBQNbmXskDV7Snl6aLxO67SwCZGLsYvUI6KWzLAQQ/obJ8 MeQ9254Ek3cXhnTeh1ApAZ9/J5mkzleH+K9rKInF3B7Y1sQ4VXjXN0HdV+sqQ7CRQsXS xsVN1HokLi5KiqQA+3m7jZXt90Xy2TAVok0I9hsD2cFYXLzuWsODMcI6TuDobnVQOdTP 5GAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714042989; x=1714647789; 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=LU/r9zSSWOAgtXVFmIxCt1qMAeFSfB+B8bTVtMRUbL4=; b=nu2s1F0tXocxlkW19Um2yfxIqYJA9NKxfyGXv/B+AQvLbg+7x6k8AufPBtR0/3AswP usT0hPoR0qx8jl+L51fCJecDxzd9+/JriR6vcNR8OnB0qklxnf294IAcK6ePZZlym65b gAHw3ONgkxcLvkAGBe6zhXfHU0FaXbEMVJgGTXITR2A6wrhC175MtRQPiMz2Ggx88LLA QKlg4WeiyFYm4ee7oynGRzYJIo7HqbN2/ckjQjOyu+5NoULjUq6L8gt15TP1MqtPdyOg JAOpq7gDBW2uI/zfDaT4Fxvv923evef6gZO4xT2s9rA4vqZO/zIUZbykZsPiF2Oj26Er nKCg== X-Gm-Message-State: AOJu0Yx0dEjt7tKZ93PjPrSS53yX2mzHUmCJGY8xW4J62Ozk6LF9riWn xU0Azd2WSeKDZlri3jU+xAwwlI5i2glaLHyzl+8zlFHMvDrqDsa13A5V4y3VguMAyjIqlwTFQlI x X-Received: by 2002:a2e:954f:0:b0:2de:81c9:14b3 with SMTP id t15-20020a2e954f000000b002de81c914b3mr2837508ljh.35.1714042988935; Thu, 25 Apr 2024 04:03:08 -0700 (PDT) Received: from localhost.localdomain ([92.88.170.77]) by smtp.gmail.com with ESMTPSA id o20-20020a05600c511400b0041a49b10a13sm14955302wms.11.2024.04.25.04.03.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 25 Apr 2024 04:03:08 -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 Subject: [PULL 12/22] hw/cxl/cxl-cdat: Make ct3_load_cdat() return boolean Date: Thu, 25 Apr 2024 13:01:45 +0200 Message-ID: <20240425110157.20328-13-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::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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. 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 Reviewed-by: Philippe Mathieu-Daudé Acked-by: Jonathan Cameron Message-ID: <20240418100433.1085447-2-zhao1.liu@linux.intel.com> Signed-off-by: Philippe Mathieu-Daudé --- 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 551545f782..b3e496857a 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 **errp) cdat->entry = g_steal_pointer(&cdat_st); } -static void ct3_load_cdat(CDATObject *cdat, Error **errp) +static bool ct3_load_cdat(CDATObject *cdat, Error **errp) { g_autofree CDATEntry *cdat_st = NULL; g_autofree uint8_t *buf = NULL; @@ -127,11 +127,11 @@ static void ct3_load_cdat(CDATObject *cdat, Error **errp) &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 = sizeof(CDATTableHeader); num_ent = 1; @@ -139,19 +139,19 @@ static void ct3_load_cdat(CDATObject *cdat, Error **errp) hdr = (CDATSubHeader *)(buf + i); if (i + sizeof(CDATSubHeader) > file_size) { error_setg(errp, "CDAT: Truncated table"); - return; + return false; } cdat_len_check(hdr, errp); i += hdr->length; if (i > file_size) { error_setg(errp, "CDAT: Truncated table"); - return; + return false; } num_ent++; } if (i != file_size) { error_setg(errp, "CDAT: File length mismatch"); - return; + return false; } cdat_st = g_new0(CDATEntry, num_ent); @@ -185,6 +185,7 @@ static void ct3_load_cdat(CDATObject *cdat, Error **errp) cdat->entry_len = num_ent; cdat->entry = g_steal_pointer(&cdat_st); cdat->buf = g_steal_pointer(&buf); + return true; } void cxl_doe_cdat_init(CXLComponentState *cxl_cstate, Error **errp)