Re: [PATCH RFC] Remove useless return variables
Peter Senna Tschudin <peter.senna@gmail.com> writes:
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.
This ret variable pattern is pretty standard in Linux, as it makes it easier to add new code that may trigger new errors (using the usual "goto forest" error handling pattern) I don't see any benefit in whole-sale removing it. The compiler doesn't care about it and will generate the same code in any case. -Andi -- ak@linux.intel.com -- Speaking for myself only
On Sat, May 17, 2014 at 10:04:35PM -0700, Andi Kleen wrote:
Peter Senna Tschudin <peter.senna@gmail.com> writes:
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.
This ret variable pattern is pretty standard in Linux, as it makes it easier to add new code that may trigger new errors (using the usual "goto forest" error handling pattern)
I don't see any benefit in whole-sale removing it. The compiler doesn't care about it and will generate the same code in any case.
Peter is not selling this in the right way, it's not about saving memory. The patch is good because: return IRQ_HANDLED; is clearer to read than: return ret; And then when you remove the one user, you may as well remove the unused variable. You could leave it there for future work but really it's not hard to add it back if it's needed. regards, dan carpenter
Added CC: trivial@vger.kernel.org On Sun, May 18, 2014 at 7:04 AM, Andi Kleen <andi@firstfloor.org> wrote:
Peter Senna Tschudin <peter.senna@gmail.com> writes:
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.
This ret variable pattern is pretty standard in Linux, as it makes it easier to add new code that may trigger new errors (using the usual "goto forest" error handling pattern) The average age in days of the return statements my patch changes is 1384, which is more than 3 years, so, in average, the plan of adding new code was lost... See: http://pastebin.com/2k13sHU2
I don't see any benefit in whole-sale removing it. The compiler doesn't care about it and will generate the same code in any case.
My goal is to make the code cleaner and easier to understand. Should I split this into a lot of patches?
-Andi
-- ak@linux.intel.com -- Speaking for myself only
-- Peter
On Sun, May 18, 2014 at 5:14 AM, Peter Senna Tschudin <peter.senna@gmail.com> wrote:
Added CC: trivial@vger.kernel.org
On Sun, May 18, 2014 at 7:04 AM, Andi Kleen <andi@firstfloor.org> wrote:
Peter Senna Tschudin <peter.senna@gmail.com> writes:
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.
This ret variable pattern is pretty standard in Linux, as it makes it easier to add new code that may trigger new errors (using the usual "goto forest" error handling pattern) The average age in days of the return statements my patch changes is 1384, which is more than 3 years, so, in average, the plan of adding new code was lost... See: http://pastebin.com/2k13sHU2
I don't see any benefit in whole-sale removing it. The compiler doesn't care about it and will generate the same code in any case.
My goal is to make the code cleaner and easier to understand.
Should I split this into a lot of patches?
-Andi
-- ak@linux.intel.com -- Speaking for myself only
-- Peter
NAK on the drivers/net/ethernet/intel/i40e/i40e_dcb.c change because I have patches currently in my queue that make the return variable necessary. -- Cheers, Jeff
participants (4)
-
Andi Kleen -
Dan Carpenter -
Jeff Kirsher -
Peter Senna Tschudin