Skip to contentSkip to conversation

staging: iio: meter: replace ternary operator by if condition

PATCH In review Deepak R Varma 2 participants 2 messages Nov 13, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: iio: meter: replace ternary operator by if condition

Replace ternary operator by simple if based evaluation of the return value. Issue identified using coccicheck.

---

Changes in v2:
1. Use if based evaluation instead of using min macro suggested by Joe Perches.

 drivers/staging/iio/meter/ade7854-i2c.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/iio/meter/ade7854-i2c.c +4 -1
index a9a06e8dda51..71b67dd3c8e9 100644
@@ -61,7 +61,10 @@ static int ade7854_i2c_write_reg(struct device *dev,
 unlock:
 	mutex_unlock(&st->buf_lock);
 
-	return ret < 0 ? ret : 0;
+	if (ret < 0)
+		return ret;
+
+	return 0;
 }
 
 static int ade7854_i2c_read_reg(struct device *dev,

--
2.34.1

maintainer
#1 lore raw
Quoted 4 lines · On Sun, 13 Nov 2022 10:58:20 +0530 Deepak R Varma <[email protected]> wrote:

Replace ternary operator by simple if based evaluation of the return value. Issue identified using coccicheck.

Applied to the togreg branch of iio.git and pushed out as testing to see if 0-day can find anything we missed.

Thanks,

Jonathan

Quoted 31 lines

---

Changes in v2:
1. Use if based evaluation instead of using min macro suggested by Joe Perches.

 drivers/staging/iio/meter/ade7854-i2c.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/iio/meter/ade7854-i2c.c +4 -2
index a9a06e8dda51..71b67dd3c8e9 100644
@@ -61,7 +61,10 @@ static int ade7854_i2c_write_reg(struct device *dev,
 unlock:
 	mutex_unlock(&st->buf_lock);
 
-	return ret < 0 ? ret : 0;
+	if (ret < 0)
+		return ret;
+
+	return 0;
 }
 
 static int ade7854_i2c_read_reg(struct device *dev,
--

2.34.1