depmod.pl: add recursive sanity check

If modules contain circular dependencies, the depmod script will follow
the circle forever.  So add a simple sanity check to abort rather than
chew up the CPU.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
Mike Frysinger 2010-11-16 07:15:00 -05:00
parent 2e9aeae4db
commit 8ce1ad3097

View File

@ -173,6 +173,9 @@ sub add_mod_deps
$depth .= " "; $depth .= " ";
warn "${depth}loading deps of module: $this_module\n" if $verbose; warn "${depth}loading deps of module: $this_module\n" if $verbose;
if (length($depth) > 50) {
die "too much recursion (circular dependencies in modules?)";
}
foreach my $md (keys %{$mod->{$this_module}}) { foreach my $md (keys %{$mod->{$this_module}}) {
add_mod_deps ($depth, $mod, $mod2, $module, $md); add_mod_deps ($depth, $mod, $mod2, $module, $md);