From bab550371cb13fe7adc4105a57d0530565740fc6 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Mon, 26 Dec 2022 17:10:48 +0530 Subject: coccinelle: api/atomic_as_refcounter: include message type in output A common practice is to grep for "WARNING" or "ERROR" text in the report output from a Coccinelle semantic patch script. So, include the text "WARNING: " in the report output generated by the semantic patch for desired filtering of the output. Also improves the readability of the output. Here is an example of the old and new outputs reported: xyz_file.c:131:39-40: atomic_add_unless xyz_file.c:131:39-40: WARNING: atomic_add_unless xyz_file.c:196:6-25: atomic_dec_and_test variation before object free at line 208. xyz_file.c:196:6-25: WARNING: atomic_dec_and_test variation before object free at line 208. Signed-off-by: Deepak R Varma Acked-by: Julia Lawall --- scripts/coccinelle/api/atomic_as_refcounter.cocci | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci index e63d52408b86..bbe5b2932933 100644 --- a/scripts/coccinelle/api/atomic_as_refcounter.cocci +++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci @@ -55,7 +55,7 @@ identifier fname6 =~ ".*call_rcu.*"; p1 << r1.p1; p2 << r1.p2; @@ -msg = "atomic_dec_and_test variation before object free at line %s." +msg = "WARNING: atomic_dec_and_test variation before object free at line %s." coccilib.report.print_report(p1[0], msg % (p2[0].line)) @r4 exists@ @@ -88,7 +88,7 @@ fname@p2(y, ...); p1 << r4.p1; p2 << r4.p2; @@ -msg = "atomic_dec_and_test variation before object free at line %s." +msg = "WARNING: atomic_dec_and_test variation before object free at line %s." coccilib.report.print_report(p1[0], msg % (p2[0].line)) @r2 exists@ @@ -107,7 +107,7 @@ atomic64_add_unless(&(a)->x,-1,1)@p1 @script:python depends on report@ p1 << r2.p1; @@ -msg = "atomic_add_unless" +msg = "WARNING: atomic_add_unless" coccilib.report.print_report(p1[0], msg) @r3 exists@ @@ -126,5 +126,5 @@ x = atomic64_add_return@p1(-1, ...); @script:python depends on report@ p1 << r3.p1; @@ -msg = "x = atomic_add_return(-1, ...)" +msg = "WARNING: x = atomic_add_return(-1, ...)" coccilib.report.print_report(p1[0], msg) -- cgit v1.2.3 From 180da5ef84fba0a8ea06870a38d6d657d689944a Mon Sep 17 00:00:00 2001 From: Peter Foley Date: Fri, 13 Jan 2023 12:29:36 -0500 Subject: scripts: coccicheck: Avoid warning about spurious escape e.g. grep: warning: stray \ before - Signed-off-by: Peter Foley Signed-off-by: Julia Lawall --- scripts/coccicheck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/coccicheck b/scripts/coccicheck index 2956fce8fa4f..fb492f032c5f 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -18,7 +18,7 @@ fi SPATCH_VERSION=$($SPATCH --version | head -1 | awk '{print $3}') USE_JOBS="no" -$SPATCH --help | grep "\-\-jobs" > /dev/null && USE_JOBS="yes" +$SPATCH --help | grep -e "--jobs" > /dev/null && USE_JOBS="yes" # The verbosity may be set by the environmental parameter V= # as for example with 'make V=1 coccicheck' -- cgit v1.2.3 From 2b2d50bdd258f8ef37c25f7d5f0d7ba694066dec Mon Sep 17 00:00:00 2001 From: Jarkko Sakkinen Date: Thu, 26 Jan 2023 21:56:12 +0000 Subject: scripts: coccicheck: Use /usr/bin/env If bash is not located under /bin, coccicheck fails to run. In the real world, this happens for instance when NixOS is used in the host. Instead, use /usr/bin/env to locate the executable binary for bash. Signed-off-by: Jarkko Sakkinen Tested-by: Deepak R Varma Signed-off-by: Julia Lawall --- scripts/coccicheck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/coccicheck b/scripts/coccicheck index fb492f032c5f..e52cb43fede6 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # SPDX-License-Identifier: GPL-2.0 # Linux kernel coccicheck # -- cgit v1.2.3