From patchwork Mon Jan 29 22:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Adami X-Patchwork-Id: 867332 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZdjbeyR3"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="R2OKbLNM"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zVkCc3zH4z9sBd for ; Tue, 30 Jan 2018 09:07:56 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=cJl6Cid9/thpzhYkiaLN68sT/4u5YUh+ejQlpmQG5/g=; b=ZdjbeyR3hacgB6sHou8DqBUXDc TxSwnTK3JiVZdWS/j/WGeJ1/6Vk0GFfbAvpV76EwPmcLLf1X5XdT2WK9FUdXH0Jp0lLnEQuhzU43U fS/AK/bhWTAep8jEmQk2ti/4LdnZ7U7KGJi6Nq8g7gD0AzGz0q0qPMEA5wkEvX9YyqnKqcZGTpGZb lPn9qIism/7oeEYAiMOtMPHgVhyIdDueFAp7w+jbX/FJU75g+k4RATyRKu09uRfU24e0yjyq9wLrn yALjUaWkWSAUxl2D7uFSV9DexcM0BOhkZyCoSzwbfVhhM3RW4Toj0zSPBntO9HYrMVFLjgje4gvL3 l0tJ/QvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1egHah-0001Tp-8S; Mon, 29 Jan 2018 22:07:51 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1egHaK-00010u-AM for linux-mtd@lists.infradead.org; Mon, 29 Jan 2018 22:07:30 +0000 Received: by mail-wm0-x242.google.com with SMTP id x4so902432wmc.0 for ; Mon, 29 Jan 2018 14:07:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QZyp4EjZsz+YG5ddKdDKT6EWEttdMG9o+GFwxHT80dM=; b=R2OKbLNMIPNnviWFH39ku3xVsVMMq22W01PLAwu2KBf5bqtq86Gp9uzgTHi5rmJ3xT /OQ+Ho5bsuihnBg5t6L1UXM4AccYeZ/g/x65bOO6nP4CIhB/2wU+d7UW/UIOZhAfnwwH BIjfV/z71tURTQpf3+zuyFJXIhfXRA3UG2xengAAxPGA98T2fQjHg1QeUvtZrea7q7II dhzwYaB9d12uGQSjQtwhptDYbHmW8bVHuOFhrC5jmlxPZP0nEbaLgkZvYrhqsUuUGDzo cpNTEAAVFCdCs6QVVbg6ZbdddeuM7s2oDthzCXh7xAYI1IHv59PExwgRt0Br2ty5G9Kb 5aCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QZyp4EjZsz+YG5ddKdDKT6EWEttdMG9o+GFwxHT80dM=; b=roFPSymnn17va3Mq/716U+ihOp4jn0gdu+vdFZDYBDm5AJMY74X1ufGd3WZRYTCVCJ ROaRSqDv2Uq19levir9v5AIsUReYomP/I/VFM9c3iv6ZlcB1xaF1a+wa3TTAuFDeOg/q HQFt7WXuDawHG3WfPjl+klX25b+S8irnOrsqjX3EtxNt3mCWhr+XNrtMuaEzxggc4DPW P2GPL1QLjejI0GZmqtN6aZUB29uVS7PwcLPn/06eYHUcHDLshkAQ9ZO07GaBG6bADfvL 1NPxjSkPM9nGb4xdu5574QayRFqptH15hC5CUiTXX3KFbIOkUhfOMT4HbwgHURjBYZd0 PqEg== X-Gm-Message-State: AKwxyteG3OciZM9vmAB9TsPiAZU5//JYJR9IzfgGuVa6bllVZDgM9cET maTWOWT93nhT6wOSNDx5ziCh4w== X-Google-Smtp-Source: AH8x227g/kje0YCWdRw24UQf9XBpwnQRojeQnn2pw0h0y85v3UeCJQl0a+WCsyZ9nR7lniRBHyHSNQ== X-Received: by 10.28.227.70 with SMTP id a67mr17950729wmh.46.1517263636031; Mon, 29 Jan 2018 14:07:16 -0800 (PST) Received: from andrea-ThinkPad-T520.homenet.telecomitalia.it (host57-10-dynamic.248-95-r.retail.telecomitalia.it. [95.248.10.57]) by smtp.gmail.com with ESMTPSA id v22sm13334832wra.58.2018.01.29.14.07.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Jan 2018 14:07:15 -0800 (PST) From: Andrea Adami To: linux-mtd@lists.infradead.org Subject: [PATCH v2 2/2] ubi-utils: ubiformat.c: convert to integer arithmetic Date: Mon, 29 Jan 2018 23:07:12 +0100 Message-Id: <1517263632-11126-3-git-send-email-andrea.adami@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517263632-11126-1-git-send-email-andrea.adami@gmail.com> References: <1517263632-11126-1-git-send-email-andrea.adami@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (andrea.adami[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:242 listed in] [list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Oberhollenzer MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Do not cast percent to double, it is just used as upper limit. Avoid floating point to fix compilation for aarch64 against klibc: error: '-mgeneral-regs-only' is incompatible with floating-point code | int percent = ((double)si->ok_cnt)/si->good_cnt * 100; | ^~~~~~~ Notes: * The checks in the code above this line ensure that si->good_cnt is not 0. * The code assumes si->good_cnt * 100 will not overflow, then we can use (si->ok_cnt * 100) safely because the former is bigger. * The truncated result does not affect the logic: i.e. a value of 49.9 is truncated to 49 and is still <50. Signed-off-by: Andrea Adami --- v2 no changes ubi-utils/ubiformat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c index ef0378a..c38b9b4 100644 --- a/ubi-utils/ubiformat.c +++ b/ubi-utils/ubiformat.c @@ -844,7 +844,7 @@ int main(int argc, char * const argv[]) } if (!args.override_ec && si->empty_cnt < si->good_cnt) { - int percent = ((double)si->ok_cnt)/si->good_cnt * 100; + int percent = (si->ok_cnt * 100) / si->good_cnt; /* * Make sure the majority of eraseblocks have valid