New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dumpvalue: have module run with warnings #17177
Comments
From @jkeenanWhile working on RT 134441 and trying to extend the test coverage of ##### These are all fixable. Will supply a patch once I have an RT number. Thank you very much. # perl perl perl |
From @jkeenanOn Wed, 09 Oct 2019 19:52:34 GMT, jkeenan@pobox.com wrote:
Patch attached. Also available for smoking in this branch: smoke-me/jkeenan/134490-Dumpvalue-use-warnings Thank you very much. |
From @jkeenan134490-0001-Use-warnings-in-Dumpvalue.pm-fix-those-found.patchFrom 62c19a2cbe3efedc8103bba6521f728ac0c45a44 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Wed, 9 Oct 2019 15:45:41 -0400
Subject: [PATCH] Use warnings in Dumpvalue.pm; fix those found
Activating warnings showed many fixable warnings. The suppression of
some of those warnings was obscuring other problems.
---
dist/Dumpvalue/lib/Dumpvalue.pm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dist/Dumpvalue/lib/Dumpvalue.pm b/dist/Dumpvalue/lib/Dumpvalue.pm
index 3faf829538..ff9efe1ec6 100644
--- a/dist/Dumpvalue/lib/Dumpvalue.pm
+++ b/dist/Dumpvalue/lib/Dumpvalue.pm
@@ -1,7 +1,8 @@
use 5.006_001; # for (defined ref) and $#$v and our
package Dumpvalue;
use strict;
-our $VERSION = '1.19';
+use warnings;
+our $VERSION = '1.20';
our(%address, $stab, @stab, %stab, %subs);
sub ASCII { return ord('A') == 65; }
@@ -101,6 +102,7 @@ sub stringify {
my $tick = $self->{tick};
return 'undef' unless defined $_ or not $self->{printUndef};
+ $_ = '' if not defined $_;
return $_ . "" if ref \$_ eq 'GLOB';
{ no strict 'refs';
$_ = &{'overload::StrVal'}($_)
@@ -176,7 +178,7 @@ sub unwrap {
my $self = shift;
return if $DB::signal and $self->{stopDbSignal};
my ($v) = shift ;
- my ($s) = shift ; # extra no of spaces
+ my ($s) = shift || 0; # extra no of spaces
my $sp;
my (%v,@v,$address,$short,$fileno);
@@ -390,6 +392,7 @@ sub CvGV_name {
sub dumpsub {
my $self = shift;
my ($off,$sub) = @_;
+ $off ||= 0;
my $ini = $sub;
my $s;
$sub = $1 if $sub =~ /^\{\*(.*)\}$/;
@@ -424,7 +427,7 @@ sub dumpvars {
*stab = *main::;
while ($package =~ /(\w+?::)/g) {
- *stab = $ {stab}{$1};
+ *stab = defined ${stab}{$1} ? ${stab}{$1} : '';
}
$self->{TotalStrings} = 0;
$self->{Strings} = 0;
--
2.17.1
|
From [Unknown Contact. See original ticket]On Wed, 09 Oct 2019 19:52:34 GMT, jkeenan@pobox.com wrote:
Patch attached. Also available for smoking in this branch: smoke-me/jkeenan/134490-Dumpvalue-use-warnings Thank you very much. |
From @jkeenanOn Wed, 09 Oct 2019 20:09:52 GMT, jkeenan wrote:
# snip
If anyone has objections to this please speak up quickly, as I would like to resolve this RT before the transition of issues to github commences. Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Wed, 09 Oct 2019 20:09:52 GMT, jkeenan wrote:
One more patch to avoid warnings, this time pertaining to the use of 'each'. -- |
From @jkeenan134490-0002-Dumpvalue-handle-one-more-potential-warning.patchFrom 67eb585123f82c50117f74fd12bf748a659b41e8 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Fri, 11 Oct 2019 20:01:26 -0400
Subject: [PATCH 2/2] Dumpvalue: handle one more potential warning
While working on adding tests to this module, the following warning
sometimes appeared:
Use of each() on hash after insertion without resetting hash
iterator results in undefined behavior
Per perldiag, instead use 'keys' function to iterate over hash.
---
dist/Dumpvalue/lib/Dumpvalue.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dist/Dumpvalue/lib/Dumpvalue.pm b/dist/Dumpvalue/lib/Dumpvalue.pm
index ff9efe1ec6..0bec4cb3e9 100644
--- a/dist/Dumpvalue/lib/Dumpvalue.pm
+++ b/dist/Dumpvalue/lib/Dumpvalue.pm
@@ -422,7 +422,6 @@ sub dumpvars {
my $self = shift;
my ($package,@vars) = @_;
local(%address,$^W);
- my ($key,$val);
$package .= "::" unless $package =~ /::$/;
*stab = *main::;
@@ -432,7 +431,8 @@ sub dumpvars {
$self->{TotalStrings} = 0;
$self->{Strings} = 0;
$self->{CompleteTotal} = 0;
- while (($key,$val) = each(%stab)) {
+ for my $k (keys %stab) {
+ my ($key,$val) = ($k, $stab{$k});
return if $DB::signal and $self->{stopDbSignal};
next if @vars && !grep( matchvar($key, $_), @vars );
if ($self->{usageOnly}) {
--
2.17.1
|
From @jkeenanOn Sat, 12 Oct 2019 02:25:09 GMT, jkeenan wrote:
Branch has been merged to blead; commits 05b8159 and 67eb585. Thank you very much. -- |
@jkeenan - Status changed from 'open' to 'pending release' |
Migrated from rt.perl.org#134490 (status was 'pending release')
Searchable as RT134490$
The text was updated successfully, but these errors were encountered: