iscsi-target: remove some dead code
Subsystems (3)
PATCH 1/1 iscsi-target: remove some dead code
Neither "acceptor_values" nor "proposer_values" can be NULL here. Smatch complains because we are not allowed to pass NULL pointers to strchr().
Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition.
---
Compile tested only. Please review carefully.
drivers/target/iscsi/iscsi_target_parameters.c +0 -9
@@ -1037,13 +1037,6 @@ static char *iscsi_check_valuelist_for_support( tmp2 =strchr (acceptor_values,',' );if (tmp2) *tmp2 ='\0' ; -if (!acceptor_values || !proposer_values) { -if (tmp1) - *tmp1 =',' ; -if (tmp2) - *tmp2 =',' ; -return NULL ; - }if (!strcmp (acceptor_values, proposer_values)) {if (tmp2) *tmp2 =',' ;
@@ -1053,8 +1046,6 @@ static char *iscsi_check_valuelist_for_support( *tmp2++ =',' ; acceptor_values = tmp2; -if (!acceptor_values) -break ; }while (acceptor_values);if (tmp1) *tmp1++ =',' ;
Nicholas A. Bellinger
AppliedHello DanC,
Quoted 16 lines · Dan Carpenter
Neither "
acceptor_values" nor "proposer_values" can be NULL here. Smatch complains because we are not allowed to pass NULL pointers tostrchr().Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition.
Signed-off-by Dan Carpenter <[email protected]>---
Compile tested only. Please review carefully.drivers/target/iscsi/iscsi_target_parameters.c +0
-0
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1046
Quoted 10 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-7@@ -1037,13 +1037,6 @@ static char *iscsi_check_valuelist_for_support( tmp2 =strchr (acceptor_values,',' );if (tmp2) *tmp2 ='\0' ; -if (!acceptor_values || !proposer_values) { -if (tmp1) - *tmp1 =',' ; -if (tmp2) - *tmp2 =',' ; -return NULL ; - }
Mmmmm, I seem to remember this code being some manner of bugfix when these two NULL checks for IS_TYPE_VALUE_LIST() type login parameters where originally added into iscsi-target code (circa 2004)..
Looking at iscsi_check_valuelist_for_support() now in modern usage I think it's fine to go ahead and drop these checks..
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1051
Quoted 12 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-2if (!strcmp (acceptor_values, proposer_values)) {if (tmp2) *tmp2 =',' ;@@ -1053,8 +1046,6 @@ static char *iscsi_check_valuelist_for_support( *tmp2++ =',' ; acceptor_values = tmp2; -if (!acceptor_values) -break ; }while (acceptor_values);if (tmp1) *tmp1++ =',' ;
<nod>, looks harmless to drop as well.
Applied to lio-core, and queuing into for-next.
Thanks Dan!
--nab
Am 17.05.2012 09:08, schrieb Dan Carpenter:
Quoted 16 lines
Neither "
acceptor_values" nor "proposer_values" can be NULL here. Smatch complains because we are not allowed to pass NULL pointers tostrchr().Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition.
Signed-off-by Dan Carpenter <[email protected]>---
Compile tested only. Please review carefully.drivers/target/iscsi/iscsi_target_parameters.c +0
-0
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1039
Quoted 3 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-0@@ -1037,13 +1037,6 @@ static char *iscsi_check_valuelist_for_support( tmp2 =strchr (acceptor_values,',' );if (tmp2) *tmp2 ='\0' ;
this looks like strchrnul(). I realy do not know is this supported inside the kernel ?
Quoted 11 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-7-if (!acceptor_values || !proposer_values) { -if (tmp1) - *tmp1 =',' ; -if (tmp2) - *tmp2 =',' ; -return NULL ; - }if (!strcmp (acceptor_values, proposer_values)) {if (tmp2) *tmp2 =',' ;
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1051
Quoted 8 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-2@@ -1053,8 +1046,6 @@ static char *iscsi_check_valuelist_for_support( *tmp2++ =',' ; acceptor_values = tmp2; -if (!acceptor_values) -break ; }while (acceptor_values);if (tmp1) *tmp1++ =',' ;
the changes look reasonable but to be fair the code should have an explanation what it is supposed to do. I do not have the feeling that i did understand the purpose completely.
just my 2 cents,
wh
Quoted 14 lines · walter harms
Am 17.05.2012 09:08, schrieb Dan Carpenter:
Quoted 11 lines
Neither "
acceptor_values" nor "proposer_values" can be NULL here. Smatch complains because we are not allowed to pass NULL pointers tostrchr().Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition.
Signed-off-by Dan Carpenter <[email protected]>---
Compile tested only. Please review carefully.
Quoted 10 lines
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1039
Quoted 8 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-0@@ -1037,13 +1037,6 @@ static char *iscsi_check_valuelist_for_support( tmp2 =strchr (acceptor_values,',' );if (tmp2) *tmp2 ='\0' ;this looks like
strchrnul(). I realy do not know is this supported inside the kernel ?
It can't be NULL here. Adding bogus checks is the wrong idea and static checkers are right to ask about needless checks.
regards,
dan carpenter
Quoted 4 lines · walter harms
the changes look reasonable but to be fair the code should have an explanation what it is supposed to do. I do not have the feeling that i did understand the purpose completely.
I suppose that is a decent summary for much of the target code. Patches are clearly welcome.
Jörn
--
Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures. -- Rob Pike
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Am 17.05.2012 12:26, schrieb Dan Carpenter:
Quoted 26 lines · walter harms
Quoted 14 lines
Am 17.05.2012 09:08, schrieb Dan Carpenter:
Quoted 11 lines
Neither "
acceptor_values" nor "proposer_values" can be NULL here. Smatch complains because we are not allowed to pass NULL pointers tostrchr().Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition.
Signed-off-by Dan Carpenter <[email protected]>---
Compile tested only. Please review carefully.Quoted 10 lines
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1039
Quoted 8 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-0@@ -1037,13 +1037,6 @@ static char *iscsi_check_valuelist_for_support( tmp2 =strchr (acceptor_values,',' );if (tmp2) *tmp2 ='\0' ;this looks like
strchrnul(). I realy do not know is this supported inside the kernel ?
Quoted 3 lines
It can't be NULL here. Adding bogus checks is the wrong idea and static checkers are right to ask about needless checks.
sorry i was writing (talking) about something different.
the construction:
....
v=strchr()
if (v=NULL)
return '\0'
...
is like strchrnul() in glibc. Maybe this pattern is used more than once inside the kernel code.
re,
wh
Quoted 32 lines · walter harms
Am 17.05.2012 12:26, schrieb Dan Carpenter:
Quoted 26 lines · walter harms
Quoted 14 lines
Am 17.05.2012 09:08, schrieb Dan Carpenter:
Quoted 11 lines
Neither "
acceptor_values" nor "proposer_values" can be NULL here. Smatch complains because we are not allowed to pass NULL pointers tostrchr().Also I removed a second later check for "!acceptor_values" because it gets checked on the next line in the do while condition.
Signed-off-by Dan Carpenter <[email protected]>---
Compile tested only. Please review carefully.Quoted 10 lines
drivers/target/iscsi/iscsi_target_parameters.c static char *iscsi_check_valuelist_for_support( · line 1039
Quoted 8 lines
drivers/target/iscsi/iscsi_target_parameters.c +0
-0@@ -1037,13 +1037,6 @@ static char *iscsi_check_valuelist_for_support( tmp2 =strchr (acceptor_values,',' );if (tmp2) *tmp2 ='\0' ;this looks like
strchrnul(). I realy do not know is this supported inside the kernel ?Quoted 3 lines
It can't be NULL here. Adding bogus checks is the wrong idea and static checkers are right to ask about needless checks.
Quoted 8 lines
sorry i was writing (talking) about something different.
the construction:
....
v=strchr()
if (v=NULL)
return '\0'
...
is likestrchrnul()in glibc. Maybe this pattern is used more than once inside the kernel code.
No no. My mistake I didn't know what strchrnul() did. But there isn't a kernel version of that function.
regards,
dan carpenter