cleanup some calls to strncmp()
Subsystems (2)
PATCH 1/1 cleanup some calls to strncmp()
The main motivation for this patch is that for the first strncmp() we do 'strncmp(src, "-", 20)' but "src" is a 15 character buffer not 20.
Also since we know that "-" is only two characters, the compare isn't going to go further than 2 characters into src before deciding that it doesn't match.
The same applies to the other strncmp()s. In those cases "str" is actually 10 characters so the limiter is correct but it is still not needed when the length for "adapter" and "firmware" is known and less than 10.
Signed-off-by Dan Carpenter <[email protected]>
drivers/scsi/scsi_sysfs.c +3 -3
@@ -84,7 +84,7 @@ static int check_set(unsigned int *val, char *src) {char *last; -if (strncmp (src,"-" ,20 ) =0 ) { +if (strcmp (src,"-" ) =0 ) { *val =SCAN_WILD_CARD ; }else {/*
@@ -249,9 +249,9 @@ static DEVICE_ATTR(active_mode, S_IRUGO | S_IWUSR, show_shost_active_mode, NULL)static int check_reset_type (char *str) { -if (strncmp (str,"adapter" ,10 ) =0 ) +if (strcmp (str,"adapter" ) =0 )return SCSI_ADAPTER_RESET ; -else if (strncmp (str,"firmware" ,10 ) =0 ) +else if (strcmp (str,"firmware" ) =0 )return SCSI_FIRMWARE_RESET ;else return 0 ;