strncmp uses in arch/m68k/sun3/prom/console.c
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")))Quoted 5 lines · Joe Perches
These might be corrected to
sizeof("foo")- 1arch/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