Skip Menu |

This queue is for tickets about the Net-Subnet CPAN distribution.

Report information
The Basics
Id: 85596
Status: resolved
Priority: 0/
Queue: Net-Subnet

People
Owner: Nobody in particular
Requestors: SAPER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.02
Fixed in: (no value)



Subject: [patch] suppress "redefine" warnings
Hello, On recent versions of Perl, Socket now provides IPv6 functions, and unconditionally loading Socket6 generates warnings: $ perl -wMNet::Subnet -e1 Subroutine Net::Subnet::pack_sockaddr_in6 redefined at /usr/local/share/perl/5.14.2/Exporter.pm line 66. at /usr/local/share/perl/5.14.2/Net/Subnet.pm line 5. Subroutine Net::Subnet::unpack_sockaddr_in6 redefined at /usr/local/share/perl/5.14.2/Exporter.pm line 66. at /usr/local/share/perl/5.14.2/Net/Subnet.pm line 5. Subroutine Net::Subnet::sockaddr_in6 redefined at /usr/local/share/perl/5.14.2/Exporter.pm line 66. at /usr/local/share/perl/5.14.2/Net/Subnet.pm line 5. The attached patch fixes these warnings, and adds a test to check that loading the module does not generate warnings. Regards -- Close the world, txEn eht nepO.
Subject: 0001-suppress-redefine-warnings.patch
From 22b4508b97907c17347f09e72065674e82e64e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Aperghis-Tramoni?= <sebastien.aperghis-tramoni@diabolocom.com> Date: Fri, 24 May 2013 16:59:06 +0200 Subject: [PATCH] suppress "redefine" warnings - load Socket6 only if Socket is an old version - manually import Socket::inet_pton - change t/01use.t so it checks, when Test::NoWarnings is installed, that loading Net::Subnet does not generate warnings --- lib/Net/Subnet.pm | 13 ++++++++++++- t/01use.t | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/Net/Subnet.pm b/lib/Net/Subnet.pm index b8cc863..3173485 100644 --- a/lib/Net/Subnet.pm +++ b/lib/Net/Subnet.pm @@ -2,13 +2,24 @@ package Net::Subnet; use strict; use Socket; -use Socket6; use base 'Exporter'; our @EXPORT = qw(subnet_matcher subnet_classifier sort_subnets); our $VERSION = '1.02'; + +# starting with version 1.94, Socket.pm (which is now dual-life) +# began integrating IPv6 functions that were previously available +# via Socket6 or Socket::GetAddrInfo +if ($Socket::VERSION < 1.94) { + require Socket6; + import Socket6; +} else { + *inet_pton = \&Socket::inet_pton; +} + + sub cidr2mask_v4 { my ($length) = @_; return pack "N", 0xffffffff << (32 - $length); diff --git a/t/01use.t b/t/01use.t index dbc4af8..2245683 100644 --- a/t/01use.t +++ b/t/01use.t @@ -1,2 +1,7 @@ -use Test::More tests => 1; +use strict; +use Test::More; + +use constant HAS_TEST_NOWARNINGS => eval "use Test::NoWarnings; 1" ? 1 : 0; + +plan tests => 1 + HAS_TEST_NOWARNINGS; use_ok('Net::Subnet'); -- 1.7.10.4
The new release (1.03) fixes this issue, although in a slightly different way. I hadn't noticed that there were RT tickets until someone told me AFTER I released 1.03.