Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1611892 > unrolled thread
| Started by | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| First post | 2017-03-29 14:40 +0200 |
| Last post | 2017-03-29 19:30 +0200 |
| Articles | 3 — 3 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 1/4] iio: common: st_sensors: Replace ternary operator with min macro simran singhal <singhalsimran0@gmail.com> - 2017-03-29 14:40 +0200
Re: [Outreachy kernel] [PATCH 1/4] iio: common: st_sensors: Replace ternary operator with min macro Daniel Baluta <daniel.baluta@gmail.com> - 2017-03-29 18:20 +0200
Re: [Outreachy kernel] [PATCH 1/4] iio: common: st_sensors: Replace ternary operator with min macro SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-29 19:30 +0200
| From | simran singhal <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-29 14:40 +0200 |
| Subject | [PATCH 1/4] iio: common: st_sensors: Replace ternary operator with min macro |
| Message-ID | <tql3k-6Rq-25@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/common/st_sensors/st_sensors_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c index c83df4d..7a68fdd 100644 --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c @@ -39,7 +39,7 @@ static int st_sensors_i2c_read_byte(struct st_sensor_transfer_buffer *tb, *res_byte = err & 0xff; st_accel_i2c_read_byte_error: - return err < 0 ? err : 0; + return min(err, 0); } static int st_sensors_i2c_read_multiple_byte( -- 2.7.4
[toc] | [next] | [standalone]
| From | Daniel Baluta <daniel.baluta@gmail.com> |
|---|---|
| Date | 2017-03-29 18:20 +0200 |
| Subject | Re: [Outreachy kernel] [PATCH 1/4] iio: common: st_sensors: Replace ternary operator with min macro |
| Message-ID | <tqoue-Wy-17@gated-at.bofh.it> |
| In reply to | #1611892 |
On Wed, Mar 29, 2017 at 3:33 PM, simran singhal <singhalsimran0@gmail.com> 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/common/st_sensors/st_sensors_i2c.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c > index c83df4d..7a68fdd 100644 > --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c > +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c > @@ -39,7 +39,7 @@ static int st_sensors_i2c_read_byte(struct st_sensor_transfer_buffer *tb, > *res_byte = err & 0xff; > > st_accel_i2c_read_byte_error: > - return err < 0 ? err : 0; > + return min(err, 0); > } Appreciate the brevity but this certainly doesn't make code easier to read. In linux kernel err < 0 signifies an error and be replacing comparison < 0 with min() we some hide the meaning of this. thanks, Daniel.
[toc] | [prev] | [next] | [standalone]
| From | SIMRAN SINGHAL <singhalsimran0@gmail.com> |
|---|---|
| Date | 2017-03-29 19:30 +0200 |
| Subject | Re: [Outreachy kernel] [PATCH 1/4] iio: common: st_sensors: Replace ternary operator with min macro |
| Message-ID | <tqpzY-1Bd-5@gated-at.bofh.it> |
| In reply to | #1612116 |
On Wed, Mar 29, 2017 at 9:46 PM, Daniel Baluta <daniel.baluta@gmail.com> wrote: > On Wed, Mar 29, 2017 at 3:33 PM, simran singhal > <singhalsimran0@gmail.com> 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/common/st_sensors/st_sensors_i2c.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/iio/common/st_sensors/st_sensors_i2c.c b/drivers/iio/common/st_sensors/st_sensors_i2c.c >> index c83df4d..7a68fdd 100644 >> --- a/drivers/iio/common/st_sensors/st_sensors_i2c.c >> +++ b/drivers/iio/common/st_sensors/st_sensors_i2c.c >> @@ -39,7 +39,7 @@ static int st_sensors_i2c_read_byte(struct st_sensor_transfer_buffer *tb, >> *res_byte = err & 0xff; >> >> st_accel_i2c_read_byte_error: >> - return err < 0 ? err : 0; >> + return min(err, 0); >> } > > Appreciate the brevity but this certainly doesn't make code > easier to read. > > In linux kernel err < 0 signifies an error and be replacing > comparison < 0 with min() we some hide the meaning of this. > Yes, you are right keeping the previous one will be more meaningful. Thanks. > thanks, > Daniel.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web