From nobody Mon Feb 9 15:29:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626185814631169.21250258190673; Tue, 13 Jul 2021 07:16:54 -0700 (PDT) Received: from localhost ([::1]:59510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3JDR-0005Xj-J1 for importer@patchew.org; Tue, 13 Jul 2021 10:16:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3IkR-00012x-GM; Tue, 13 Jul 2021 09:46:55 -0400 Received: from ozlabs.ru ([107.174.27.60]:44198) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3IkO-0000Tz-NC; Tue, 13 Jul 2021 09:46:54 -0400 Received: from fstn1-p1.ozlabs.ibm.com. (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id E141DAE80042; Tue, 13 Jul 2021 09:46:43 -0400 (EDT) From: Alexey Kardashevskiy To: qemu-ppc@nongnu.org Subject: [PATCH qemu] ppc/vof: Fix Coverity issues Date: Tue, 13 Jul 2021 23:46:38 +1000 Message-Id: <20210713134638.1803316-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.30.2 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=107.174.27.60; envelope-from=aik@ozlabs.ru; helo=ozlabs.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , Peter Maydell , David Gibson , qemu-devel@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1626185817297100001 Content-Type: text/plain; charset="utf-8" This fixes NEGATIVE_RETURNS, OVERRUN issues reported by the Coverity. This adds a comment about the return parameters number in the VOF hcall. The reason for such counting is to keep the numbers look the same in vof_client_handle() and the Linux (an OF client). Signed-off-by: Alexey Kardashevskiy --- Will this make COverity happy? What is the canonical way of fixing these uint32_t vs. int? Thanks, --- hw/ppc/vof.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c index 81f65962156c..872f671babbe 100644 --- a/hw/ppc/vof.c +++ b/hw/ppc/vof.c @@ -517,7 +517,7 @@ static uint32_t vof_instance_to_package(Vof *vof, uint3= 2_t ihandle) static uint32_t vof_package_to_path(const void *fdt, uint32_t phandle, uint32_t buf, uint32_t len) { - uint32_t ret =3D -1; + int ret =3D -1; char tmp[VOF_MAX_PATH] =3D ""; =20 ret =3D phandle_to_path(fdt, phandle, tmp, sizeof(tmp)); @@ -529,13 +529,13 @@ static uint32_t vof_package_to_path(const void *fdt, = uint32_t phandle, =20 trace_vof_package_to_path(phandle, tmp, ret); =20 - return ret; + return (uint32_t) ret; } =20 static uint32_t vof_instance_to_path(void *fdt, Vof *vof, uint32_t ihandle, uint32_t buf, uint32_t len) { - uint32_t ret =3D -1; + int ret =3D -1; uint32_t phandle =3D vof_instance_to_package(vof, ihandle); char tmp[VOF_MAX_PATH] =3D ""; =20 @@ -549,7 +549,7 @@ static uint32_t vof_instance_to_path(void *fdt, Vof *vo= f, uint32_t ihandle, } trace_vof_instance_to_path(ihandle, phandle, tmp, ret); =20 - return ret; + return (uint32_t) ret; } =20 static uint32_t vof_write(Vof *vof, uint32_t ihandle, uint32_t buf, @@ -965,11 +965,15 @@ int vof_client_call(MachineState *ms, Vof *vof, void = *fdt, } =20 nret =3D be32_to_cpu(args_be.nret); + if (nret > ARRAY_SIZE(args_be.args) - nargs) { + return -EINVAL; + } ret =3D vof_client_handle(ms, fdt, vof, service, args, nargs, rets, nr= et); if (!nret) { return 0; } =20 + /* @nrets includes the value which this function returns */ args_be.args[nargs] =3D cpu_to_be32(ret); for (i =3D 1; i < nret; ++i) { args_be.args[nargs + i] =3D cpu_to_be32(rets[i - 1]); --=20 2.30.2