All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
@ 2017-10-27 16:20 ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-10-27 16:20 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Dan Carpenter,
	Greg Kroah-Hartman
  Cc: LKML, Jonathan Cameron, Samu Onkalo

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Oct 2017 18:00:31 +0200

Adjust jump targets so that a bit of exception handling can be better
reused in an if branch of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/bh1770glc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index 9c62bf064f77..c4c108ed88b0 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -660,15 +660,14 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_get_sync(dev);
 
 		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
-		if (ret < 0) {
-			pm_runtime_put(dev);
-			goto leave;
-		}
+		if (ret < 0)
+			goto put_runtime;
 
 		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
 		if (ret < 0) {
+put_runtime:
 			pm_runtime_put(dev);
-			goto leave;
+			goto unlock;
 		}
 
 		/* This causes interrupt after the next measurement cycle */
@@ -681,7 +680,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_put(dev);
 	}
 	ret = count;
-leave:
+unlock:
 	mutex_unlock(&chip->mutex);
 	return ret;
 }
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
@ 2017-10-27 16:20 ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-10-27 16:20 UTC (permalink / raw)
  To: kernel-janitors, Andrew Morton, Arnd Bergmann, Dan Carpenter,
	Greg Kroah-Hartman
  Cc: LKML, Jonathan Cameron, Samu Onkalo

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 27 Oct 2017 18:00:31 +0200

Adjust jump targets so that a bit of exception handling can be better
reused in an if branch of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/bh1770glc.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index 9c62bf064f77..c4c108ed88b0 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -660,15 +660,14 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_get_sync(dev);
 
 		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
-		if (ret < 0) {
-			pm_runtime_put(dev);
-			goto leave;
-		}
+		if (ret < 0)
+			goto put_runtime;
 
 		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
 		if (ret < 0) {
+put_runtime:
 			pm_runtime_put(dev);
-			goto leave;
+			goto unlock;
 		}
 
 		/* This causes interrupt after the next measurement cycle */
@@ -681,7 +680,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_put(dev);
 	}
 	ret = count;
-leave:
+unlock:
 	mutex_unlock(&chip->mutex);
 	return ret;
 }
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
  2017-10-27 16:20 ` SF Markus Elfring
@ 2017-10-27 17:11   ` Daniele Nicolodi
  -1 siblings, 0 replies; 8+ messages in thread
From: Daniele Nicolodi @ 2017-10-27 17:11 UTC (permalink / raw)
  To: SF Markus Elfring, kernel-janitors, Andrew Morton, Arnd Bergmann,
	Dan Carpenter, Greg Kroah-Hartman
  Cc: LKML, Jonathan Cameron, Samu Onkalo

On 10/27/17 10:20 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 27 Oct 2017 18:00:31 +0200
> 
> Adjust jump targets so that a bit of exception handling can be better
> reused in an if branch of this function.

What is the benefit brought by this change?

Anyhow, are you seriously suggesting adding a goto to a label define
within a if block?  Is this somehow an Halloween related joke?


> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/misc/bh1770glc.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
> index 9c62bf064f77..c4c108ed88b0 100644
> --- a/drivers/misc/bh1770glc.c
> +++ b/drivers/misc/bh1770glc.c
> @@ -660,15 +660,14 @@ static ssize_t bh1770_power_state_store(struct device *dev,
>  		pm_runtime_get_sync(dev);
>  
>  		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
> -		if (ret < 0) {
> -			pm_runtime_put(dev);
> -			goto leave;
> -		}
> +		if (ret < 0)
> +			goto put_runtime;
>  
>  		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
>  		if (ret < 0) {
> +put_runtime:
>  			pm_runtime_put(dev);
> -			goto leave;
> +			goto unlock;
>  		}
>  
>  		/* This causes interrupt after the next measurement cycle */
> @@ -681,7 +680,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
>  		pm_runtime_put(dev);
>  	}
>  	ret = count;
> -leave:
> +unlock:
>  	mutex_unlock(&chip->mutex);
>  	return ret;
>  }
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
@ 2017-10-27 17:11   ` Daniele Nicolodi
  0 siblings, 0 replies; 8+ messages in thread
From: Daniele Nicolodi @ 2017-10-27 17:11 UTC (permalink / raw)
  To: SF Markus Elfring, kernel-janitors, Andrew Morton, Arnd Bergmann,
	Dan Carpenter, Greg Kroah-Hartman
  Cc: LKML, Jonathan Cameron, Samu Onkalo

On 10/27/17 10:20 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 27 Oct 2017 18:00:31 +0200
> 
> Adjust jump targets so that a bit of exception handling can be better
> reused in an if branch of this function.

What is the benefit brought by this change?

Anyhow, are you seriously suggesting adding a goto to a label define
within a if block?  Is this somehow an Halloween related joke?


> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/misc/bh1770glc.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
> index 9c62bf064f77..c4c108ed88b0 100644
> --- a/drivers/misc/bh1770glc.c
> +++ b/drivers/misc/bh1770glc.c
> @@ -660,15 +660,14 @@ static ssize_t bh1770_power_state_store(struct device *dev,
>  		pm_runtime_get_sync(dev);
>  
>  		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
> -		if (ret < 0) {
> -			pm_runtime_put(dev);
> -			goto leave;
> -		}
> +		if (ret < 0)
> +			goto put_runtime;
>  
>  		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
>  		if (ret < 0) {
> +put_runtime:
>  			pm_runtime_put(dev);
> -			goto leave;
> +			goto unlock;
>  		}
>  
>  		/* This causes interrupt after the next measurement cycle */
> @@ -681,7 +680,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
>  		pm_runtime_put(dev);
>  	}
>  	ret = count;
> -leave:
> +unlock:
>  	mutex_unlock(&chip->mutex);
>  	return ret;
>  }
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
  2017-10-27 17:11   ` Daniele Nicolodi
@ 2017-10-27 17:23     ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2017-10-27 17:23 UTC (permalink / raw)
  To: Daniele Nicolodi
  Cc: SF Markus Elfring, kernel-janitors, Andrew Morton, Arnd Bergmann,
	Dan Carpenter, LKML, Jonathan Cameron, Samu Onkalo

On Fri, Oct 27, 2017 at 11:11:13AM -0600, Daniele Nicolodi wrote:
> On 10/27/17 10:20 AM, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Fri, 27 Oct 2017 18:00:31 +0200
> > 
> > Adjust jump targets so that a bit of exception handling can be better
> > reused in an if branch of this function.
> 
> What is the benefit brought by this change?

Please note, you are responding to someone who lots and lots of kernel
maintainers/developers have blacklisted, myself included.  It's just not
worth your effort, I recommend doing the same, as I'm not applying any
patches from this author, unless some other maintainer wants to take the
time to validate and send them on to me.

kill-files are a good thing, please use them :)

good luck!

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
@ 2017-10-27 17:23     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 8+ messages in thread
From: Greg Kroah-Hartman @ 2017-10-27 17:23 UTC (permalink / raw)
  To: Daniele Nicolodi
  Cc: SF Markus Elfring, kernel-janitors, Andrew Morton, Arnd Bergmann,
	Dan Carpenter, LKML, Jonathan Cameron, Samu Onkalo

On Fri, Oct 27, 2017 at 11:11:13AM -0600, Daniele Nicolodi wrote:
> On 10/27/17 10:20 AM, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Fri, 27 Oct 2017 18:00:31 +0200
> > 
> > Adjust jump targets so that a bit of exception handling can be better
> > reused in an if branch of this function.
> 
> What is the benefit brought by this change?

Please note, you are responding to someone who lots and lots of kernel
maintainers/developers have blacklisted, myself included.  It's just not
worth your effort, I recommend doing the same, as I'm not applying any
patches from this author, unless some other maintainer wants to take the
time to validate and send them on to me.

kill-files are a good thing, please use them :)

good luck!

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
  2017-10-27 17:11   ` Daniele Nicolodi
@ 2017-10-27 18:04     ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-10-27 18:04 UTC (permalink / raw)
  To: Daniele Nicolodi, Andrew Morton, Arnd Bergmann, Dan Carpenter,
	Greg Kroah-Hartman, kernel-janitors
  Cc: LKML, Jonathan Cameron, Samu Onkalo

>> Adjust jump targets so that a bit of exception handling can be better
>> reused in an if branch of this function.
> 
> What is the benefit brought by this change?

Will you notice that the object code size can be a bit smaller
because the call of the function “pm_runtime_put” is specified at
two places in the implementation in comparison to three places before?


> Anyhow, are you seriously suggesting adding a goto to a label define
> within a if block?

Yes. - For this update suggestion.


> Is this somehow an Halloween related joke?

I hope not.

Another software design approach would be to move two statements from
the affected if branch to the end of this function. Such an adjustment
would have the consequence that the statement “goto unlock” will be
transformed into a jump to a backward target.
Would you prefer such an implementation variant instead?

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: misc: bh1770glc: Use common error handling code in bh1770_power_state_store()
@ 2017-10-27 18:04     ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-10-27 18:04 UTC (permalink / raw)
  To: Daniele Nicolodi, Andrew Morton, Arnd Bergmann, Dan Carpenter,
	Greg Kroah-Hartman, kernel-janitors
  Cc: LKML, Jonathan Cameron, Samu Onkalo

>> Adjust jump targets so that a bit of exception handling can be better
>> reused in an if branch of this function.
> 
> What is the benefit brought by this change?

Will you notice that the object code size can be a bit smaller
because the call of the function “pm_runtime_put” is specified at
two places in the implementation in comparison to three places before?


> Anyhow, are you seriously suggesting adding a goto to a label define
> within a if block?

Yes. - For this update suggestion.


> Is this somehow an Halloween related joke?

I hope not.

Another software design approach would be to move two statements from
the affected if branch to the end of this function. Such an adjustment
would have the consequence that the statement “goto unlock” will be
transformed into a jump to a backward target.
Would you prefer such an implementation variant instead?

Regards,
Markus

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-10-27 18:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 16:20 [PATCH] misc: bh1770glc: Use common error handling code in bh1770_power_state_store() SF Markus Elfring
2017-10-27 16:20 ` SF Markus Elfring
2017-10-27 17:11 ` Daniele Nicolodi
2017-10-27 17:11   ` Daniele Nicolodi
2017-10-27 17:23   ` Greg Kroah-Hartman
2017-10-27 17:23     ` Greg Kroah-Hartman
2017-10-27 18:04   ` SF Markus Elfring
2017-10-27 18:04     ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.