checkpatch: usb_free_urb() can take NULL
authorGreg Kroah-Hartman <gregkh@suse.de>
Mon, 14 Apr 2008 21:17:29 +0000 (14:17 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 25 Apr 2008 04:16:33 +0000 (21:16 -0700)
usb_free_urb() can take a NULL, so let's check and warn about that.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
scripts/checkpatch.pl

index 58a94947d6557e0783ef1043b77cb7e8a57bc30d..64ec4b8a51b502cca0b37638f4443813d65d35ae 100755 (executable)
@@ -1889,6 +1889,13 @@ sub process {
                                WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev);
                        }
                }
+# check for needless usb_free_urb() checks
+               if ($prevline =~ /\bif\s*\(([^\)]*)\)/) {
+                       my $expr = $1;
+                       if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) {
+                               WARN("usb_free_urb(NULL) is safe this check is probabally not required\n" . $hereprev);
+                       }
+               }
 
 # warn about #ifdefs in C files
 #              if ($line =~ /^.#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {