From nobody Sun May 5 10:21:01 2024 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 1528127975283902.1479223259287; Mon, 4 Jun 2018 08:59:35 -0700 (PDT) Received: from localhost ([::1]:40578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPrtO-0001ZH-Gz for importer@patchew.org; Mon, 04 Jun 2018 11:59:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPrY4-00007d-FH for qemu-devel@nongnu.org; Mon, 04 Jun 2018 11:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPrY3-00066S-Jr for qemu-devel@nongnu.org; Mon, 04 Jun 2018 11:37:32 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:40028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPrY3-00066M-Fy for qemu-devel@nongnu.org; Mon, 04 Jun 2018 11:37:31 -0400 Received: by mail-qt0-x244.google.com with SMTP id q6-v6so7098308qtn.7 for ; Mon, 04 Jun 2018 08:37:31 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id q5-v6sm14342276qkd.51.2018.06.04.08.37.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 08:37:30 -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=u3waZ2Rwqek9lSHV+vru3Lt8biIgbawuCJ3dSGhnrow=; b=vEJz89iW0Omq3B2e8OZD1WaaxBfqdmTkGpmIFu42Jp9t2z3ataioSCPlV2A6hZt6UW MmS8rstlWaxCSpwFNLfp956SYF0JSyHaByeDoOJQMp0MZNw9xsWEq3US+cZvyZ9IiSVx /mIXoHnOYta37Cyz+4uoZo1vXzG7LA20zjDClUZJQk8CAWzlO5zCJWUxljhb9dywFMVN hldBrwNGaMYmTU6+aB7fGH2ExJDopuwm6xE1HoA0DW1+eSTPQ4El0F94ZLxW8uaj1tVQ mG+vL8Y9JD0tTNoVPnUJyuhFaWE1WWiKfzbGadI9smjYFFCBorjYXiYxosLrbJhCnkW0 vy8w== 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=u3waZ2Rwqek9lSHV+vru3Lt8biIgbawuCJ3dSGhnrow=; b=H5UJ1Gl/7AGmWwV5+8UlCaCx4Br+oW8sqKx+Z+kacjrkk64HSokc3MZcZ3Bg7rlanP P9s9HwZLBdDuB7tKmiHgWX356tl9JQ0M6cH3hFC1pE2GujTDxX5q85PGVAhIQe5d42ZL OUfT+hju1ZA1Z1ynAzp12yf3shoLEuQV3yqhnytdWov57irvapVqVLQRwEw8FbrEUIXC NZmWSJ73Z/eLi1PvNGX6KvuHFl0YAuEslf+IY7q6/xav3opHL94LMp9Jn64ymEDk7kwn 4mzpY23hyz5UpPv0Yv9PIattG2I4hqAey11HV1g4HnN5HA/Nhe+c9BlWq5GUoEPabQ2K 37DA== X-Gm-Message-State: APt69E2vJtKQz1ozd0dM0WAu6kFoUvhsc5fMq5ImX9XCRuYbIAM6ymKn Ws/w9W40/7+Q6HB3pTmn+xCy8o0+ X-Google-Smtp-Source: ADUXVKJRKlKK5HRsBmLryNEhwCbYpNUf55jdSaLvJ7hw6SE+XX9MAF4VFDDFVlFxrbeyZbF5NN9ppQ== X-Received: by 2002:a0c:9ccb:: with SMTP id j11-v6mr20731644qvf.58.1528126651023; Mon, 04 Jun 2018 08:37:31 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Laurent Vivier Date: Mon, 4 Jun 2018 12:37:21 -0300 Message-Id: <20180604153722.24956-2-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180604153722.24956-1-f4bug@amsat.org> References: <20180604153722.24956-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:c0d::244 Subject: [Qemu-devel] [PATCH RESEND v2 1/2] linux-user: Export use is_error(), use it to avoid warnings 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 , =?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 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 --- linux-user/qemu.h | 5 +++++ linux-user/syscall.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index c55c8e294b..4eeffe3c76 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -618,6 +618,11 @@ static inline void *lock_user_string(abi_ulong guest_a= ddr) =20 #include =20 +static inline int is_error(abi_long ret) +{ + return (abi_ulong)ret >=3D (abi_ulong)(-4096); +} + /* Include target-specific struct and function definitions; * they may need access to the target-independent structures * above, so include them last. diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d02c16bbc6..5e122dbdda 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -906,11 +906,6 @@ static inline abi_long get_errno(abi_long ret) return ret; } =20 -static inline int is_error(abi_long ret) -{ - return (abi_ulong)ret >=3D (abi_ulong)(-4096); -} - const char *target_strerror(int err) { if (err =3D=3D TARGET_ERESTARTSYS) { --=20 2.17.1 From nobody Sun May 5 10:21:01 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528128157984557.7207661957153; Mon, 4 Jun 2018 09:02:37 -0700 (PDT) Received: from localhost ([::1]:40625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPrwA-0003xe-4w for importer@patchew.org; Mon, 04 Jun 2018 12:02:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPrY6-00009n-OX for qemu-devel@nongnu.org; Mon, 04 Jun 2018 11:37:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPrY5-00067Y-Rw for qemu-devel@nongnu.org; Mon, 04 Jun 2018 11:37:34 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:41866) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPrY5-00067P-No for qemu-devel@nongnu.org; Mon, 04 Jun 2018 11:37:33 -0400 Received: by mail-qt0-x244.google.com with SMTP id y20-v6so14760661qto.8 for ; Mon, 04 Jun 2018 08:37:33 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id q5-v6sm14342276qkd.51.2018.06.04.08.37.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 08:37:32 -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=nJ77JOjeVWuYkiO1v5GxepD1Cdk8GMyS+MDjxIIPmsE=; b=ITDJLH0DOSnGSlXqk7wpW3DmDBrQT/alY8ONLGPy8FE5qxYWNjd0EwPJQYICyMawIF 5ayYA2H7U9VqjwxdHoqbO1QhvQ5it/hnI144z2VG24U4b+cKr/y29FMmlntQmp4bvtAE PuUKXYhbdQgRX+i2q68GW+tiRSWfS1i4i/kU/liOSh12acnJHISgOKOJX79rBwJn15K8 DNdskuUdE2rk2rMbCDy/N5cDJCoYQQ8AdIanoiT0gV2Gh9NWpAozzscXtQY3Xt/CIezx hgeqCI+oNjzcZBIiU02IZ2/nJ3hs4MVxfkspDc8VVQYgNBpS05Rx0X7ggkigPbUU/9Hb BVrg== 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=nJ77JOjeVWuYkiO1v5GxepD1Cdk8GMyS+MDjxIIPmsE=; b=XEBiY0y35TxT3tXDwwqpBVIP0nGvsmCFn4/ZsTIEiVuatQe1C/TfIulr4DXtPFU0hL lccgaRyh9D6CQ2hV5bUgj9cun7SjojSulDsUQFQwWtRiNOSEOhlSlPBdz1C1wjdZZ7xA iS8Yxsr68lwKTG5XbUtoBOKLjz7DBrV4t0AUDB81yyzEE2a5A65MunJkyr4LenYSXsSH QhwZyLDwCO7FUo7TfvlRRG8loKcAv/xdtp6M2tfbFxAz7qnRDNQox0JXtHQ0HEBqRNoh M6ItXW02fiz0WGZDNAcUcALTsWA4MYXqdFKEEbY/hcX6NA+EgaENWtO9xNsSk608hdfo TTCA== X-Gm-Message-State: APt69E3Ivb90pn5Wx70NCutaQ9w1LQ+T75Er10TJK82Zl9qYg7G++gbo GDSjLJfdGg603EO4U8CWZYY= X-Google-Smtp-Source: ADUXVKJw4WBWX3BCn0eAB6tPbqgtl0dIx/F1wxffZaOvXC+D0mmFszO3C+N8raSk5McZXvHtI/hntw== X-Received: by 2002:a0c:81b2:: with SMTP id 47-v6mr20484186qvd.31.1528126653246; Mon, 04 Jun 2018 08:37:33 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Laurent Vivier Date: Mon, 4 Jun 2018 12:37:22 -0300 Message-Id: <20180604153722.24956-3-f4bug@amsat.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180604153722.24956-1-f4bug@amsat.org> References: <20180604153722.24956-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:c0d::244 Subject: [Qemu-devel] [PATCH RESEND v2 2/2] 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 , =?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 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 --- 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