Patchwork [2/2] checkpatch.pl: make C99 comments a warning, not error

login
register
mail settings
Submitter Michael Roth
Date April 1, 2011, 3:20 p.m.
Message ID <1301671255-27717-3-git-send-email-mdroth@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/89319/
State New
Headers show

Comments

Michael Roth - April 1, 2011, 3:20 p.m.
C99 comments are pretty heavilly used in QEMU, and don't violate
anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 scripts/checkpatch.pl |    2 +-
 test.c                |    5 +++++
 2 files changed, 6 insertions(+), 1 deletions(-)
 create mode 100644 test.c
Michael Roth - April 1, 2011, 3:33 p.m.
On 04/01/2011 10:20 AM, Michael Roth wrote:
> C99 comments are pretty heavilly used in QEMU, and don't violate
> anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.
>
> Signed-off-by: Michael Roth<mdroth@linux.vnet.ibm.com>
> ---
>   scripts/checkpatch.pl |    2 +-
>   test.c                |    5 +++++
>   2 files changed, 6 insertions(+), 1 deletions(-)
>   create mode 100644 test.c
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 770d534..2aab4e9 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1799,7 +1799,7 @@ sub process {
>
>   # no C99 // comments
>   		if ($line =~ m{//}) {
> -			ERROR("do not use C99 // comments\n" . $herecurr);
> +			WARN("do not use C99 // comments\n" . $herecurr);
>   		}
>   		# Remove C99 comments.
>   		$line =~ s@//.*@@;
> diff --git a/test.c b/test.c
> new file mode 100644
> index 0000000..fe3b163
> --- /dev/null
> +++ b/test.c
> @@ -0,0 +1,5 @@
> +//stuff
> +static int blah(void)
> +{
> +    return 1;
> +}

Ugh, please ignore this test.c addition. Let me know if I should resend
Blue Swirl - April 1, 2011, 6:46 p.m.
On Fri, Apr 1, 2011 at 6:20 PM, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> C99 comments are pretty heavilly used in QEMU, and don't violate
> anything mentioned in HACKING/CODING_STYLE. Make them warnings instead.
>
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  scripts/checkpatch.pl |    2 +-
>  test.c                |    5 +++++
>  2 files changed, 6 insertions(+), 1 deletions(-)
>  create mode 100644 test.c
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 770d534..2aab4e9 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1799,7 +1799,7 @@ sub process {
>
>  # no C99 // comments
>                if ($line =~ m{//}) {
> -                       ERROR("do not use C99 // comments\n" . $herecurr);
> +                       WARN("do not use C99 // comments\n" . $herecurr);

I think the only reasonable use for C99 comments is
//#define DEBUG_xyz
for quickly enabling debugging printfs.

But even this pattern should be replaced by tracepoints, since they
are much better. So I'd prefer to keep the ERROR.
Stefan Hajnoczi - April 2, 2011, 2:02 p.m.
On Fri, Apr 1, 2011 at 7:46 PM, Blue Swirl <blauwirbel@gmail.com> wrote:
> I think the only reasonable use for C99 comments is
> //#define DEBUG_xyz
> for quickly enabling debugging printfs.
>
> But even this pattern should be replaced by tracepoints, since they
> are much better. So I'd prefer to keep the ERROR.

Please update CODING_STYLE.

Stefan

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 770d534..2aab4e9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1799,7 +1799,7 @@  sub process {
 
 # no C99 // comments
 		if ($line =~ m{//}) {
-			ERROR("do not use C99 // comments\n" . $herecurr);
+			WARN("do not use C99 // comments\n" . $herecurr);
 		}
 		# Remove C99 comments.
 		$line =~ s@//.*@@;
diff --git a/test.c b/test.c
new file mode 100644
index 0000000..fe3b163
--- /dev/null
+++ b/test.c
@@ -0,0 +1,5 @@ 
+//stuff
+static int blah(void)
+{
+    return 1;
+}