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]
Message-ID: <20141104114421.6a7f9de5@leda.localdomain>
Date:	Tue, 4 Nov 2014 11:44:21 +0100
From:	Christian Hesse <mail@...rm.de>
To:	Stephen Hemminger <stephen@...workplumber.org>
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH 1/1] ip-link: in human readable output use dynamic
 precision length

Christian Hesse <mail@...rm.de> on Tue, 2014/11/04 10:39:
> Now that we use floating point numbers for human readable output we can
> calculate precision length on the fly.
> ---
>  ip/ipaddress.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index e240bb5..0ddcb0d 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -343,8 +343,8 @@ static void print_num(FILE *fp, unsigned width,
> uint64_t count) ++prefix;
>  	}
>  
> -	snprintf(buf, sizeof(buf), "%.1f%c%s", (double) count / powi, 
> -		 *prefix, use_iec ? "i" : "");
> +	snprintf(buf, sizeof(buf), "%.*f%c%s", 3 - snprintf(NULL, 0,
> "%"PRIu64, count / powi),
> +		(double) count / powi, *prefix, use_iec ? "i" : "");
>  
>  	fprintf(fp, "%-*s ", width, buf);
>  }

Damn... In IEC mode we have negative precision length for values between 1000
and 1024. Will send a new patch.
-- 
Best Regards,
Christian Hesse

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ