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] [day] [month] [year] [list]
Message-ID: <20080415104503.GA27459@ZenIV.linux.org.uk>
Date:	Tue, 15 Apr 2008 11:45:03 +0100
From:	Al Viro <viro@...IV.linux.org.uk>
To:	"YOSHIFUJI Hideaki / ?$B5HF#1QL@" <yoshfuji@...ux-ipv6.org>
Cc:	davem@...emloft.net, netdev@...r.kernel.org
Subject: Re: [RFC PATCH net-2.6.26 (Plan A)] [TCP]: Lower stack usage in tcp4_seq_show().

On Tue, Apr 15, 2008 at 07:24:34PM +0900, YOSHIFUJI Hideaki / ?$B5HF#1QL@ wrote:
> tcp4_seq_show() eats about 250 bytes.  By using buffer in seq_file
> directly, it will be reduced under 100 bytes.
> 
> One drawback is slight change of the format - the format was fixed
> size and now its size is variable.
> However, size of the line was 128 bytes in 2.2, and 150 bytes in 2.6,
> so the change may not matter, probably.

> -	sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
> -		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p",
> +	seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
> +		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p\n",

Or you can just do
	int len;
	...
	seq_printf(seq, "%4d: %08X:%04X %08X:%04X"
		" %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %p%n",
>  		i,
>  		ireq->loc_addr,
>  		ntohs(inet_sk(sk)->sport),
		...,
		&len);
	seq_printf("%*s\n", TMPSZ - 1 - len, "");

and be done with that, keeping the output unchanged.  That's exactly what
%n is for - it allows to get the width of output so far, precisely for
such situations.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ