public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scripts/checkpatch.pl: Dramatically improve #define parse times
Date: Mon, 8 Feb 2010 15:15:50 -0800	[thread overview]
Message-ID: <20100208151550.15796cad.akpm@linux-foundation.org> (raw)
In-Reply-To: <1265167112.1945.184.camel@Joe-Laptop.home>

On Tue, 02 Feb 2010 19:18:32 -0800
Joe Perches <joe@perches.com> wrote:

> 
> #define macros currently take a _very_ long time to parse because
> the macro is being searched for multiple statements and unnecessary
> searching is being done when comments are replaced with unprintable
> characters.
> 
> For instance:
> 
> Without this patch:
> $ time perl ./scripts/checkpatch.pl -f include/linux/mfd/wm831x/irq.h > /dev/null
> 
> real	3m43.229s
> user	3m42.254s
> sys	0m0.332s
> 
> With this patch: 
> $ time perl ./scripts/checkpatch.pl -f include/linux/mfd/wm831x/irq.h > /dev/null
> 
> real	0m1.372s
> user	0m1.348s
> sys	0m0.020s
> 
> A 160:1 improvement.
> 
> I don't know if this is correct, but it seems to work for me.

This patch triggers lots of warnings:

akpm:/usr/src/25> perl scripts/checkpatch.pl patches/drivers-char-memc-cleanups-fix.patch
Use of uninitialized value in length at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1597.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1655.
Use of uninitialized value in length at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1597.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1655.
Use of uninitialized value in length at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1597.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1655.
Use of uninitialized value in length at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in substr at scripts/checkpatch.pl line 1589.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1597.
Use of uninitialized value in pattern match (m//) at scripts/checkpatch.pl line 1655.


Test case:


diff -puN drivers/char/mem.c~drivers-char-memc-cleanups-fix drivers/char/mem.c
--- a/drivers/char/mem.c~drivers-char-memc-cleanups-fix
+++ a/drivers/char/mem.c
@@ -579,7 +579,7 @@ static ssize_t read_port(struct file *fi
 	if (!access_ok(VERIFY_WRITE, buf, count))
 		return -EFAULT;
 	while (count-- > 0 && i < 65536) {
-		if (__put_user(inb(i),tmp) < 0)
+		if (__put_user(inb(i), tmp) < 0)
 			return -EFAULT;
 		i++;
 		tmp++;
@@ -594,7 +594,7 @@ static ssize_t write_port(struct file *f
 	unsigned long i = *ppos;
 	const char __user * tmp = buf;
 
-	if (!access_ok(VERIFY_READ,buf,count))
+	if (!access_ok(VERIFY_READ, buf, count))
 		return -EFAULT;
 	while (count-- > 0 && i < 65536) {
 		char c;
@@ -603,7 +603,7 @@ static ssize_t write_port(struct file *f
 				break;
 			return -EFAULT;
 		}
-		outb(c,i);
+		outb(c, i);
 		i++;
 		tmp++;
 	}
@@ -630,7 +630,7 @@ static int pipe_to_null(struct pipe_inod
 	return sd->len;
 }
 
-static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out,
+static ssize_t splice_write_null(struct pipe_inode_info *pipe, struct file *out,
 				 loff_t *ppos, size_t len, unsigned int flags)
 {
 	return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null);
@@ -831,7 +831,7 @@ static ssize_t kmsg_write(struct file *f
 }
 
 static const struct file_operations kmsg_fops = {
-	.write =	kmsg_write,
+	.write = kmsg_write,
 };
 
 static const struct memdev {
@@ -907,7 +907,7 @@ static int __init chr_dev_init(void)
 	if (err)
 		return err;
 
-	if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
+	if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
 		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
 
 	mem_class = class_create(THIS_MODULE, "mem");
_




  reply	other threads:[~2010-02-08 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-03  3:18 [PATCH] scripts/checkpatch.pl: Dramatically improve #define parse times Joe Perches
2010-02-08 23:15 ` Andrew Morton [this message]
2010-02-09  1:42   ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100208151550.15796cad.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox