From patchwork Tue Jun 12 10:58:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 928266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 414n3838jjz9s1B for ; Tue, 12 Jun 2018 21:00:04 +1000 (AEST) Received: from localhost ([::1]:54466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSh1u-0003tp-3d for incoming@patchwork.ozlabs.org; Tue, 12 Jun 2018 07:00:02 -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 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_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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é 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 = bprm->file->f_op->read(bprm->file, buf, LBUFSIZE, &fpos); if (ret <= 0) break; - if (ret >= (unsigned long) -4096) + if (is_error(ret)) { break; + } len -= ret; strm.next_in = buf; @@ -283,8 +284,7 @@ calc_reloc(abi_ulong r, struct lib_info *p, int curid, int internalp) "in same module (%d != %d)\n", (unsigned) r, curid, id); goto failed; - } else if ( ! p[id].loaded && - load_flat_shared_library(id, p) > (unsigned long) -4096) { + } 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 = 0; result = bprm->file->f_op->read(bprm->file, (char *) textpos, text_len, &fpos); - if (result < (unsigned long) -4096) + if (!is_error(result)) { result = decompress_exec(bprm, text_len, (char *) datapos, data_len + (relocs * sizeof(unsigned long)), 0); + } } else #endif @@ -693,8 +694,9 @@ static int load_flat_shared_library(int id, struct lib_info *libs) res = prepare_binprm(&bprm); - if (res <= (unsigned long)-4096) + if (!is_error(res)) { res = 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 image_info *info) res = load_flat_file(bprm, libinfo, 0, &stack_len); - if (res > (unsigned long)-4096) + if (is_error(res)) { return res; + } /* Update data segment pointers for all libraries */ for (i=0; i