diff mbox

[4/11] via-ircc: Remove useless return variables

Message ID 1401542051-3174-4-git-send-email-peter.senna@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Peter Senna Tschudin May 31, 2014, 1:14 p.m. UTC
This patch remove variables that are initialized with a constant,
are never updated, and are only used as parameter of return.
Return the constant instead of using a variable.

Verified by compilation only.

The coccinelle script that find and fixes this issue is:
// <smpl>
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
    when strict
return
- ret
+ C
;
// </smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>

---
 drivers/net/irda/via-ircc.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dan Carpenter May 31, 2014, 8:36 p.m. UTC | #1
On Sat, May 31, 2014 at 10:14:04AM -0300, Peter Senna Tschudin wrote:
> This patch remove variables that are initialized with a constant,
> are never updated, and are only used as parameter of return.
> Return the constant instead of using a variable.
> 
> Verified by compilation only.
> 
> The coccinelle script that find and fixes this issue is:
> // <smpl>
> @@
> type T;
> constant C;
> identifier ret;
> @@
> - T ret = C;
> ... when != ret
>     when strict
> return
> - ret
> + C
> ;
> // </smpl>
> 
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
> 
> ---
>  drivers/net/irda/via-ircc.c |    9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
> index 2900af0..3fde116 100644
> --- a/drivers/net/irda/via-ircc.c
> +++ b/drivers/net/irda/via-ircc.c
> @@ -509,11 +509,9 @@ static void via_hw_init(struct via_ircc_cb *self)
>   *
>   */
>  static int via_ircc_read_dongle_id(int iobase)
> -{
> -	int dongle_id = 9;	/* Default to IBM */
> -
> +{/* Default to IBM */

Yuck.  And anyway, the comment should be on return line.  (And of course
there should have been a #define IBM_DONGLE_ID 9, but that's probably
something for another patch.

>  	IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
> -	return dongle_id;
> +	return 9;

So put the comment here.

	return 9;  /* Everything is an IBM */
>  }
>  

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Walter Harms June 1, 2014, 11:42 a.m. UTC | #2
Am 31.05.2014 22:36, schrieb Dan Carpenter:
> On Sat, May 31, 2014 at 10:14:04AM -0300, Peter Senna Tschudin wrote:
>> This patch remove variables that are initialized with a constant,
>> are never updated, and are only used as parameter of return.
>> Return the constant instead of using a variable.
>>
>> Verified by compilation only.
>>
>> The coccinelle script that find and fixes this issue is:
>> // <smpl>
>> @@
>> type T;
>> constant C;
>> identifier ret;
>> @@
>> - T ret = C;
>> ... when != ret
>>     when strict
>> return
>> - ret
>> + C
>> ;
>> // </smpl>
>>
>> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
>>
>> ---
>>  drivers/net/irda/via-ircc.c |    9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
>> index 2900af0..3fde116 100644
>> --- a/drivers/net/irda/via-ircc.c
>> +++ b/drivers/net/irda/via-ircc.c
>> @@ -509,11 +509,9 @@ static void via_hw_init(struct via_ircc_cb *self)
>>   *
>>   */
>>  static int via_ircc_read_dongle_id(int iobase)
>> -{
>> -	int dongle_id = 9;	/* Default to IBM */
>> -
>> +{/* Default to IBM */
> 
> Yuck.  And anyway, the comment should be on return line.  (And of course
> there should have been a #define IBM_DONGLE_ID 9, but that's probably
> something for another patch.
> 
>>  	IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
>> -	return dongle_id;
>> +	return 9;


more over code and error msg do not fit,
it returns a default of 9 (what ever that means) it does not look like
an error. Sow the warning should be

via-ircc: dongle probing not supported, please specify dongle_id module parameter. settting dongle_id=9

re,
 wh


> So put the comment here.
> 
> 	return 9;  /* Everything is an IBM */
>>  }
>>  
> 
> regards,
> dan carpenter
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Carpenter June 1, 2014, 1:34 p.m. UTC | #3
On Sun, Jun 01, 2014 at 01:42:30PM +0200, walter harms wrote:
> >>  static int via_ircc_read_dongle_id(int iobase)
> >> -{
> >> -	int dongle_id = 9;	/* Default to IBM */
> >> -
> >> +{/* Default to IBM */
> > 
> > Yuck.  And anyway, the comment should be on return line.  (And of course
> > there should have been a #define IBM_DONGLE_ID 9, but that's probably
> > something for another patch.
> > 
> >>  	IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
> >> -	return dongle_id;
> >> +	return 9;
> 
> 
> more over code and error msg do not fit,
> it returns a default of 9 (what ever that means) it does not look like
> an error. Sow the warning should be
> 
> via-ircc: dongle probing not supported, please specify dongle_id module parameter. settting dongle_id=9
>

The print is ok.  It's called like this:

   328          /* Check if user has supplied the dongle id or not */
   329          if (!dongle_id)
   330                  dongle_id = via_ircc_read_dongle_id(self->io.fir_base);
   331          self->io.dongle_id = dongle_id;

If you don't use a module id then it acts like an IBM dongle by default.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 2900af0..3fde116 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -509,11 +509,9 @@  static void via_hw_init(struct via_ircc_cb *self)
  *
  */
 static int via_ircc_read_dongle_id(int iobase)
-{
-	int dongle_id = 9;	/* Default to IBM */
-
+{/* Default to IBM */
 	IRDA_ERROR("via-ircc: dongle probing not supported, please specify dongle_id module parameter.\n");
-	return dongle_id;
+	return 9;
 }
 
 /*
@@ -926,7 +924,6 @@  static int via_ircc_dma_xmit(struct via_ircc_cb *self, u16 iobase)
 static int via_ircc_dma_xmit_complete(struct via_ircc_cb *self)
 {
 	int iobase;
-	int ret = TRUE;
 	u8 Tx_status;
 
 	IRDA_DEBUG(3, "%s()\n", __func__);
@@ -983,7 +980,7 @@  F01_E*/
 	// Tell the network layer, that we can accept more frames 
 	netif_wake_queue(self->netdev);
 //F01   }
-	return ret;
+	return TRUE;
 }
 
 /*