public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: comedi: ni_tiocmd: remove unused code
@ 2015-09-28 20:54 Luis de Bethencourt
  2015-09-28 21:10 ` [PATCH] staging: comedi: cb_pcidas64: " Luis de Bethencourt
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Luis de Bethencourt @ 2015-09-28 20:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: abbotti, hsweeten, gregkh, surya.seetharaman9, devel,
	Luis de Bethencourt

Remove the unused code, which isn't implemented yet, using #if 0.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---

Hi,

The code after the return is dead code. My understanding is that it is
there for when the output commands are implemented in the future.
Meanwhile it would be clearer if the code is removed with #if 0.

Thanks,
Luis

 drivers/staging/comedi/drivers/ni_tiocmd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c
index 9b124b0..728c7f4 100644
--- a/drivers/staging/comedi/drivers/ni_tiocmd.c
+++ b/drivers/staging/comedi/drivers/ni_tiocmd.c
@@ -158,11 +158,13 @@ static int ni_tio_output_cmd(struct comedi_subdevice *s)
 		"output commands not yet implemented.\n");
 	return -ENOTSUPP;
 
+#if 0 /* unused */
 	counter->mite_chan->dir = COMEDI_OUTPUT;
 	mite_prep_dma(counter->mite_chan, 32, 32);
 	ni_tio_configure_dma(counter, true, false);
 	mite_dma_arm(counter->mite_chan);
 	return ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE);
+#endif
 }
 
 static int ni_tio_cmd_setup(struct comedi_subdevice *s)
-- 
2.5.1


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

* [PATCH] staging: comedi: cb_pcidas64: remove unused code
  2015-09-28 20:54 [PATCH] staging: comedi: ni_tiocmd: remove unused code Luis de Bethencourt
@ 2015-09-28 21:10 ` Luis de Bethencourt
  2015-09-29  1:23   ` Greg KH
  2015-09-28 21:52 ` [PATCH] staging: rtl8712: remove dead code Luis de Bethencourt
  2015-09-29  1:22 ` [PATCH] staging: comedi: ni_tiocmd: remove unused code Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Luis de Bethencourt @ 2015-09-28 21:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: abbotti, hsweeten, gregkh, amaury.denoyelle, devel,
	Luis de Bethencourt

Remove the disabled code, for now, with #if 0.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---

Hi,

The code after the return is dead code. There is a comment saying it is
disabled for now, it would be good if the code is removed with #if 0 as
well.

Thanks,
Luis

 drivers/staging/comedi/drivers/cb_pcidas64.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index d33b8fe..f86ea9f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -2233,10 +2233,12 @@ static int use_hw_sample_counter(struct comedi_cmd *cmd)
 /* disable for now until I work out a race */
 	return 0;
 
+#if 0
 	if (cmd->stop_src == TRIG_COUNT && cmd->stop_arg <= max_counter_value)
 		return 1;
 
 	return 0;
+#endif
 }
 
 static void setup_sample_counters(struct comedi_device *dev,
-- 
2.5.1


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

* [PATCH] staging: rtl8712: remove dead code
  2015-09-28 20:54 [PATCH] staging: comedi: ni_tiocmd: remove unused code Luis de Bethencourt
  2015-09-28 21:10 ` [PATCH] staging: comedi: cb_pcidas64: " Luis de Bethencourt
@ 2015-09-28 21:52 ` Luis de Bethencourt
  2015-09-30  5:32   ` Joshua Clayton
  2015-09-29  1:22 ` [PATCH] staging: comedi: ni_tiocmd: remove unused code Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Luis de Bethencourt @ 2015-09-28 21:52 UTC (permalink / raw)
  To: linux-kernel
  Cc: Larry.Finger, florian.c.schilhabel, gregkh, vthakkar1994,
	sudipm.mukherjee, stillcompiling, mperepelitsyn, tapaswenipathak,
	hamohammed.sa, devel, Luis de Bethencourt

The while() loop will only exit in a return or a goto ask_for_joinbss,
which means it will never break and execute the return after it.
Removing return _FAIL since it is dead code.

Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
---
 drivers/staging/rtl8712/rtl871x_mlme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
index fc5dbea..fbcb248 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -1190,7 +1190,7 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv)
 			}
 		}
 	}
-	return _FAIL;
+
 ask_for_joinbss:
 	return r8712_joinbss_cmd(adapter, pnetwork);
 }
-- 
2.5.1


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

* Re: [PATCH] staging: comedi: ni_tiocmd: remove unused code
  2015-09-28 20:54 [PATCH] staging: comedi: ni_tiocmd: remove unused code Luis de Bethencourt
  2015-09-28 21:10 ` [PATCH] staging: comedi: cb_pcidas64: " Luis de Bethencourt
  2015-09-28 21:52 ` [PATCH] staging: rtl8712: remove dead code Luis de Bethencourt
@ 2015-09-29  1:22 ` Greg KH
  2 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2015-09-29  1:22 UTC (permalink / raw)
  To: Luis de Bethencourt; +Cc: linux-kernel, devel, abbotti, surya.seetharaman9

On Mon, Sep 28, 2015 at 09:54:45PM +0100, Luis de Bethencourt wrote:
> Remove the unused code, which isn't implemented yet, using #if 0.
> 
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
> 
> Hi,
> 
> The code after the return is dead code. My understanding is that it is
> there for when the output commands are implemented in the future.
> Meanwhile it would be clearer if the code is removed with #if 0.
> 
> Thanks,
> Luis
> 
>  drivers/staging/comedi/drivers/ni_tiocmd.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c
> index 9b124b0..728c7f4 100644
> --- a/drivers/staging/comedi/drivers/ni_tiocmd.c
> +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c
> @@ -158,11 +158,13 @@ static int ni_tio_output_cmd(struct comedi_subdevice *s)
>  		"output commands not yet implemented.\n");
>  	return -ENOTSUPP;
>  
> +#if 0 /* unused */
>  	counter->mite_chan->dir = COMEDI_OUTPUT;
>  	mite_prep_dma(counter->mite_chan, 32, 32);
>  	ni_tio_configure_dma(counter, true, false);
>  	mite_dma_arm(counter->mite_chan);
>  	return ni_tio_arm(counter, 1, NI_GPCT_ARM_IMMEDIATE);
> +#endif

That's not clear at all, if the code isn't needed, let's just delete it,
why is it here at all?

thanks,

greg k-h

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

* Re: [PATCH] staging: comedi: cb_pcidas64: remove unused code
  2015-09-28 21:10 ` [PATCH] staging: comedi: cb_pcidas64: " Luis de Bethencourt
@ 2015-09-29  1:23   ` Greg KH
  2015-09-29  9:55     ` Luis de Bethencourt
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2015-09-29  1:23 UTC (permalink / raw)
  To: Luis de Bethencourt; +Cc: linux-kernel, devel, amaury.denoyelle, abbotti

On Mon, Sep 28, 2015 at 10:10:42PM +0100, Luis de Bethencourt wrote:
> Remove the disabled code, for now, with #if 0.
> 
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
> 
> Hi,
> 
> The code after the return is dead code. There is a comment saying it is
> disabled for now, it would be good if the code is removed with #if 0 as
> well.

The compiler doesn't add it anyway, so this is the same as what you just
did, so I don't think it's needed.

thanks,

greg k-h

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

* Re: [PATCH] staging: comedi: cb_pcidas64: remove unused code
  2015-09-29  1:23   ` Greg KH
@ 2015-09-29  9:55     ` Luis de Bethencourt
  0 siblings, 0 replies; 7+ messages in thread
From: Luis de Bethencourt @ 2015-09-29  9:55 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, devel, amaury.denoyelle, abbotti

On 29/09/15 02:23, Greg KH wrote:
> On Mon, Sep 28, 2015 at 10:10:42PM +0100, Luis de Bethencourt wrote:
>> Remove the disabled code, for now, with #if 0.
>>
>> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
>> ---
>>
>> Hi,
>>
>> The code after the return is dead code. There is a comment saying it is
>> disabled for now, it would be good if the code is removed with #if 0 as
>> well.
> 
> The compiler doesn't add it anyway, so this is the same as what you just
> did, so I don't think it's needed.
> 
> thanks,
> 
> greg k-h
> 

Hi Greg,

I thought it would be easier to read if the code was explicitly marked as
dead/uncompiled.
You are correct though, it is probably not worth it.

Thanks for the review,
Luis

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

* Re: [PATCH] staging: rtl8712: remove dead code
  2015-09-28 21:52 ` [PATCH] staging: rtl8712: remove dead code Luis de Bethencourt
@ 2015-09-30  5:32   ` Joshua Clayton
  0 siblings, 0 replies; 7+ messages in thread
From: Joshua Clayton @ 2015-09-30  5:32 UTC (permalink / raw)
  To: Luis de Bethencourt
  Cc: linux-kernel, Larry.Finger, florian.c.schilhabel, gregkh,
	vthakkar1994, sudipm.mukherjee, mperepelitsyn, tapaswenipathak,
	hamohammed.sa, devel

On Monday, September 28, 2015 10:52:33 PM Luis de Bethencourt wrote:
> The while() loop will only exit in a return or a goto ask_for_joinbss,
> which means it will never break and execute the return after it.
> Removing return _FAIL since it is dead code.
> 
> Signed-off-by: Luis de Bethencourt <luisbg@osg.samsung.com>
> ---
>  drivers/staging/rtl8712/rtl871x_mlme.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c
> index fc5dbea..fbcb248 100644
> --- a/drivers/staging/rtl8712/rtl871x_mlme.c
> +++ b/drivers/staging/rtl8712/rtl871x_mlme.c
> @@ -1190,7 +1190,7 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv)
>  			}
>  		}
>  	}
> -	return _FAIL;
> +
>  ask_for_joinbss:
>  	return r8712_joinbss_cmd(adapter, pnetwork);
>  }
> 

Yes, that line is unreachable, (no breaks, only returns and gotos to get out of the loop).

but ugh, that function is an abomination.
removing the return _FAIL does little to improve the code flow or
readability. 

perhaps a nicer fix would be to change it to follow the convention
of gotos for the failure path, so instead of 5 levels of nesting, 
it would flow naturally toward r8712_joinbss_cmd();

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

end of thread, other threads:[~2015-09-30  5:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-28 20:54 [PATCH] staging: comedi: ni_tiocmd: remove unused code Luis de Bethencourt
2015-09-28 21:10 ` [PATCH] staging: comedi: cb_pcidas64: " Luis de Bethencourt
2015-09-29  1:23   ` Greg KH
2015-09-29  9:55     ` Luis de Bethencourt
2015-09-28 21:52 ` [PATCH] staging: rtl8712: remove dead code Luis de Bethencourt
2015-09-30  5:32   ` Joshua Clayton
2015-09-29  1:22 ` [PATCH] staging: comedi: ni_tiocmd: remove unused code Greg KH

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