From nobody Thu Oct 30 16:32:09 2025 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; dkim=fail; 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 1500922675681539.6487804265881; Mon, 24 Jul 2017 11:57:55 -0700 (PDT) Received: from localhost ([::1]:56485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZiYD-00086n-VP for importer@patchew.org; Mon, 24 Jul 2017 14:57:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZi6g-00011R-GE for qemu-devel@nongnu.org; Mon, 24 Jul 2017 14:29:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZi6f-0005e7-Gd for qemu-devel@nongnu.org; Mon, 24 Jul 2017 14:29:26 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:35796) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZi6f-0005dp-BQ; Mon, 24 Jul 2017 14:29:25 -0400 Received: by mail-qk0-x241.google.com with SMTP id k2so3227132qkf.2; Mon, 24 Jul 2017 11:29:25 -0700 (PDT) Received: from yoga.offpageads.com ([138.117.48.223]) by smtp.gmail.com with ESMTPSA id t57sm9033799qtt.18.2017.07.24.11.29.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 11:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cTPrwNR5Zh92wu/+TbrpewVtE8VS1FvcmNf5Q9/Fnek=; b=ulC5eaSiukVCEz6zyGNyU60m5eFnbYZCIBQBCRHUeGKCFBx0gv7amgZzBIcUtaMuac w7NkLbuX6R2a+9dMzupcwT37zrs1K2gyn2ZweOtmNYgHuRNiSjOzXKgOi/xFK93I4aam HBb3PwCqolNDJyCeJi4EynrpiSO3JSTRwJsYD1eFD/SO7ut6j36sVtiLGdJ1p9iOxdpr 087D/RqnqinP12HQEyyFHFEQa4SqYgMnjiZ71H7YoILDgFQtE/pLial20s+qNzCOQJCt QgXd/npbeS7c4uFXEp2AUXvjD20gNBqWavhwxrcl5JF+K8nWBfAgjKWao3YIXBMRHLZA AaFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=cTPrwNR5Zh92wu/+TbrpewVtE8VS1FvcmNf5Q9/Fnek=; b=GgSbc84T0clhnGm2n67uKyTMACHTgyBgrojcqZwRokza8pAJIJVFGLJMba6y7NiUK9 /vYZG4nyhR52IbK2ciKsREJOscSK4sLesiIhLsOzZlyfp6Z08buwoVwkTagR9owC/bmn vid5mxkYQXI9qXKBLlLBGpEM/95oJiEymWp1zeQQTeN8ZkhZSbzOBA8TC/AKygT2DGkJ O2+QBAU2aGFAD0UateBaDG5m3W9RirjpG/v65NKwy4VFLEeOQZudyWZXb52+vjiKR1Px RShjmzFP9Gph5mwJuHDiofAZxool1J+L5KbEJeHTclsXCt13StLtyqzwqGoI5wOQR2d5 qrFQ== X-Gm-Message-State: AIVw1106ngCpiRCaxE54lOBP8mnPIhb9rap40SvYNTtcGdCCg2QEaPol IA1QZcb0mGmxOA== X-Received: by 10.55.110.67 with SMTP id j64mr807725qkc.26.1500920964851; Mon, 24 Jul 2017 11:29:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Eric Blake , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Riku Voipio , Laurent Vivier Date: Mon, 24 Jul 2017 15:27:42 -0300 Message-Id: <20170724182751.18261-27-f4bug@amsat.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170724182751.18261-1-f4bug@amsat.org> References: <20170724182751.18261-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH for 2.10 26/35] 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: qemu-trivial@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 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 --- 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