Skip to contentSkip to conversation

bcachefs: Use max() to improve gen_after()

PATCH Applied Thorsten Blum 2 participants 2 messages Mar 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bcachefs: Use max() to improve gen_after()

Use max() to simplify gen_after() and improve its readability.

---
 fs/bcachefs/buckets.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/bcachefs/buckets.h +1 -3
index a9acdd6c0c86..124ac380b22e 100644
@@ -167,9 +167,7 @@ static inline int gen_cmp(u8 a, u8 b)
 
 static inline int gen_after(u8 a, u8 b)
 {
-	int r = gen_cmp(a, b);
-
-	return r > 0 ? r : 0;
+	return max(0, gen_cmp(a, b));
 }
 
 static inline int dev_ptr_stale_rcu(struct bch_dev *ca, const struct bch_extent_ptr *ptr)
Signature · 1 line
2.48.1
#1 lore raw
Quoted 3 lines · Thorsten Blum

Use max() to simplify gen_after() and improve its readability.

applied

Quoted 22 lines
---
 fs/bcachefs/buckets.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
fs/bcachefs/buckets.h +1 -3
index a9acdd6c0c86..124ac380b22e 100644
@@ -167,9 +167,7 @@ static inline int gen_cmp(u8 a, u8 b)
 
 static inline int gen_after(u8 a, u8 b)
 {
-	int r = gen_cmp(a, b);
-
-	return r > 0 ? r : 0;
+	return max(0, gen_cmp(a, b));
 }
 
 static inline int dev_ptr_stale_rcu(struct bch_dev *ca, const struct bch_extent_ptr *ptr)
Signature · 1 line
2.48.1