Skip to contentSkip to conversation

staging: media: Remove ternary operator

PATCH Superseded Gargi Sharma 1 participant 2 messages Feb 19, 2017

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: media: Remove ternary operator

Relational and logical operators evaluate to either true or false. Explicit conversion is not needed so remove the ternary operator. Done using coccinelle:

@r@
expression A,B;
symbol true,false;
binary operator b = {==,!=,&&,||,>=,<=,>,<};
@@
- (A b B) ? true : false
+ A b B

---
 drivers/staging/media/platform/bcm2835/controls.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/media/platform/bcm2835/controls.c +1 -3
index a40987b..4d7e2a2 100644
@@ -218,9 +218,7 @@ static int ctrl_set_iso(struct bm2835_mmal_dev *dev,
 		dev->iso = iso_values[ctrl->val];
 	else if (ctrl->id == V4L2_CID_ISO_SENSITIVITY_AUTO)
 		dev->manual_iso_enabled =
-				(ctrl->val == V4L2_ISO_SENSITIVITY_MANUAL ?
-							true :
-							false);
+				(ctrl->val == V4L2_ISO_SENSITIVITY_MANUAL);
 
 	control = &dev->component[MMAL_COMPONENT_CAMERA]->control;
 
Signature · 1 line
2.7.4
#1 lore raw

Please ignore.

Quoted 13 lines · Gargi Sharma

Relational and logical operators evaluate to either true or false. Explicit conversion is not needed so remove the ternary operator. Done using coccinelle:

@r@
expression A,B;
symbol true,false;
binary operator b = {==,!=,&&,||,>=,<=,>,<};
@@
- (A b B) ? true : false
+ A b B

Review

Quoted 6 lines
---
 drivers/staging/media/platform/bcm2835/controls.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/media/platform/bcm2835/controls.c

drivers/staging/media/platform/bcm2835/controls.c static int ctrl_set_iso(struct bm2835_mmal_dev *dev, · line 221

Quoted 8 lines

index a40987b..4d7e2a2 100644

drivers/staging/media/platform/bcm2835/controls.c +0 -1
@@ -218,9 +218,7 @@ static int ctrl_set_iso(struct bm2835_mmal_dev *dev,
                dev->iso = iso_values[ctrl->val];
        else if (ctrl->id == V4L2_CID_ISO_SENSITIVITY_AUTO)
                dev->manual_iso_enabled =
-                               (ctrl->val == V4L2_ISO_SENSITIVITY_MANUAL

?

drivers/staging/media/platform/bcm2835/controls.c static int ctrl_set_iso(struct bm2835_mmal_dev *dev,

Quoted 3 lines
drivers/staging/media/platform/bcm2835/controls.c +1 -2
-                                                       true :
-                                                       false);
+                               (ctrl->val ==

V4L2_ISO_SENSITIVITY_MANUAL);

Quoted 6 lines
drivers/staging/media/platform/bcm2835/controls.c +0 -1
        control = &dev->component[MMAL_COMPONENT_CAMERA]->control;
 
--

2.7.4