Re: [PATCH] iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-26 Thread Jonathan Cameron
On Thu, 26 Oct 2017 16:51:13 +0100 Jonathan Cameron wrote: > On Wed, 25 Oct 2017 18:22:02 +0200 > Hans de Goede wrote: > > > Hi, > > > > On 25-10-17 18:15, SF Markus Elfring wrote: > > >> IMHO, if you do this, you should rework the function so that there is a > > >> single unlock call > > >

Re: iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-26 Thread Jonathan Cameron
On Wed, 25 Oct 2017 20:07:48 +0200 SF Markus Elfring wrote: > > What you are suggesting breaks this pattern > > I might be looking for an other balance between involved implementation > details after your constructive feedback for my first approach > in this software module. > > > > (not usi

Re: [PATCH] iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-26 Thread Jonathan Cameron
On Wed, 25 Oct 2017 18:22:02 +0200 Hans de Goede wrote: > Hi, > > On 25-10-17 18:15, SF Markus Elfring wrote: > >> IMHO, if you do this, you should rework the function so that there is a > >> single unlock call > >> at the end, not a separate one in in error label. > > > > Thanks for your up

Re: iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread SF Markus Elfring
> What you are suggesting breaks this pattern I might be looking for an other balance between involved implementation details after your constructive feedback for my first approach in this software module. > (not using a goto in the last if (err) case) I would find it nice when a bit more code

Re: iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread Hans de Goede
Hi, On 25-10-17 18:58, SF Markus Elfring wrote: If that is the only unlock in the function, then it is probably best to keep things as is. In general gotos are considered better then multiple unlocks, but not having either is even better. Thanks for your quick feedback. How do you think abo

Re: iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread SF Markus Elfring
> If that is the only unlock in the function, then it is probably > best to keep things as is. In general gotos are considered > better then multiple unlocks, but not having either is > even better. Thanks for your quick feedback. >> How do you think about to use the following code variant then?

Re: [PATCH] iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread Hans de Goede
Hi, On 25-10-17 18:15, SF Markus Elfring wrote: IMHO, if you do this, you should rework the function so that there is a single unlock call at the end, not a separate one in in error label. Thanks for your update suggestion. Does it indicate that I may propose similar source code adjustments

Re: [PATCH] iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread SF Markus Elfring
> IMHO, if you do this, you should rework the function so that there is a > single unlock call > at the end, not a separate one in in error label. Thanks for your update suggestion. Does it indicate that I may propose similar source code adjustments in this software area? > Could e.g. change t

Re: [PATCH] iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread Hans de Goede
Hi, On 25-10-17 16:33, SF Markus Elfring wrote: From: Markus Elfring Date: Wed, 25 Oct 2017 16:26:29 +0200 Add a jump target so that a call of the function "mutex_unlock" is mostly stored at the end of these function implementations. Replace five calls by goto statements. This issue was detec

[PATCH] iio/accel/bmc150: Improve unlocking of a mutex in two functions

2017-10-25 Thread SF Markus Elfring
From: Markus Elfring Date: Wed, 25 Oct 2017 16:26:29 +0200 Add a jump target so that a call of the function "mutex_unlock" is mostly stored at the end of these function implementations. Replace five calls by goto statements. This issue was detected by using the Coccinelle software. Signed-off-b