diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2009-11-04 11:48:43 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2009-11-04 11:48:43 +0000 |
commit | 4acca097139e94c753d4137f0eb418042b1d52d5 (patch) | |
tree | 398bf4669219eaac59bca6c12c0ce61adf791bac /xpp/perl_modules/Dahdi/Hardware | |
parent | da8465487b9b828406f8295c8a76e434b83cbd75 (diff) |
dahdi-perl: Avoid '"is_twinstar" on unblessed reference'
Dpn't panic if a device is not found in the list of hardware. This
is not only indication of a bug, but can also happen if a device
appeared after the script was started.
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@7462 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/perl_modules/Dahdi/Hardware')
-rw-r--r-- | xpp/perl_modules/Dahdi/Hardware/USB.pm | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/xpp/perl_modules/Dahdi/Hardware/USB.pm b/xpp/perl_modules/Dahdi/Hardware/USB.pm index 56ac23a..722b87b 100644 --- a/xpp/perl_modules/Dahdi/Hardware/USB.pm +++ b/xpp/perl_modules/Dahdi/Hardware/USB.pm @@ -77,7 +77,6 @@ sub set_transport($$) { my $xbus = shift || die; my $xbus_dir = shift; my $transportdir = "$xbus_dir/transport"; - my $hwdev; if(! -e "$transportdir/ep_00") { warn "A trasnport in '$transportdir' is not USB"; return undef; @@ -101,12 +100,14 @@ sub set_transport($$) { my $usbname = sprintf("%03d/%03d", $busnum, $devnum); #printf STDERR "DEBUG: %03d/%03d\n", $busnum, $devnum; $xbus->{USB_DEVNAME} = $usbname; - $hwdev = Dahdi::Hardware->device_by_hwname("usb:$usbname"); - #print "set_transport: ", $hwdev, "\n"; - $xbus->{TRANSPORT} = $hwdev; - $hwdev->{XBUS} = $xbus; - $hwdev->{LOADED} = 'xpp_usb'; - $xbus->{IS_TWINSTAR} = $hwdev->is_twinstar; + my $hwdev = Dahdi::Hardware->device_by_hwname("usb:$usbname"); + if(defined $hwdev) { + #print "set_transport: ", $hwdev, "\n"; + $xbus->{TRANSPORT} = $hwdev; + $hwdev->{XBUS} = $xbus; + $hwdev->{LOADED} = 'xpp_usb'; + $xbus->{IS_TWINSTAR} = $hwdev->is_twinstar; + } return $hwdev; } |