When atomic_as_refcounter script is used by 0day CI and
the findings are automatically reported, the message that
it gives is confusing to people. I.e. it does not actually
state what should be done.

Add more information to the message output.

Reported-by: Dan Carpenter <dan.carpen...@oracle.com>
Signed-off-by: Elena Reshetova <elena.reshet...@intel.com>
---
 scripts/coccinelle/api/atomic_as_refcounter.cocci | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci 
b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 0f78d94abc35..0ce7618479fd 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -55,7 +55,8 @@ identifier fname6 =~ ".*call_rcu.*";
 p1 << r1.p1;
 p2 << r1.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
+msg = "atomic_dec_and_test variation before object free at line %s. \
+Consider using refcount_t instead of atomic_t for the variable."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r4 exists@
@@ -88,7 +89,8 @@ fname@p2(y, ...);
 p1 << r4.p1;
 p2 << r4.p2;
 @@
-msg = "atomic_dec_and_test variation before object free at line %s."
+msg = "atomic_dec_and_test variation before object free at line %s. \
+Consider using refcount_t instead of atomic_t for the variable."
 coccilib.report.print_report(p1[0], msg % (p2[0].line))
 
 @r2 exists@
@@ -107,7 +109,8 @@ atomic64_add_unless(&(a)->x,-1,1)@p1
 @script:python depends on report@
 p1 << r2.p1;
 @@
-msg = "atomic_add_unless"
+msg = "Usage of atomic_add_unless encountered. \
+Consider using refcount_t instead of atomic_t for the variable."
 coccilib.report.print_report(p1[0], msg)
 
 @r3 exists@
@@ -126,5 +129,6 @@ x = atomic64_add_return@p1(-1, ...);
 @script:python depends on report@
 p1 << r3.p1;
 @@
-msg = "x = atomic_add_return(-1, ...)"
+msg = "Usage of x = atomic_add_return(-1, ...) encountered. \
+Consider using refcount_t instead of atomic_t for the variable."
 coccilib.report.print_report(p1[0], msg)
-- 
2.25.1

_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to