From patchwork Thu Jan 25 08:52:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Adami X-Patchwork-Id: 865796 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="HnzBqDgk"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ACTZ3dD/"; 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 3zRwmd0q9Vz9s1h for ; Thu, 25 Jan 2018 19:53:21 +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=8u8eV9ovywlNL35INvk1HgLQ4HFMpjQeNEV4esUEaN4=; b=HnzBqDgkHhje/nu/GDYn8ADqiu LlVUzJLwETLB92Z3uoV0kHZ4VqSAbINTwVSWV9jCZO+nnAWrBwowr22ChhQSOElDznY0fdBBF0fNh nFh9jVNFePDJL2DDcx00KJVtbn5z0PhAxr96CefNEj/LKbHNHr39xumXyGq8SGxHnFTAaLDv9/2VL 6aOY9jPBNuFZF1jSfPEMaqsJqmq5ZaqSEOvlOPdWWRW+rIRA0/++C1g62ajEBbftrgg/T4tKbz5Ts yCFHJb0BRab21TYrVBAS3SXpnADILhJMzPsa+tGwkK71cb260wfCOd0jtpqF0wij4p/2TQZAybWg3 Jb4c/PFg==; 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 1eedHX-0004Q9-RK; Thu, 25 Jan 2018 08:53:15 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eedHC-00041a-Ez for linux-mtd@lists.infradead.org; Thu, 25 Jan 2018 08:52:56 +0000 Received: by mail-wr0-x242.google.com with SMTP id 36so6806419wrh.1 for ; Thu, 25 Jan 2018 00:52:43 -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 :in-reply-to:references; bh=xc8tmu5sRMLD0tn0XXcEuv6FouAdWOxVQXUNKRSKjL0=; b=ACTZ3dD/UPyEwOPkTMCoK+rC0a8PipLq7yj3iA3LkTTCPeKl6vTPz6mNHQN+UhVp73 9CAJorryVlJtG8wvi9Vd4y1J9YQNedxhEErDcgDWXe4oiGrjks7OIFw3qgcP8FrhvvHn jllK+8hnnrcMdgnkwMnySdR4r9aRvAEiRaGu4ecWo8nSR9Jou5Fm/+Bb1OTaTJqoE/eq CwGMAoBPiHLbfN11vhgIxlRUURTL/Wrx+JS1UFRKoCCfcCNyfZV4NWMs6yT64hual6Xh WQpy0ouqsXFpR1doHmCS8hsvxRL8tVwIosw4EnB+s4hFehSjSMnmxuhkuiDxUiZYWB7Q vb0A== 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:in-reply-to:references; bh=xc8tmu5sRMLD0tn0XXcEuv6FouAdWOxVQXUNKRSKjL0=; b=R2kZH1KWOey5wyuCqXcQGbWZYUGf2uyDbDiEl7rKe9MlEJYDNw1o7pek5uKe8C232w +ybfxR9G91cligffgk092mdebO1gDm+xSlLyTK0qPEZcEH9hdb+wUDgCDQLcpx1UkOc8 eMo9UgdQxr0SSaJrqfiUM2F4YDX1cDvf9KlBYsbkK/RBD85qMEZvBJwhYDBbAn90nk+n tEs+J05zc8NCFNIpZUFTd6prjd+zYZrDiKm8TaRZ247xRt0oLXvJpv9U6G8l0pRMW3HQ 4S39MPimWgH3FDiIy5C5snvfSJZ2DbSsM3b6sPiKKsPPcRaGXHY9rRaIzo1/ahMi7mSu 0bWQ== X-Gm-Message-State: AKwxytcs7sG7Zqhg+7Q23QD8lDo105eynautpNnElFEQsgW17X5IaLoB LMHwqJmmaJnGGzLHTou5CWpdmw== X-Google-Smtp-Source: AH8x224xKvgXhEXqAgfySCEZhUrepL/1n1QTROAwx4DqqHtZ1ICWHbQy5aHmLRmQkpJa8syp3qphuQ== X-Received: by 10.223.160.228 with SMTP id n33mr8488553wrn.82.1516870362408; Thu, 25 Jan 2018 00:52:42 -0800 (PST) Received: from andrea-ThinkPad-T520.homenet.telecomitalia.it (host79-102-static.63-82-b.business.telecomitalia.it. [82.63.102.79]) by smtp.gmail.com with ESMTPSA id x203sm925140wmd.11.2018.01.25.00.52.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Jan 2018 00:52:41 -0800 (PST) From: Andrea Adami To: linux-mtd@lists.infradead.org Subject: [PATCH 2/2] ubi-utils: ubiformat.c: convert to integer arithmetic Date: Thu, 25 Jan 2018 09:52:38 +0100 Message-Id: <86bc7e1111a80d6938d623d29b926876b3563923.1516868053.git.andrea.adami@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: 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 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:242 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (andrea.adami[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 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 --- 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