From nobody Tue Feb 10 12:59:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528801282415359.1129414998063; Tue, 12 Jun 2018 04:01:22 -0700 (PDT) Received: from localhost ([::1]:54476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSh3B-0005EP-Ef for importer@patchew.org; Tue, 12 Jun 2018 07:01:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSh1E-0003q5-VS for qemu-devel@nongnu.org; Tue, 12 Jun 2018 06:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSh1A-0007Nq-4z for qemu-devel@nongnu.org; Tue, 12 Jun 2018 06:59:21 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:37433) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSh19-0007NK-RO for qemu-devel@nongnu.org; Tue, 12 Jun 2018 06:59:16 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0MP3gp-1fMNTe1r9T-006S9e; Tue, 12 Jun 2018 12:58:37 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Tue, 12 Jun 2018 12:58:25 +0200 Message-Id: <20180612105831.25703-3-laurent@vivier.eu> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180612105831.25703-1-laurent@vivier.eu> References: <20180612105831.25703-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:UTRBZyPvnCS5BAg/NReWI7PgjUtHTgbGFj3pjBZhxyigQRYU/cD /UupPFZOVlfL8dTg4r9GKtD6xZcc7VQF3z2KJqmBi1JmOYoPD+I1D1AXbHS9bOyQXePrAE2 rYLxEfFB6bHg32Hl/UMSQ0o6soQ/IWu9zAcBSNHq7xEyTHCAeDOUra91+tOOZNpY9ag+Rqy 7YurYCxhClQHJYb3iJRjg== X-UI-Out-Filterresults: notjunk:1;V01:K0:zBh+JfGeNTE=:ja3ERJsFAte9TKsQLfHEWD XtwpaFWEUTEPqgnp9fuI8W0M7gPZnpr/WyAk+cAOFRPv5IJsVBr/nMlOMFfryolV5XDbV+B0i TsKEYzZJqMaT5alHt5kOKHg1Jqm1UUGuPqzxGwoIy8Ow/BjlYCA7R7KiPxlJNa9p2qZOEgtu9 OrHqTIw6doq59AvjeTLm2S3HrMjzOrxQIuGLmx9SaD7/1cteL32RM/XeVSR9LpnhLxM3aXqjq 8hxVMgDG9WV8k2HVl8IyJLyEth7LgPNPV95ZMFNcL6PpedUgDf/slR+FTidurzLbKk2l9bGJy u/5RoD32ogXnYJ51j238Wmtyx6kok4CzmwQyLCcTp2WcvpfO4S/O/HwQk4s0JG2ns3w72SH57 hgcbo4MQBN/q4bXooOarxWz3kPMgR5tSupq+rr+43/saLnFkCoTSsxuFU986ZIvI902eRT3Xe 4omZqDy7OtRV2HGlffjJeC3ZWMS6zoayZIkd1gu2akmT8MtGpc6t+VOl1KEzXSMHrvyf6Fydw A1DDmX4rJs4Vgua9WM6Kpqj0m72NLzK9PdNk3655oYG93oqvgoodgeUMlyg+1araTz4WR5v2D YdctPqlQbvK0cGqrvMz9Kk8zLicHBxSIhYQ1eceKxH4H9gjQ8O+wf304kqKmKri7btncc7Cjm d5dWM0kGEqsux/QwCWaNAClNv29h8Zgju/S04cKEPadanNo5/OwQivsLp91AEqIGC0zsQkHv4 Aaa3qLOE/pQlAOlv X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.130 Subject: [Qemu-devel] [PULL 2/8] linux-user: Use is_error() to avoid warnings and make the code clearer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 From: Philippe Mathieu-Daud=C3=A9 This fixes: linux-user/flatload.c:740:9: warning: Loss of sign in implicit conversion if (res > (unsigned long)-4096) ^~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Laurent Vivier Message-Id: <20180604153722.24956-3-f4bug@amsat.org> Signed-off-by: Laurent Vivier --- linux-user/flatload.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/linux-user/flatload.c b/linux-user/flatload.c index a35a560904..10c529910f 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -224,8 +224,9 @@ static int decompress_exec( ret =3D bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos); if (ret <=3D 0) break; - if (ret >=3D (unsigned long) -4096) + if (is_error(ret)) { break; + } len -=3D ret; =20 strm.next_in =3D buf; @@ -283,8 +284,7 @@ calc_reloc(abi_ulong r, struct lib_info *p, int curid, = int internalp) "in same module (%d !=3D %d)\n", (unsigned) r, curid, id); goto failed; - } else if ( ! p[id].loaded && - load_flat_shared_library(id, p) > (unsigned long) -409= 6) { + } else if (!p[id].loaded && is_error(load_flat_shared_library(id, = p))) { fprintf(stderr, "BINFMT_FLAT: failed to load library %d\n", id= ); goto failed; } @@ -523,9 +523,10 @@ static int load_flat_file(struct linux_binprm * bprm, fpos =3D 0; result =3D bprm->file->f_op->read(bprm->file, (char *) textpos, text_len, &fpos); - if (result < (unsigned long) -4096) + if (!is_error(result)) { result =3D decompress_exec(bprm, text_len, (char *= ) datapos, data_len + (relocs * sizeof(unsig= ned long)), 0); + } } else #endif @@ -693,8 +694,9 @@ static int load_flat_shared_library(int id, struct lib_= info *libs) =20 res =3D prepare_binprm(&bprm); =20 - if (res <=3D (unsigned long)-4096) + if (!is_error(res)) { res =3D load_flat_file(&bprm, libs, id, NULL); + } if (bprm.file) { allow_write_access(bprm.file); fput(bprm.file); @@ -737,8 +739,9 @@ int load_flt_binary(struct linux_binprm *bprm, struct i= mage_info *info) =20 =20 res =3D load_flat_file(bprm, libinfo, 0, &stack_len); - if (res > (unsigned long)-4096) + if (is_error(res)) { return res; + } =20 /* Update data segment pointers for all libraries */ for (i=3D0; i