[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20130924.101231.1193830264265403478.davem@davemloft.net>
Date: Tue, 24 Sep 2013 10:12:31 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: joe@...ches.com
Cc: jeffrey.t.kirsher@...el.com, jesse.brandeburg@...el.com,
netdev@...r.kernel.org, gospo@...hat.com, sassmann@...hat.com
Subject: Re: [net 5/6] i40e: better return values
From: Joe Perches <joe@...ches.com>
Date: Tue, 24 Sep 2013 04:34:46 -0700
> On Tue, 2013-09-24 at 02:45 -0700, Jeff Kirsher wrote:
>
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> []
>> @@ -3339,9 +3345,7 @@ static u8 i40e_dcb_get_num_tc(struct i40e_dcbx_config *dcbcfg)
>> /* Traffic class index starts from zero so
>> * increment to return the actual count
>> */
>> - num_tc++;
>> -
>> - return num_tc;
>> + return num_tc++;
>
> Ick. post_increment problem.
>
> return ++num_tc;
>
> There's nothing wrong with the original code
> unless this is a bugfix which should be documented
> better than "better return values".
Agreed, this style of coding is asking for a bug.
If you want to return "num_tc PLUS ONE" just say that:
return num_tc + 1;
Why even use pre/post increment when the variable has no other
use than as a return value?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists