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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 12 Aug 2010 00:43:34 +0200
From:	Denys Vlasenko <vda.linux@...glemail.com>
To:	Michal Nazarewicz <mina86@...a86.com>
Cc:	linux-kernel@...r.kernel.org, m.nazarewicz@...sung.com,
	Andrew Morton <akpm@...ux-foundation.org>,
	"Douglas W. Jones" <jones@...uiowa.edu>
Subject: Re: [PATCHv3 1/2] lib: vsprintf: optimised put_dec() function

On Wednesday 11 August 2010 23:58, Michal Nazarewicz wrote:
> +static noinline_for_stack
> +char *put_dec(char *buf, unsigned long long n)
> +{
> +	uint32_t d3, d2, d1, q;
> +
> +	if (n < 10) {
> +		*buf++ = '0' + (unsigned)n;
> +		return buf;
> +	}

I looked at it and discovered that 0 is already special-cased
at put_dec() callsite. You can drop the above if() block
(or better comment it out, explaining that caller does it),
and while at it, improve special-case code in number():
replace

        /* generate full string in tmp[], in reverse order */
        i = 0;
        if (num == 0)
                tmp[i++] = '0';

with

        if (num <= 7)
                tmp[i++] = '0' + num;

(7, not 9, because it can be an octal conversion).


> +	q   = q / 10000;
> +	buf = put_dec_full4(buf, q % 10000);

Bug. You need to use temporary variable to store q / 10000 result.

-- 
vda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ