staging: comedi: ni_tiocmd: remove unused code
PATCH 1/1 staging: comedi: ni_tiocmd: remove unused code
Remove the unused code, which isn't implemented yet, using #if 0.
---
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(+)
drivers/staging/comedi/drivers/ni_tiocmd.c +2 -0
@@ -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)
Signature · 1 line
2.5.1
PATCH 1/1 staging: comedi: cb_pcidas64: remove unused code
Remove the disabled code, for now, with #if 0.
---
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(+)
drivers/staging/comedi/drivers/cb_pcidas64.c +2 -0
@@ -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,
Signature · 1 line
2.5.1
Greg KH
maintainerRe: [PATCH] staging: comedi: cb_pcidas64: remove unused code
Quoted 10 lines · Luis de Bethencourt
Remove the disabled code, for now, with #if 0.
Signed-off-by Luis de Bethencourt <[email protected]>---
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
Re: [PATCH] staging: comedi: cb_pcidas64: remove unused code
Quoted 12 lines · Greg KH
Quoted 10 lines · Luis de Bethencourt
Remove the disabled code, for now, with #if 0.
Signed-off-by Luis de Bethencourt <[email protected]>---
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.
Quoted 7 lines
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
PATCH 1/1 staging: rtl8712: remove dead code
In reply to Luis de BethencourtThe 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.
--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/rtl871x_mlme.c +1 -1
@@ -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); }
Signature · 1 line
2.5.1
Re: [PATCH] staging: rtl8712: remove dead code
Quoted 15 lines · Luis de Bethencourt
The
while()loop will only exit in a return or a gotoask_for_joinbss, which means it will never break and execute the return after it. Removing return_FAILsince it is dead code.Signed-off-by Luis de Bethencourt <[email protected]>--- drivers/staging/rtl8712/rtl871x_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/rtl8712/rtl871x_mlme.c +0
-0
drivers/staging/rtl8712/rtl871x_mlme.c int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) · line 1196
Quoted 8 lines
drivers/staging/rtl8712/rtl871x_mlme.c +1
-1@@ -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();
Greg KH
maintainerQuoted 22 lines · Luis de Bethencourt
Remove the unused code, which isn't implemented yet, using #if 0.
Signed-off-by Luis de Bethencourt <[email protected]>---
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,
Luisdrivers/staging/comedi/drivers/ni_tiocmd.c | 2 ++ 1 file changed, 2 insertions(+)drivers/staging/comedi/drivers/ni_tiocmd.c +0
-0
drivers/staging/comedi/drivers/ni_tiocmd.c static int ni_tio_output_cmd(struct comedi_subdevice *s) · line 167
Quoted 10 lines
drivers/staging/comedi/drivers/ni_tiocmd.c +2
-0@@ -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