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:	Wed, 16 Sep 2015 13:44:08 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Aaro Koskinen' <aaro.koskinen@....fi>,
	Eric Curtin <ericcurtin17@...il.com>
CC:	"valentina.manea.m@...il.com" <valentina.manea.m@...il.com>,
	"shuah.kh@...sung.com" <shuah.kh@...sung.com>,
	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: tools: usbip: detach: avoid calling strlen() at each iteration

From: Aaro Koskinen
> Sent: 15 September 2015 21:56
...
> > -	for (unsigned int i = 0; i < strlen(port); i++)
> > +	unsigned int port_len = strlen(port);
> > +
> > +	for (unsigned int i = 0; i < port_len; i++)
> 
> port is read only in this function, so maybe just use "const" and the
> compiler should know to do the same without adding a new variable?

While I've seen the compiler make the assumption, I'm not sure
it should assume that data that is 'const' in one function cannot
be modified by a called function.
(Unless the compiler has some way of knowing that the called function
cannot obtain a non-const pointer to the referenced data.)
(This is also independent of whether the const pointer is passed
to the function.) 

	David

--
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