Skip to contentSkip to conversation

utils: simplify bool returns

PATCH New Rosen Penev 1 participant 1 message Apr 17, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: simplify bool returns

Found with readability-simplify-boolean-expr

---
 utils/cec-compliance/cec-test-audio.cpp | 8 ++------
 utils/cec-follower/cec-processing.cpp   | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)
utils/cec-compliance/cec-test-audio.cpp +2 -6
index 576d59c6..d422a7da 100644
@@ -113,9 +113,7 @@ static bool pa_are_adjacent(__u16 pa1, __u16 pa2)
 		return false;
 	if ((pa1 & trail_mask) || (pa2 & trail_mask))
 		return false;
-	if (!((pa1 & ~mask) && (pa2 & ~mask)))
-		return true;
-	return false;
+	return !((pa1 & ~mask) && (pa2 & ~mask));
 }
 
 static bool pa_is_upstream_from(__u16 pa1, __u16 pa2)
@@ -124,9 +122,7 @@ static bool pa_is_upstream_from(__u16 pa1, __u16 pa2)
 
 	if (pa1 == CEC_PHYS_ADDR_INVALID || pa2 == CEC_PHYS_ADDR_INVALID)
 		return false;
-	if (!(pa1 & ~mask) && (pa2 & ~mask))
-		return true;
-	return false;
+	return !(pa1 & ~mask) && (pa2 & ~mask);
 }
 
 static int arc_initiate_tx(struct node *node, unsigned me, unsigned la, bool interactive)
utils/cec-follower/cec-processing.cpp +2 -6
index 75000b73..e4056c55 100644
@@ -214,9 +214,7 @@ static bool pa_are_adjacent(__u16 pa1, __u16 pa2)
 		return false;
 	if ((pa1 & trail_mask) || (pa2 & trail_mask))
 		return false;
-	if (!((pa1 & ~mask) && (pa2 & ~mask)))
-		return true;
-	return false;
+	return !((pa1 & ~mask) && (pa2 & ~mask));
 }
 
 static bool pa_is_upstream_from(__u16 pa1, __u16 pa2)
@@ -225,9 +223,7 @@ static bool pa_is_upstream_from(__u16 pa1, __u16 pa2)
 
 	if (pa1 == CEC_PHYS_ADDR_INVALID || pa2 == CEC_PHYS_ADDR_INVALID)
 		return false;
-	if (!(pa1 & ~mask) && (pa2 & ~mask))
-		return true;
-	return false;
+	return !(pa1 & ~mask) && (pa2 & ~mask);
 }
 
 static __u8 current_power_state(struct node *node)
Signature · 1 line
2.25.2