public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] iscsi-target: remove some dead code
@ 2012-05-17  7:08 Dan Carpenter
  2012-05-17  7:39 ` Nicholas A. Bellinger
  2012-05-17  9:58 ` walter harms
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-05-17  7:08 UTC (permalink / raw)
  To: Nicholas A. Bellinger
  Cc: Andy Grover, Jesper Juhl, Joern Engel, Roland Dreier, linux-scsi,
	target-devel, kernel-janitors

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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Compile tested only.  Please review carefully.

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index ad3b3c1..ed5241e 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -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++ = ',';

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [patch] iscsi-target: remove some dead code
  2012-05-17  7:08 [patch] iscsi-target: remove some dead code Dan Carpenter
@ 2012-05-17  7:39 ` Nicholas A. Bellinger
  2012-05-17  9:58 ` walter harms
  1 sibling, 0 replies; 5+ messages in thread
From: Nicholas A. Bellinger @ 2012-05-17  7:39 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andy Grover, Jesper Juhl, Joern Engel, Roland Dreier, linux-scsi,
	target-devel, kernel-janitors

Hello DanC,

On Thu, 2012-05-17 at 10:08 +0300, Dan Carpenter wrote:
> 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.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Compile tested only.  Please review carefully.
> 
> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> index ad3b3c1..ed5241e 100644
> --- a/drivers/target/iscsi/iscsi_target_parameters.c
> +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> @@ -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..  

>  			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++ = ',';

<nod>, looks harmless to drop as well.

Applied to lio-core, and queuing into for-next.

Thanks Dan!

--nab


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] iscsi-target: remove some dead code
  2012-05-17  7:08 [patch] iscsi-target: remove some dead code Dan Carpenter
  2012-05-17  7:39 ` Nicholas A. Bellinger
@ 2012-05-17  9:58 ` walter harms
  2012-05-17 10:26   ` Dan Carpenter
  2012-05-17 15:15   ` Jörn Engel
  1 sibling, 2 replies; 5+ messages in thread
From: walter harms @ 2012-05-17  9:58 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Nicholas A. Bellinger, Andy Grover, Jesper Juhl, Joern Engel,
	Roland Dreier, linux-scsi, kernel-janitors



Am 17.05.2012 09:08, schrieb Dan Carpenter:
> 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.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> Compile tested only.  Please review carefully.
> 
> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> index ad3b3c1..ed5241e 100644
> --- a/drivers/target/iscsi/iscsi_target_parameters.c
> +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> @@ -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 ?



> -			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++ = ',';


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] iscsi-target: remove some dead code
  2012-05-17  9:58 ` walter harms
@ 2012-05-17 10:26   ` Dan Carpenter
  2012-05-17 15:15   ` Jörn Engel
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-05-17 10:26 UTC (permalink / raw)
  To: walter harms
  Cc: Nicholas A. Bellinger, Andy Grover, Jesper Juhl, Joern Engel,
	Roland Dreier, linux-scsi, kernel-janitors

On Thu, May 17, 2012 at 11:58:40AM +0200, walter harms wrote:
> 
> 
> Am 17.05.2012 09:08, schrieb Dan Carpenter:
> > 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.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > Compile tested only.  Please review carefully.
> > 
> > diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> > index ad3b3c1..ed5241e 100644
> > --- a/drivers/target/iscsi/iscsi_target_parameters.c
> > +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> > @@ -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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] iscsi-target: remove some dead code
  2012-05-17  9:58 ` walter harms
  2012-05-17 10:26   ` Dan Carpenter
@ 2012-05-17 15:15   ` Jörn Engel
  1 sibling, 0 replies; 5+ messages in thread
From: Jörn Engel @ 2012-05-17 15:15 UTC (permalink / raw)
  To: walter harms
  Cc: Dan Carpenter, Nicholas A. Bellinger, Andy Grover, Jesper Juhl,
	Roland Dreier, linux-scsi, kernel-janitors

On Thu, 17 May 2012 11:58:40 +0200, walter harms wrote:
> 
> 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 linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-17 17:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-17  7:08 [patch] iscsi-target: remove some dead code Dan Carpenter
2012-05-17  7:39 ` Nicholas A. Bellinger
2012-05-17  9:58 ` walter harms
2012-05-17 10:26   ` Dan Carpenter
2012-05-17 15:15   ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox