Skip to content

Commit

Permalink
$^W / use warnings / no warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Tux committed Aug 13, 2024
1 parent 1fee906 commit e2220be
Show file tree
Hide file tree
Showing 36 changed files with 49 additions and 223 deletions.
7 changes: 4 additions & 3 deletions DBI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ for (qw(trace_msg set_err parse_trace_flag parse_trace_flags)) {
}

use strict;
use warnings;

DBI->trace(split /=/, $ENV{DBI_TRACE}, 2) if $ENV{DBI_TRACE};

Expand Down Expand Up @@ -602,7 +603,7 @@ sub connect {
$dsn ||= $ENV{DBI_DSN} || $ENV{DBI_DBNAME} || '' unless $old_driver;

if ($DBI::dbi_debug) {
local $^W = 0;
no warnings;
pop @_ if $connect_meth ne 'connect';
my @args = @_; $args[2] = '****'; # hide password
DBI->trace_msg(" -> $class->$connect_meth(".join(", ",@args).")\n");
Expand Down Expand Up @@ -1487,7 +1488,7 @@ sub _new_sth { # called by DBD::<drivername>::db::prepare)
my ($dsn, $user, $auth, $attr) = @_;

my $cache = $drh->{CachedKids} ||= {};
my $key = do { local $^W;
my $key = do { no warnings;
join "!\001", $dsn, $user, $auth, DBI::_concat_hash_sorted($attr, "=\001", ",\001", 0, 0)
};
my $dbh = $cache->{$key};
Expand Down Expand Up @@ -1716,7 +1717,7 @@ sub _new_sth { # called by DBD::<drivername>::db::prepare)
# active children. The XS template code does this. Drivers not using
# the template must handle clearing the cache themselves.
my $cache = $dbh->{CachedKids} ||= {};
my $key = do { local $^W;
my $key = do { no warnings;
join "!\001", $statement, DBI::_concat_hash_sorted($attr, "=\001", ",\001", 0, 0)
};
my $sth = $cache->{$key};
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,4 @@ t/91_store_warning.t
t/lib.pl Utility functions for test scripts
t/pod.t
t/pod-coverage.t
test.pl Assorted informal tests, including tests for memory leaks
typemap
3 changes: 2 additions & 1 deletion MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
^blib/
^DBI-\d
^dbi.tiddlyspot.com.html
^doc/
^err/
^err_
^_Inline/
^ppport.h$
^t/zz_\w+_pp.t$
^t/z
^t/pod-cm.t
^t-mock/
^devel/
Expand Down
1 change: 1 addition & 0 deletions lib/Bundle/DBI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package Bundle::DBI;

use strict;
use warnings;
our $VERSION = "12.008696";

1;
Expand Down
1 change: 1 addition & 0 deletions lib/DBD/DBM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#######################################################################
require 5.008;
use strict;
use warnings;

#################
package DBD::DBM;
Expand Down
1 change: 1 addition & 0 deletions lib/DBD/ExampleP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package DBD::ExampleP;

use strict;
use warnings;
use Symbol;

use DBI qw(:sql_types);
Expand Down
3 changes: 2 additions & 1 deletion lib/DBD/Gofer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package DBD::Gofer;

use strict;
use warnings;

require DBI;
require DBI::Gofer::Request;
Expand Down Expand Up @@ -506,7 +507,7 @@
if $DBD::Gofer::xxh_local_store_attrib_if_same_value{$attrib}
&& do { # values are the same
my $crnt = $dbh->FETCH($attrib);
local $^W;
no warnings;
(defined($value) ^ defined($crnt))
? 0 # definedness differs
: $value eq $crnt;
Expand Down
1 change: 1 addition & 0 deletions lib/DBD/Multiplex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# some file-scoped lexicals:

use strict;
use warnings;

my %parent_only_attr = (
# mx needs to manage errors from children
Expand Down
1 change: 1 addition & 0 deletions lib/DBD/Multiplex/Logic/Default.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package DBD::Multiplex::Logic::Default;

use strict;
use warnings;
no strict 'refs';

sub mx_pick_handles {
Expand Down
1 change: 1 addition & 0 deletions lib/DBD/NullP.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use strict;
use warnings;
{
package DBD::NullP;

Expand Down
3 changes: 2 additions & 1 deletion lib/DBD/Proxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#

use strict;
use warnings;
use Carp;

require DBI;
Expand All @@ -34,7 +35,7 @@ use RPC::PlClient 0.2000; # XXX change to 0.2017 once it's released
my $self = shift;
if ($self->{debug}) {
my ($rpcmeth, $obj, $method, @args) = @_;
local $^W; # silence undefs
no warnings; # silence undefs
Carp::carp("Server $rpcmeth $method(@args)");
}
return $self->SUPER::Call(@_);
Expand Down
3 changes: 2 additions & 1 deletion lib/DBD/Sponge.pm
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use strict;
use warnings;
{
package DBD::Sponge;

Expand Down Expand Up @@ -176,7 +177,7 @@ use strict;
my $NUM_OF_PARAMS = $sth->{NUM_OF_PARAMS};
return $sth->set_err($DBI::stderr, @$row." values bound (@$row) but $NUM_OF_PARAMS expected")
if @$row != $NUM_OF_PARAMS;
{ local $^W; $sth->trace_msg("inserting (@$row)\n"); }
{ no warnings; $sth->trace_msg("inserting (@$row)\n"); }
push @{ $sth->{rows} }, $row;
}
else { # mark select sth as Active
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Const/GetInfo/ANSI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
use strict;
use warnings;

package DBI::Const::GetInfo::ANSI;

Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Const/GetInfo/ODBC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
use strict;
use warnings;
package DBI::Const::GetInfo::ODBC;

our (%InfoTypes,%ReturnTypes,%ReturnValues,);
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Const/GetInfoReturn.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package DBI::Const::GetInfoReturn;

use strict;
use warnings;

use Exporter ();

Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Const/GetInfoType.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package DBI::Const::GetInfoType;

use strict;
use warnings;

use Exporter ();

Expand Down
1 change: 1 addition & 0 deletions lib/DBI/DBD.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package DBI::DBD;
# vim:ts=8:sw=4
use strict;
use warnings;
use vars qw($VERSION); # set $VERSION early so we don't confuse PAUSE/CPAN etc

# don't use Revision here because that's not in svn:keywords so that the
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/DBD/Metadata.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package DBI::DBD::Metadata;
# License or the Artistic License, as specified in the Perl README file.

use strict;
use warnings;

use Exporter ();
use Carp;
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/FAQ.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
### made to Alligator Descartes.
###
use strict;
use warnings;

package DBI::FAQ;

Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Gofer/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package DBI::Gofer::Request;
# License or the Artistic License, as specified in the Perl README file.

use strict;
use warnings;

use DBI qw(neat neat_list);

Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Gofer/Response.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package DBI::Gofer::Response;
# License or the Artistic License, as specified in the Perl README file.

use strict;
use warnings;

use Carp;
use DBI qw(neat neat_list);
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Profile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ many forward references. (Patches welcome!)


use strict;
use warnings;
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
use Exporter ();
use UNIVERSAL ();
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/ProfileData.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package DBI::ProfileData;
use strict;
use warnings;

=head1 NAME
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/ProfileDumper.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package DBI::ProfileDumper;
use strict;
use warnings;

=head1 NAME
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/ProfileDumper/Apache.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package DBI::ProfileDumper::Apache;

use strict;
use warnings;

=head1 NAME
Expand Down
5 changes: 3 additions & 2 deletions lib/DBI/ProxyServer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

require 5.004;
use strict;
use warnings;

use RPC::PlServer 0.2001;
require DBI;
Expand Down Expand Up @@ -215,15 +216,15 @@ sub CallMethod {
# $dbh. However, we'd have a reference loop in that case and
# I would be concerned about garbage collection. :-(
$dbh->{'private_server'} = $server;
$server->Debug("CallMethod: => " . do { local $^W; join(",", @_)});
$server->Debug("CallMethod: => " . do { no warnings; join(",", @_)});
my @result = eval { $server->SUPER::CallMethod(@_) };
my $msg = $@;
undef $dbh->{'private_server'};
if ($msg) {
$server->Debug("CallMethod died with: $@");
die $msg;
} else {
$server->Debug("CallMethod: <= " . do { local $^W; join(",", @result) });
$server->Debug("CallMethod: <= " . do { no warnings; join(",", @result) });
}
@result;
}
Expand Down
7 changes: 4 additions & 3 deletions lib/DBI/PurePerl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package # hide from PAUSE
########################################################################

use strict;
use warnings;
use Carp;
require Symbol;

Expand Down Expand Up @@ -305,7 +306,7 @@ sub _install_method {

push @pre_call_frag, q{
if (($DBI::dbi_debug & 0xF) >= 2) {
local $^W;
no warnings;
my $args = join " ", map { DBI::neat($_) } ($h, @_);
printf $DBI::tfh " > $method_name in $imp ($args) [$@]\n";
}
Expand Down Expand Up @@ -496,7 +497,7 @@ sub _setup_handle {
my($h, $imp_class, $parent, $imp_data) = @_;
my $h_inner = tied(%$h) || $h;
if (($DBI::dbi_debug & 0xF) >= 4) {
local $^W;
no warnings;
print $DBI::tfh " _setup_handle(@_)\n";
}
$h_inner->{"imp_data"} = $imp_data;
Expand Down Expand Up @@ -864,7 +865,7 @@ sub FETCH {
Carp::carp( sprintf "Can't determine Type for %s",$h );
}
if (!$is_valid_attribute{$key} and $key =~ m/^[A-Z]/) {
local $^W; # hide undef warnings
no warnings; # hide undef warnings
Carp::carp( sprintf "Can't get %s->{%s}: unrecognised attribute (@{[ %$h ]})",$h,$key )
}
}
Expand Down
1 change: 1 addition & 0 deletions lib/DBI/Util/_accessor.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package DBI::Util::_accessor;
use strict;
use warnings;
use Carp;
our $VERSION = "0.009479";

Expand Down
1 change: 1 addition & 0 deletions lib/DBI/W32ODBC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use Win32::ODBC;
@ISA = qw(Win32::ODBC);

use strict;
use warnings;

$DBI::dbi_debug = $ENV{PERL_DBI_DEBUG} || 0;
carp "Loaded (W32ODBC) DBI.pm ${'DBI::VERSION'} (debug $DBI::dbi_debug)"
Expand Down
1 change: 1 addition & 0 deletions lib/Win32/DBIODBC.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package # hide this package from CPAN indexer
Win32::ODBC;

use strict;
use warnings;

use DBI;

Expand Down
4 changes: 2 additions & 2 deletions t-mock/DBI/Test/DBI/DSN/Provider/DBM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ sub dsn_conf
{
# test with as many of the major DBM types as are available
@dbm_types = grep {
eval { local $^W; require "$_.pm" }
eval { no warnings; require "$_.pm" }
} @dbms;
}
elsif (@use_dbms)
Expand All @@ -51,7 +51,7 @@ sub dsn_conf
# (However, if SDBM_File is not available, then use another.)
for my $dbm (@dbms)
{
if ( eval { local $^W; require "$dbm.pm" } )
if ( eval { no warnings; require "$dbm.pm" } )
{
@dbm_types = ($dbm);
last;
Expand Down
4 changes: 2 additions & 2 deletions t/50dbm_simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BEGIN {

if (lc "@use_dbms" eq "all") {
# test with as many of the major DBM types as are available
@dbm_types = grep { eval { local $^W; require "$_.pm" } } @dbms;
@dbm_types = grep { eval { no warnings; require "$_.pm" } } @dbms;
}
elsif (@use_dbms) {
@dbm_types = @use_dbms;
Expand All @@ -54,7 +54,7 @@ BEGIN {
# It's only DBD::DBM we're trying to test here.
# (However, if SDBM_File is not available, then use another.)
for my $dbm (@dbms) {
if (eval { local $^W; require "$dbm.pm" }) {
if (eval { no warnings; require "$dbm.pm" }) {
@dbm_types = ($dbm);
last;
}
Expand Down
4 changes: 2 additions & 2 deletions t/52dbm_complex.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ BEGIN
{
# test with as many of the major DBM types as are available
@dbm_types = grep {
eval { local $^W; require "$_.pm" }
eval { no warnings; require "$_.pm" }
} @dbms;
}
elsif (@use_dbms)
Expand All @@ -62,7 +62,7 @@ BEGIN
# (However, if SDBM_File is not available, then use another.)
for my $dbm (@dbms)
{
if ( eval { local $^W; require "$dbm.pm" } )
if ( eval { no warnings; require "$dbm.pm" } )
{
@dbm_types = ($dbm);
last;
Expand Down
2 changes: 1 addition & 1 deletion t/85gofer.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ GetOptions(
if (!$opt_dbm) {
# pick first available, starting with SDBM_File
for (qw( SDBM_File GDBM_File DB_File BerkeleyDB )) {
if (eval { local $^W; require "$_.pm" }) {
if (eval { no warnings; require "$_.pm" }) {
$opt_dbm = ($_);
last;
}
Expand Down
Loading

0 comments on commit e2220be

Please sign in to comment.