lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 15 Jan 2016 00:23:41 +0200
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	Robert Elliott <elliott@....com>,
	Matt Fleming <matt@...eblueprint.co.uk>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Brian Norris <computersforpeace@...il.com>,
	Hariprasad S <hariprasad@...lsio.com>
Cc:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 11/11] pcmciamtd: print value in human-readable form via %.0plKM

Recently added %pl[From[To]] specifier is dedicated to print values in
human-readable format with IEC prefix. Convert the code to use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 drivers/mtd/maps/pcmciamtd.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 70bb403..44c2fe9 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -589,19 +589,11 @@ static int pcmciamtd_config(struct pcmcia_device *link)
 	mtd->owner = THIS_MODULE;
 
 	if(new_name) {
-		int size = 0;
-		char unit = ' ';
 		/* Since we are using a default name, make it better by adding
 		 * in the size
 		 */
-		if(mtd->size < 1048576) { /* <1MiB in size, show size in KiB */
-			size = mtd->size >> 10;
-			unit = 'K';
-		} else {
-			size = mtd->size >> 20;
-			unit = 'M';
-		}
-		snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%d%ciB %s", size, unit, "PCMCIA Memory card");
+		snprintf(dev->mtd_name, sizeof(dev->mtd_name), "%.0plKM %s",
+			 &mtd->size, "PCMCIA Memory card");
 	}
 
 	/* If the memory found is fits completely into the mapped PCMCIA window,
-- 
2.6.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ