Skip to contentSkip to conversation

staging: comedi: ni_atmio16d: remove commented code blocks

PATCH Superseded Deepak R Varma 2 participants 6 messages Mar 14, 2020 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: comedi: ni_atmio16d: remove commented code blocks

Remove two if# 0 directive code blocks. The first commented code block is redundant too; whereas the other code block is never used. Problem detected by checkpatch script.

---
 drivers/staging/comedi/drivers/ni_atmio16d.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/staging/comedi/drivers/ni_atmio16d.c +0 -10
index 68ad9676f962..0bca7d752015 100644
@@ -266,19 +266,9 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev,
 	if (cmd->scan_begin_src == TRIG_FOLLOW) {
 		/* internal trigger */
 		err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-	} else {
-#if 0
-		/* external trigger */
-		/* should be level/edge, hi/lo specification here */
-		err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-#endif
 	}
 
 	err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
-#if 0
-	err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
-#endif
-
 	err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
 					   cmd->chanlist_len);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 1 line · Deepak R Varma

Remove two if# 0 directive code blocks. The first commented code block

#if

Quoted 1 line

is redundant too; whereas the other code block is never used. Problem

Why do you say that the first one is redundant?

julia

Quoted 39 lines

detected by checkpatch script.

---
 drivers/staging/comedi/drivers/ni_atmio16d.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/staging/comedi/drivers/ni_atmio16d.c +0 -11
index 68ad9676f962..0bca7d752015 100644
@@ -266,19 +266,9 @@ static int atmio16d_ai_cmdtest(struct comedi_device *dev,
 	if (cmd->scan_begin_src == TRIG_FOLLOW) {
 		/* internal trigger */
 		err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-	} else {
-#if 0
-		/* external trigger */
-		/* should be level/edge, hi/lo specification here */
-		err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
-#endif
 	}
 
 	err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
-#if 0
-	err |= comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
-#endif
-
 	err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
 					   cmd->chanlist_len);
 
--

2.17.1

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20200314165130.GA18939%40deeUbuntu.

#2 lore raw
Quoted 7 lines · Julia Lawall
Quoted 1 line · Deepak R Varma

Remove two if# 0 directive code blocks. The first commented code block

Quoted 8 lines

#if

Quoted 1 line

is redundant too; whereas the other code block is never used. Problem

Why do you say that the first one is redundant?

julia

The instructions in if and else block are exactly the same. so, if or else, you are going to run the same instruction. Let me know if I misunderstood or misquoted.

Thank you.

Quoted 49 lines

Review

Quoted 8 lines

detected by checkpatch script.

Signed-off-by Deepak R Varma <[email protected] <javascript:>>

---

 drivers/staging/comedi/drivers/ni_atmio16d.c | 10 ---------- 
 1 file changed, 10 deletions(-) 
(quoted diff) +0 -0

b/drivers/staging/comedi/drivers/ni_atmio16d.c

drivers/staging/comedi/drivers/ni_atmio16d.c static int atmio16d_ai_cmdtest(struct comedi_device

Quoted 4 lines

index 68ad9676f962..0bca7d752015 100644

drivers/staging/comedi/drivers/ni_atmio16d.c +0 -0
@@ -266,19 +266,9 @@ static int atmio16d_ai_cmdtest(struct comedi_device 

*dev,

drivers/staging/comedi/drivers/ni_atmio16d.c static int atmio16d_ai_cmdtest(struct comedi_device *dev,

Quoted 3 lines
drivers/staging/comedi/drivers/ni_atmio16d.c +0 -0
         if (cmd->scan_begin_src == TRIG_FOLLOW) { 
                 /* internal trigger */ 
                 err |= 

comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);

drivers/staging/comedi/drivers/ni_atmio16d.c static int atmio16d_ai_cmdtest(struct comedi_device *dev,

Quoted 5 lines
drivers/staging/comedi/drivers/ni_atmio16d.c +0 -5
-        } else { 
-#if 0 
-                /* external trigger */ 
-                /* should be level/edge, hi/lo specification here */ 
-                err |= 

comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);

drivers/staging/comedi/drivers/ni_atmio16d.c static int atmio16d_ai_cmdtest(struct comedi_device *dev,

Quoted 6 lines
drivers/staging/comedi/drivers/ni_atmio16d.c +0 -3
-#endif 
         } 
 
         err |= comedi_check_trigger_arg_min(&cmd->convert_arg, 10000); 
-#if 0 
-        err |= comedi_check_trigger_arg_max(&cmd->convert_arg, 

SLOWEST_TIMER);

Quoted 10 lines
drivers/staging/comedi/drivers/ni_atmio16d.c +0 -2
-#endif 
- 
         err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg, 
                                            cmd->chanlist_len); 
 
Signature · 4 lines
2.17.1 

-- 
You received this message because you are subscribed to the Google 

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected] <javascript:>.

Quoted 1 line

To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20200314165130.GA18939%40deeUbuntu.

Quoted 1 line
#3 lore raw
Quoted 15 lines · Deepak Varma

On Saturday, 14 March 2020 22:27:15 UTC+5:30, Julia Lawall wrote:

On Sat, 14 Mar 2020, Deepak R Varma wrote:

> Remove two if# 0 directive code blocks. The first commented code block

#if

> is redundant too; whereas the other code block is never used. Problem

Quoted 8 lines

Why do you say that the first one is redundant?

julia

The instructions in if and else block are exactly the same. so, if or else, you are going to run the same instruction. Let me know if I misunderstood or misquoted.

Since one of them is under an #if 0, the current effect is quite different. Only the statement in the then branch will be executed.

Redundant would be eg:

x = 0;
x = 0;

There is no point in having the second line, because x is already 0.

Even without the #if 0, if you have:

if (x)
y = 0;
else y = 0;

It doesn't seem reasonable to say that the second y = 0 is redundant. It is the if that is is not necessary. But once you have the if, you need both the then and else branches.

julia

Quoted 65 lines

Thank you.

      > detected by checkpatch script.
      >
      > Signed-off-by: Deepak R Varma <[email protected]>
      > ---
      >  drivers/staging/comedi/drivers/ni_atmio16d.c | 10 ----------
      >  1 file changed, 10 deletions(-)
      >
      > diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c
      b/drivers/staging/comedi/drivers/ni_atmio16d.c
      > index 68ad9676f962..0bca7d752015 100644
      > --- a/drivers/staging/comedi/drivers/ni_atmio16d.c
      > +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
      > @@ -266,19 +266,9 @@ static int atmio16d_ai_cmdtest(struct
      comedi_device *dev,
      >          if (cmd->scan_begin_src == TRIG_FOLLOW) {
      >                  /* internal trigger */
      >                  err |=
      comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
      > -        } else {
      > -#if 0
      > -                /* external trigger */
      > -                /* should be level/edge, hi/lo specification
      here */
      > -                err |=
      comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
      > -#endif
      >          }
      >
      >          err |=
      comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
      > -#if 0
      > -        err |=
      comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER);
      > -#endif
      > -
      >          err |=
      comedi_check_trigger_arg_is(&cmd->scan_end_arg,
      >                                            
      cmd->chanlist_len);
      >
      > --
      > 2.17.1
      >
      > --
      > You received this message because you are subscribed to the
      Google Groups "outreachy-kernel" group.
      > To unsubscribe from this group and stop receiving emails from
      it, send an email to [email protected].
      > To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/20200314165130.GA18939%4
      0deeUbuntu.
      >

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/7842c46c-710b-4a2a-bf46- 396ed319e2a6%40googlegroups.com.

#4 lore raw
Quoted 47 lines · Julia Lawall
Quoted 15 lines · Deepak Varma

On Saturday, 14 March 2020 22:27:15 UTC+5:30, Julia Lawall wrote:

On Sat, 14 Mar 2020, Deepak R Varma wrote:

> Remove two if# 0 directive code blocks. The first commented code block

#if

> is redundant too; whereas the other code block is never used. Problem

Quoted 6 lines

Why do you say that the first one is redundant?

julia

The instructions in if and else block are exactly the same. so, if or

else,

Quoted 1 line

you are going to run the same instruction. Let me know if I

misunderstood or

Quoted 1 line

misquoted.

Since one of them is under an #if 0, the current effect is quite different. Only the statement in the then branch will be executed.

Redundant would be eg:

x = 0;
x = 0;

There is no point in having the second line, because x is already 0.

Even without the #if 0, if you have:

if (x)
y = 0;
else y = 0;

Quoted 6 lines

It doesn't seem reasonable to say that the second y = 0 is redundant. It is the if that is is not necessary. But once you have the if, you need both the then and else branches.

julia

Agreed. if(x) becomes redundant when #if 0 becomes #if 1. I was trying to make the same point that even if the #if 0 block is turned on, it will still have the same behavior with the if(x) .. else in place. But, I though the else part will be redundant, but it was wrong. The if part would be redundant. I got your point. Well explained. Thank you!

Would you suggest I reword the patch description and send in v2? Is the rest looking good to you?

Deepak.

Quoted 69 lines
Quoted 45 lines

Thank you.

      > detected by checkpatch script. 
      > 
      > Signed-off-by: Deepak R Varma <[email protected]> 
      > --- 
      >  drivers/staging/comedi/drivers/ni_atmio16d.c | 10 ---------- 
      >  1 file changed, 10 deletions(-) 
      > 
      > diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c 
      b/drivers/staging/comedi/drivers/ni_atmio16d.c 
      > index 68ad9676f962..0bca7d752015 100644 
      > --- a/drivers/staging/comedi/drivers/ni_atmio16d.c 
      > +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c 
      > @@ -266,19 +266,9 @@ static int atmio16d_ai_cmdtest(struct 
      comedi_device *dev, 
      >          if (cmd->scan_begin_src == TRIG_FOLLOW) { 
      >                  /* internal trigger */ 
      >                  err |= 
      comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0); 
      > -        } else { 
      > -#if 0 
      > -                /* external trigger */ 
      > -                /* should be level/edge, hi/lo specification 
      here */ 
      > -                err |= 
      comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0); 
      > -#endif 
      >          } 
      > 
      >          err |= 
      comedi_check_trigger_arg_min(&cmd->convert_arg, 10000); 
      > -#if 0 
      > -        err |= 
      comedi_check_trigger_arg_max(&cmd->convert_arg, SLOWEST_TIMER); 
      > -#endif 
      > - 
      >          err |= 
      comedi_check_trigger_arg_is(&cmd->scan_end_arg, 
      >                                             
      cmd->chanlist_len); 
      > 
      > -- 
Quoted 8 lines
      > 2.17.1 
      > 
      > -- 
      > You received this message because you are subscribed to the 
      Google Groups "outreachy-kernel" group. 
      > To unsubscribe from this group and stop receiving emails from 
      it, send an email to [email protected]. 
      > To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/20200314165130.GA18939%4

Quoted 5 lines
      0deeUbuntu. 
      > 
Signature · 1 line
You received this message because you are subscribed to the Google 

Groups

Quoted 2 lines

"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send

an

Quoted 2 lines

email to [email protected] <javascript:>. To view this discussion on the web visithttps://

groups.google.com/d/msgid/outreachy-kernel/7842c46c-710b-4a2a-bf46-

Quoted 3 lines

396ed319e2a6%40googlegroups.com.

#5 lore raw
Quoted 63 lines · Deepak Varma

On Saturday, 14 March 2020 22:41:02 UTC+5:30, Julia Lawall wrote:

On Sat, 14 Mar 2020, Deepak Varma wrote:

>
>
> On Saturday, 14 March 2020 22:27:15 UTC+5:30, Julia Lawall wrote:
>
>
>       On Sat, 14 Mar 2020, Deepak R Varma wrote:
>
>       > Remove two if# 0 directive code blocks. The first commented
>       code block
>
>       #if
>
>       > is redundant too; whereas the other code block is never used.
>       Problem
>
>       Why do you say that the first one is redundant? >
>       julia
>
>
> The instructions in if and else block are exactly the same. so, if or else,
> you are going to run the same instruction. Let me know if I misunderstood or
> misquoted.

Since one of them is under an #if 0, the current effect is quite different.  Only the statement in the then branch will be executed.

Redundant would be eg:

x = 0;
x = 0;

There is no point in having the second line, because x is already 0.

Even without the #if 0, if you have:

if (x)
  y = 0;
else y = 0;

It doesn't seem reasonable to say that the second y = 0 is redundant. It
is the if that is is not necessary.  But once you have the if, you need
both the then and else branches.

julia

Quoted 8 lines

Agreed. if(x) becomes redundant when #if 0 becomes #if 1. I was trying to make the same point that even if the #if 0 block is turned on, it will still have the same behavior with the if(x) .. else in place. But, I though the else part will be redundant, but it was wrong. The if part would be redundant. I got your point. Well explained. Thank you!

Would you suggest I reword the patch description and send in v2? Is the rest looking good to you?

Yes for both.

julia

Quoted 89 lines

Deepak.

>
> Thank you.
>
>
>       > detected by checkpatch script.
>       >
>       > Signed-off-by: Deepak R Varma <[email protected]>
>       > ---
>       >  drivers/staging/comedi/drivers/ni_atmio16d.c | 10
----------
>       >  1 file changed, 10 deletions(-)
>       >
>       > diff --git
a/drivers/staging/comedi/drivers/ni_atmio16d.c
>       b/drivers/staging/comedi/drivers/ni_atmio16d.c
>       > index 68ad9676f962..0bca7d752015 100644
>       > --- a/drivers/staging/comedi/drivers/ni_atmio16d.c
>       > +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c
>       > @@ -266,19 +266,9 @@ static int
atmio16d_ai_cmdtest(struct
>       comedi_device *dev,
>       >          if (cmd->scan_begin_src == TRIG_FOLLOW) {
>       >                  /* internal trigger */
>       >                  err |=
>       comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
>       > -        } else {
>       > -#if 0
>       > -                /* external trigger */
>       > -                /* should be level/edge, hi/lo
specification
>       here */
>       > -                err |=
>       comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
>       > -#endif
>       >          }
>       >
>       >          err |=
>       comedi_check_trigger_arg_min(&cmd->convert_arg, 10000);
>       > -#if 0
>       > -        err |=
>       comedi_check_trigger_arg_max(&cmd->convert_arg,
SLOWEST_TIMER);
>       > -#endif
>       > -
>       >          err |=
>       comedi_check_trigger_arg_is(&cmd->scan_end_arg,
>       >
>       cmd->chanlist_len);
>       >
>       > --
>       > 2.17.1
>       >
>       > --
>       > You received this message because you are subscribed
to the
>       Google Groups "outreachy-kernel" group.
>       > To unsubscribe from this group and stop receiving
emails from
>       it, send an email to [email protected].
>       > To view this discussion on the webvisithttps://groups.google.com/d/msgid/outreachy-kernel/20200314165130.GA18 939%4
>       0deeUbuntu.
>       >
>
> --
> You received this message because you are subscribed to the
Google Groups
> "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from
it, send an
> email to [email protected].
> To view this discussion on the webvisithttps://groups.google.com/d/msgid/outreachy-kernel/7842c46c-710b-4a2a- bf46-
> 396ed319e2a6%40googlegroups.com.
>
>

--
You received this message because you are subscribed to the Google Groups
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/7731265e-42a7-4c67-a0f5- 245cecbecc0b%40googlegroups.com.