Attachment 'voidp_vars.pl'
Download 1 #!/usr/bin/perl
2 # This scripts goes through the kernel sources and
3 # prints assignments of (void*) functions that
4 # get type-changed:
5 # type *x = (type*) function().
6 # The first argument is the kernel source directory, additional
7 # arguments override the embedded function name list.
8
9
10 $kernel_dir=shift || die "Need a directory argument (kernel sources),\n" .
11 "and optionally function names.\n" .
12 "If none are given, a default list is taken.\n";
13
14 # Get source files
15 @ARGV=split(/\0/, `find "$kernel_dir" -type f -iname "*.c" -print0`);
16 die "No sources found.\n" unless @ARGV;
17
18 # Read whole files, and look for such assignments.
19 $/=undef;
20 while (<>)
21 {
22 $changes=0;
23 # - struct netdev_private *np = (struct netdev_private *)dev->priv;
24 # + struct netdev_private *np = dev->priv;
25 # or just
26 # lp = (struct i596_private *) dev->priv;
27 $changes++ while
28 s{
29 ( (?: struct \s+ \w+ \s* \* \s*)? \w+ \s+ = ) \s*
30 \( [\w\s\*]+ \* \s* \) \s*
31 ( \w+ \s* -> \s* priv(?:ate)? \s* ; )
32 }{$1 $2}xgo;
33
34 if ($changes)
35 {
36 open(DIFF, qq(| diff -up --label "$ARGV" "$ARGV" --label "$ARGV" -))
37 || die "Cannot start diff program: $!\n";
38 print DIFF $_;
39 close DIFF;
40 }
41 }
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.