Re: [PATCH 2/2] namespace.pl : update file exclusion list

From: Ãvar ArnfjÃrà Bjarmason
Date: Sat Oct 02 2010 - 23:29:52 EST


On Tue, Sep 28, 2010 at 08:44, Stephen Hemminger <shemminger@xxxxxxxxxx> wrote:
> The list of exceptions in kernel tree was out of date. Convert
> the long list of if clauses to a hashes which is more efficient
> and more common in perl.
>
> Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxx>
>
> --- a/scripts/namespace.pl   Â2010-09-28 09:28:52.251563058 +0900
> +++ b/scripts/namespace.pl   Â2010-09-28 15:13:38.092073114 +0900
> @@ -84,6 +84,58 @@ my %ksymtab = (); Â Â# names that appear in
> Âmy %ref = (); Â Â Â Â Â# $ref{$name} exists if there is a true external reference to $name
> Âmy %export = (); Â Â Â # $export{$name} exists if there is an EXPORT_... of $name
>
> +my %nmexception = (
> + Â Â'fs/ext3/bitmap' Â Â Â Â Â Â Â Â Â => 1,
> + Â Â'fs/ext4/bitmap' Â Â Â Â Â Â Â Â Â => 1,
> + Â Â'arch/x86/lib/thunk_32' Â Â Â Â Â Â=> 1,
> + Â Â'arch/x86/lib/cmpxchg' Â Â Â Â Â Â => 1,
> + Â Â'arch/x86/vdso/vdso32/note' Â Â Â Â Â Â Â Â=> 1,
> + Â Â'lib/irq_regs' Â Â Â Â Â Â Â Â Â Â => 1,
> + Â Â'usr/initramfs_data' Â Â Â Â Â Â Â => 1,
> + Â Â'drivers/scsi/aic94xx/aic94xx_dump' Â Â Â Â=> 1,
> + Â Â'drivers/scsi/libsas/sas_dump' Â Â => 1,
> + Â Â'lib/dec_and_lock' Â Â Â Â Â Â Â Â => 1,
> + Â Â'drivers/ide/ide-probe-mini' Â Â Â => 1,
> + Â Â'usr/initramfs_data' Â Â Â Â Â Â Â => 1,
> + Â Â'drivers/acpi/acpia/exdump' Â Â Â Â Â Â Â Â=> 1,
> + Â Â'drivers/acpi/acpia/rsdump' Â Â Â Â Â Â Â Â=> 1,
> + Â Â'drivers/acpi/acpia/nsdumpdv' Â Â Â=> 1,
> + Â Â'drivers/acpi/acpia/nsdump' Â Â Â Â Â Â Â Â=> 1,
> + Â Â'arch/ia64/sn/kernel/sn2/io' Â Â Â => 1,
> + Â Â'arch/ia64/kernel/gate-data' Â Â Â => 1,
> + Â Â'security/capability' Â Â Â Â Â Â Â=> 1,
> + Â Â'fs/ntfs/sysctl' Â Â Â Â Â Â Â Â Â => 1,
> + Â Â'fs/jfs/jfs_debug' Â Â Â Â Â Â Â Â => 1,
> +);
> +
> +my %nameexception = (
> + Â Â'mod_use_count_' Â Â=> 1,
> + Â Â'__initramfs_end' Â=> 1,
> + Â Â'__initramfs_start' Â Â Â Â=> 1,
> + Â Â'_einittext' Â Â Â => 1,
> + Â Â'_sinittext' Â Â Â => 1,
> + Â Â'kallsyms_names' Â => 1,
> + Â Â'kallsyms_num_syms' Â Â Â Â=> 1,
> + Â Â'kallsyms_addresses'=> 1,
> + Â Â'__this_module' Â Â=> 1,
> + Â Â'_etext' Â Â Â Â Â => 1,
> + Â Â'_edata' Â Â Â Â Â => 1,
> + Â Â'_end' Â Â Â Â Â Â => 1,
> + Â Â'__bss_start' Â Â Â=> 1,
> + Â Â'_text' Â Â Â Â Â Â=> 1,
> + Â Â'_stext' Â Â Â Â Â => 1,
> + Â Â'__gp' Â Â Â Â Â Â => 1,
> + Â Â'ia64_unw_start' Â => 1,
> + Â Â'ia64_unw_end' Â Â => 1,
> + Â Â'__init_begin' Â Â => 1,
> + Â Â'__init_end' Â Â Â => 1,
> + Â Â'__bss_stop' Â Â Â => 1,
> + Â Â'__nosave_begin' Â => 1,
> + Â Â'__nosave_end' Â Â => 1,
> + Â Â'pg0' Â Â Â Â Â Â Â=> 1,
> +);
> +
> +
> Â&find(\&linux_objects, '.'); Â # find the objects and do_nm on them
> Â&list_multiply_defined();
> Â&resolve_external_references();
> @@ -272,27 +324,9 @@ sub do_nm
> Â Â Â Âclose($nmdata);
>
> Â Â Â Âif ($#nmdata < 0) {
> - Â Â Â Â Â Â Â if (
> - Â Â Â Â Â Â Â Â Â Â Â $fullname ne "lib/brlock.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "lib/dec_and_lock.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "fs/xfs/xfs_macros.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "drivers/ide/ide-probe-mini.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "usr/initramfs_data.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "drivers/acpi/executer/exdump.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "drivers/acpi/resources/rsdump.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "drivers/acpi/namespace/nsdumpdv.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "drivers/acpi/namespace/nsdump.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "arch/ia64/sn/kernel/sn2/io.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "arch/ia64/kernel/gate-data.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "drivers/ieee1394/oui.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "security/capability.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "sound/core/wrappers.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "fs/ntfs/sysctl.o"
> - Â Â Â Â Â Â Â Â Â Â Â && $fullname ne "fs/jfs/jfs_debug.o"
> - Â Â Â Â Â Â Â ) {
> - Â Â Â Â Â Â Â Â Â Â Â printf "No nm data for $fullname\n";
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â return;
> + Â Â Â Â Â printf "No nm data for $fullname\n"
> + Â Â Â Â Â Â Â unless $nmexception{$fullname};
> + Â Â Â Â Â return;


This would be more readable and easier to update:

my @nmexception = qw(
 Âfs/ext3/bitmap
 Âfs/ext4/bitmap
 Âarch/x86/lib/thunk_32
 Âarch/x86/lib/cmpxchg
 Âarch/x86/vdso/vdso32/note
 Âlib/irq_regs
 Âusr/initramfs_data
 Âdrivers/scsi/aic94xx/aic94xx_dump
 Âdrivers/scsi/libsas/sas_dump
 Âlib/dec_and_lock
 Âdrivers/ide/ide-probe-mini
 Âusr/initramfs_data
 Âdrivers/acpi/acpia/exdump
 Âdrivers/acpi/acpia/rsdump
 Âdrivers/acpi/acpia/nsdumpdv
 Âdrivers/acpi/acpia/nsdump
 Âarch/ia64/sn/kernel/sn2/io
 Âarch/ia64/kernel/gate-data
 Âsecurity/capability
 Âfs/ntfs/sysctl
 Âfs/jfs/jfs_debug
);

my @nameexception = qw(
 Âmod_use_count_
 Â__initramfs_end
 Â__initramfs_start
 Â_einittext
 Â_sinittext
 Âkallsyms_names
 Âkallsyms_num_syms
 Âkallsyms_addresses
 Â__this_module
 Â_etext
 Â_edata
 Â_end
 Â__bss_start
 Â_text
 Â_stext
 Â__gp
 Âia64_unw_start
 Âia64_unw_end
 Â__init_begin
 Â__init_end
 Â__bss_stop
 Â__nosave_begin
 Â__nosave_end
 Âpg0
);

my (%nmexception, %nameexception);
@nmexception{@nmexception} = ();
@nameexception{@nameexception} = ();

Then later:

print "No nm data for $fullname\n"
  unless exists $nmexception{$fullname};

I.e. use print (not printf) and exists().
N‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i