KernelNewbies
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Kernel Hacking

  • Frontpage

  • Kernel Hacking

  • Kernel Documentation

  • Kernel Glossary

  • FAQ

  • Found a bug?

  • Kernel Changelog

  • Upstream Merge Guide

Projects

  • KernelJanitors

  • KernelMentors

  • KernelProjects

Community

  • Why a community?

  • Regional Kernelnewbies

  • Personal Pages

  • Upcoming Events

References

  • Mailing Lists

  • Related Sites

  • Programming Links

Wiki

  • Recent Changes

  • Site Editors

  • Side Bar

  • Tips for Editors

  • Hosted by WikiWall

Navigation

  • RecentChanges
  • FindPage
  • HelpContents
KernelNewbies:
  • attachment:voidp_vars.pl of KernelJanitors/Todo/VoidPointerConvs

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.
  • [get | view] (2017-12-30 01:18:39, 0.6 KB) [[attachment:find_voidp_funcs.pl]]
  • [get | view] (2017-12-30 01:18:39, 17.0 KB) [[attachment:type-convs.pl]]
  • [get | view] (2017-12-30 01:18:38, 1.1 KB) [[attachment:voidp_vars.pl]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01