
13 Feb
2008
13 Feb
'08
5:06 p.m.
On Wed, Feb 13, 2008 at 03:20:56PM +0100, Andreas Schweigstill wrote:
- /* Validate arguments */
- if ((argc != 5) || (strlen(argv[3]) != 1)) {
printf("Usage:\n%s\n", cmdtp->usage);
return 1;
- }
May we rely on the compiler optimizing the above expression so strlen() != 1 will only be evaluated if argc == 5 ?
Short-circuit evaluation isn't optimization, it's the semantics of the C language.
-Scott