Skip to contentSkip to conversation

locking/refcount: Use REFCOUNT_WARN() to simplify code

PATCH In review Zhen Lei 2 participants 3 messages Mar 16, 2022 – Nov 2, 2022 Library code

lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

PATCH 1/1 locking/refcount: Use REFCOUNT_WARN() to simplify code

To avoid the check "new > val" appears twice, and make the style consistent with that in refcount_warn_saturate().

---
 lib/refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/refcount.c +1 -1
index a207a8f22b3ca35..d36aa3fa728f53b 100644
@@ -84,7 +84,7 @@ bool refcount_dec_not_one(refcount_t *r)
 
 		new = val - 1;
 		if (new > val) {
-			WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
+			REFCOUNT_WARN("underflow; use-after-free");
 			return true;
 		}
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 13 lines · Zhen Lei

To avoid the check "new > val" appears twice, and make the style consistent with that in refcount_warn_saturate().

---
 lib/refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/refcount.c +0 -0
index a207a8f22b3ca35..d36aa3fa728f53b 100644

lib/refcount.c bool refcount_dec_not_one(refcount_t *r) · line 89

Quoted 7 lines
lib/refcount.c +1 -1
@@ -84,7 +84,7 @@ bool refcount_dec_not_one(refcount_t *r)
 
 		new = val - 1;
 		if (new > val) {
-			WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
+			REFCOUNT_WARN("underflow; use-after-free");
 			return true;
 		}

Will

#2 lore raw
Quoted 15 lines · Will Deacon
Quoted 14 lines · Zhen Lei

To avoid the check "new > val" appears twice, and make the style consistent with that in refcount_warn_saturate().

---
 lib/refcount.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/refcount.c +0 -0
index a207a8f22b3ca35..d36aa3fa728f53b 100644
@@ -84,7 +84,7 @@ bool refcount_dec_not_one(refcount_t *r)
 
Quoted 8 lines

lib/refcount.c bool refcount_dec_not_one(refcount_t *r) · line 89

Quoted 6 lines
lib/refcount.c +1 -1
 		new = val - 1;
 		if (new > val) {
-			WARN_ONCE(new > val, "refcount_t: underflow; use-after-free.\n");
+			REFCOUNT_WARN("underflow; use-after-free");
 			return true;
 		}

Can anyone pick up this patch? It seems to have been forgotten.

Quoted 4 lines

Will
.

Signature · 2 lines
Regards,
  Zhen Lei