On Nov 9, 2009, at 1:48 PM, Joe Perches wrote:
These might be corrected to sizeof("foo") - 1
arch/m68k/sun3/prom/console.c: if(strncmp(propb, "serial",
sizeof("serial")))
arch/m68k/sun3/prom/console.c: strncmp("display",
propb, sizeof("display")) == 0)
arch/m68k/sun3/prom/console.c: if(strncmp
("serial", propb, sizeof("serial")))
May I suggest:
// Expands to a value equal to strlen( str ), but for string
constants only,
// and in constant (zero) time instead of linear time.
#define STRLEN( str ) (sizeof "" str - 1)
// Expands to two comma-separated values -- the string constant and
its length.
#define STR_LEN( str ) str, STRLEN( str )
if ( strncmp( propb, STR_LEN( "serial" ) ) != 0 )
Also, since you know the length of one of the strings, you could
safely call memcmp() instead.
Josh
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html