lkml.org 
[lkml]   [2000]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] make checkstruct (was Re: [PATCH] file_operations policing and CodingStyle addition)
[ Monday, February 28, 2000 ] Jeff Garzik wrote:
> gccify.pl looks useful, but I generally trust my cooledit macros more
> than a Perl script which it comes to automatically updating code -- at
> least with cooledit the process is somewhat interactive, with erroneous
> results or special cases immediately visible and obvious.

I wouldn't personally trust *anything* with automatically updating code
(aside from whitespace, but even that is iffy :).

Rest assured that I vim (with syntax highlighting) every patch and scan
it before submitting it. One of the structs had a comment of the form
"/* foo *//* bar */" which my code did wrong the first time around since
it checked for C++ comments first, leaving "/* foo *". :)

I'm personally going to be feeding each patch per-struct (like
file_operations was done) to make things sane all-around. I'll be making
attempt #3 at feeding inode_operations fixes soon :)

> Would you consider creating a makefile target which simply lists files
> in the source tree which need updating? "make checkstruct" or
> something?

attached :) I'm sure the semantics need work but it's a first pass (if
admittedly useless since the fops was about all that's been converted :)

jmm@ns1:/usr/src/linux-check> make checkstruct|wc -l
946

If you do end up doing the initialization edits with cooledit (or
whatever), please take the time to give the perl script a shot at
it (modifying element_map as necessary) in case it helps catch
cases that could be fed back to make the perl a little better :)

James
diff -ruN linux/Makefile linux-check/Makefile
--- linux/Makefile Mon Feb 28 20:14:51 2000
+++ linux-check/Makefile Mon Feb 28 20:07:08 2000
@@ -503,6 +503,9 @@
checkhelp:
perl -w scripts/checkhelp.pl `find * -name [cC]onfig.in -print`

+checkstruct:
+ find * -name '*.[hc]' -type f -print | xargs perl -w scripts/checkstruct.pl
+
ifdef CONFIGURATION
..$(CONFIGURATION):
@echo
diff -ruN linux/scripts/checkstruct.pl linux-check/scripts/checkstruct.pl
--- linux/scripts/checkstruct.pl Wed Dec 31 19:00:00 1969
+++ linux-check/scripts/checkstruct.pl Mon Feb 28 20:07:23 2000
@@ -0,0 +1,33 @@
+#!/usr/bin/perl -w
+
+# Copyright 2000 James Manning, <jmm@computer.org>
+# Licensed under the GNU General Public License, version 2.
+
+use strict;
+undef $/; # entire files at a time
+my $file;
+
+foreach $file (@ARGV) {
+ open(IN,"$file") or die "$file"; my $contents=<IN>; close(IN);
+ print "$file has non-gcc syntax struct initialization\n"
+ if &has_nongcc_struct(\$contents);
+}
+
+sub has_nongcc_struct {
+ my $ref_content = shift(@_);
+ my $struct_num=0;
+ my @struct_contents=($$ref_content =~ m|
+ struct\s+\S+\s+ # preamble for this struct
+ \S+ # struct name
+ \s*=\s*{(.*?)(?=}) # postamble
+ |gsx);
+ for my $content (@struct_contents) {
+ $content =~ s#/\*.*?\*/##gs; # kill c style comments
+ $content =~ s#//.*##g; # kill c++ style comments
+ # if non-empty and no : present, non-gcc syntax
+ if($content =~ /\w/ and $content !~ m/:/) {
+ return 1;
+ }
+ }
+ return 0;
+}
\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.111 / U:1.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site