Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1611887 > unrolled thread
| Started by | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| First post | 2017-03-29 14:40 +0200 |
| Last post | 2017-03-29 17:00 +0200 |
| Articles | 5 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro simran singhal <singhalsimran0@gmail.com> - 2017-03-29 14:40 +0200
Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro Julia Lawall <julia.lawall@lip6.fr> - 2017-03-29 14:50 +0200
Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro Lars-Peter Clausen <lars@metafoo.de> - 2017-03-29 15:00 +0200
Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-29 17:00 +0200
Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-29 17:00 +0200
| From | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-29 14:40 +0200 |
| Subject | [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro |
| Message-ID | <tql3j-6Rq-1@gated-at.bofh.it> |
Use macro min() to get the minimum of two values for brevity and readability. Signed-off-by: simran singhal <singhalsimran0@gmail.com> --- drivers/iio/light/si1145.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c index 096034c..e7ad6fb 100644 --- a/drivers/iio/light/si1145.c +++ b/drivers/iio/light/si1145.c @@ -557,7 +557,7 @@ static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask) data->scan_mask = scan_mask; ret = si1145_param_set(data, SI1145_PARAM_CHLIST, reg); - return ret < 0 ? ret : 0; + return min(ret, 0); } static int si1145_measure(struct iio_dev *indio_dev, -- 2.7.4
[toc] | [next] | [standalone]
| From | Julia Lawall <julia.lawall@lip6.fr> |
|---|---|
| Date | 2017-03-29 14:50 +0200 |
| Subject | Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro |
| Message-ID | <tqlcZ-6UL-3@gated-at.bofh.it> |
| In reply to | #1611887 |
On Wed, 29 Mar 2017, simran singhal wrote: > Use macro min() to get the minimum of two values for brevity and > readability. > > Signed-off-by: simran singhal <singhalsimran0@gmail.com> > --- > drivers/iio/light/si1145.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c > index 096034c..e7ad6fb 100644 > --- a/drivers/iio/light/si1145.c > +++ b/drivers/iio/light/si1145.c > @@ -557,7 +557,7 @@ static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask) > data->scan_mask = scan_mask; > ret = si1145_param_set(data, SI1145_PARAM_CHLIST, reg); > > - return ret < 0 ? ret : 0; > + return min(ret, 0); A similar change involving max was already rejected. ret < 0 is a standard way of detecting an error, so perhaps leaving that explicitly present will be preferred. julia > } > > static int si1145_measure(struct iio_dev *indio_dev, > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com. > To post to this group, send email to outreachy-kernel@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1490790791-5694-5-git-send-email-singhalsimran0%40gmail.com. > For more options, visit https://groups.google.com/d/optout. >
[toc] | [prev] | [next] | [standalone]
| From | Lars-Peter Clausen <lars@metafoo.de> |
|---|---|
| Date | 2017-03-29 15:00 +0200 |
| Subject | Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro |
| Message-ID | <tqlmF-6Yd-5@gated-at.bofh.it> |
| In reply to | #1611903 |
On 03/29/2017 02:40 PM, Julia Lawall wrote: > > > On Wed, 29 Mar 2017, simran singhal wrote: > >> Use macro min() to get the minimum of two values for brevity and >> readability. >> >> Signed-off-by: simran singhal <singhalsimran0@gmail.com> >> --- >> drivers/iio/light/si1145.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c >> index 096034c..e7ad6fb 100644 >> --- a/drivers/iio/light/si1145.c >> +++ b/drivers/iio/light/si1145.c >> @@ -557,7 +557,7 @@ static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask) >> data->scan_mask = scan_mask; >> ret = si1145_param_set(data, SI1145_PARAM_CHLIST, reg); >> >> - return ret < 0 ? ret : 0; >> + return min(ret, 0); > > A similar change involving max was already rejected. ret < 0 is a > standard way of detecting an error, so perhaps leaving that explicitly > present will be preferred. I think a more sensible thing to do here is to check whether ret/err can actually take any positive values and if not, replace the whole thing with just 'return ret;' or 'return some_fn()'. I'd expect that his can be done in most of the cases.
[toc] | [prev] | [next] | [standalone]
| From | SIMRAN SINGHAL <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-29 17:00 +0200 |
| Subject | Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro |
| Message-ID | <tqneO-8iT-25@gated-at.bofh.it> |
| In reply to | #1611904 |
On Wed, Mar 29, 2017 at 6:23 PM, Lars-Peter Clausen <lars@metafoo.de> wrote: > On 03/29/2017 02:40 PM, Julia Lawall wrote: >> >> >> On Wed, 29 Mar 2017, simran singhal wrote: >> >>> Use macro min() to get the minimum of two values for brevity and >>> readability. >>> >>> Signed-off-by: simran singhal <singhalsimran0@gmail.com> >>> --- >>> drivers/iio/light/si1145.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c >>> index 096034c..e7ad6fb 100644 >>> --- a/drivers/iio/light/si1145.c >>> +++ b/drivers/iio/light/si1145.c >>> @@ -557,7 +557,7 @@ static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask) >>> data->scan_mask = scan_mask; >>> ret = si1145_param_set(data, SI1145_PARAM_CHLIST, reg); >>> >>> - return ret < 0 ? ret : 0; >>> + return min(ret, 0); >> >> A similar change involving max was already rejected. ret < 0 is a >> standard way of detecting an error, so perhaps leaving that explicitly >> present will be preferred. > > I think a more sensible thing to do here is to check whether ret/err can > actually take any positive values and if not, replace the whole thing with > just 'return ret;' or 'return some_fn()'. I'd expect that his can be done in > most of the cases. >
[toc] | [prev] | [next] | [standalone]
| From | SIMRAN SINGHAL <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-29 17:00 +0200 |
| Subject | Re: [Outreachy kernel] [PATCH 4/4] iio: light: si1145: Replace ternary operator with min macro |
| Message-ID | <tqneP-8iT-41@gated-at.bofh.it> |
| In reply to | #1612003 |
On Wed, Mar 29, 2017 at 8:22 PM, SIMRAN SINGHAL <singhalsimran0@gmail.com> wrote: > On Wed, Mar 29, 2017 at 6:23 PM, Lars-Peter Clausen <lars@metafoo.de> wrote: >> On 03/29/2017 02:40 PM, Julia Lawall wrote: >>> >>> >>> On Wed, 29 Mar 2017, simran singhal wrote: >>> >>>> Use macro min() to get the minimum of two values for brevity and >>>> readability. >>>> >>>> Signed-off-by: simran singhal <singhalsimran0@gmail.com> >>>> --- >>>> drivers/iio/light/si1145.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/iio/light/si1145.c b/drivers/iio/light/si1145.c >>>> index 096034c..e7ad6fb 100644 >>>> --- a/drivers/iio/light/si1145.c >>>> +++ b/drivers/iio/light/si1145.c >>>> @@ -557,7 +557,7 @@ static int si1145_set_chlist(struct iio_dev *indio_dev, unsigned long scan_mask) >>>> data->scan_mask = scan_mask; >>>> ret = si1145_param_set(data, SI1145_PARAM_CHLIST, reg); >>>> >>>> - return ret < 0 ? ret : 0; >>>> + return min(ret, 0); >>> >>> A similar change involving max was already rejected. ret < 0 is a >>> standard way of detecting an error, so perhaps leaving that explicitly >>> present will be preferred. >> >> I think a more sensible thing to do here is to check whether ret/err can >> actually take any positive values and if not, replace the whole thing with >> just 'return ret;' or 'return some_fn()'. I'd expect that his can be done in >> most of the cases. >> Lars, I will check it and resend it.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web