]> granicus.if.org Git - strace/commitdiff
strace-graph: use "strict" and "warnings" pragmas
authorKeith Owens <kaos.ocs@gmail.com>
Mon, 18 Jan 2016 01:57:41 +0000 (12:57 +1100)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 5 Feb 2016 00:41:23 +0000 (00:41 +0000)
* strace-graph: Set "use strict" and "use warnings" options.  Fix errors
detected by strict/warnings.  $result is really a string, it can be "-1"
followed by an error text.

strace-graph

index d57e76863e585b3a0fdf61ad6b7e8032e99476a4..169c82c36355248e4afdee1ef8f69fcc024cb814 100755 (executable)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+use strict;
+use warnings;
+
 my %unfinished;
+my $floatform;
 
 # Scales for strace slowdown.  Make configurable!
 my $scale_factor = 3.5;
@@ -41,6 +45,7 @@ my $scale_factor = 3.5;
 while (<>) {
     my ($pid, $call, $args, $result, $time);
     chop;
+    $floatform = 0;
 
     s/^(\d+)\s+//;
     $pid = $1;
@@ -119,13 +124,14 @@ sub parse_one {
     my ($in) = @_;
 
     if ($in =~ s/^\"//) {
+       my $tmp;
        ($tmp, $in) = parse_str($in);
        if (not defined $tmp) {
            print STDERR "$0: $ARGV: $.: cannot parse string.\n";
            return (undef, $in);
        }
        return ($tmp, $in);
-    } elsif ($in =~ s/^0x(\x+)//) {
+    } elsif ($in =~ s/^0x([[:xdigit:]]+)//) {
        return (hex $1, $in);
     } elsif ($in =~ s/^(\d+)//) {
        return (int $1, $in);
@@ -214,10 +220,10 @@ sub handle_trace {
     }
 
     if ($call eq 'execve') {
-       return if $result != 0;
+       return if $result ne '0';
 
        my ($filename, $argv) = parseargs($args);
-       ($basename) = $filename =~ m/([^\/]*)$/;
+       my ($basename) = $filename =~ m/([^\/]*)$/;
        if ($basename ne $$argv[0]) {
            $$argv[0] = "$basename($$argv[0])";
         }
@@ -249,7 +255,7 @@ sub straight_seq {
     my ($pid) = @_;
     my $seq = $pr{$pid}{seq};
 
-    for $elem (@$seq) {
+    for my $elem (@$seq) {
        if ($$elem[0] eq 'EXEC') {
            my $argv = $$elem[2];
            print "$$elem[0] $$elem[1] @$argv\n";
@@ -265,7 +271,7 @@ sub first_exec {
     my ($pid) = @_;
     my $seq = $pr{$pid}{seq};
 
-    for $elem (@$seq) {
+    for my $elem (@$seq) {
        if ($$elem[0] eq 'EXEC') {
            return $elem;
        }
@@ -293,7 +299,7 @@ sub display_pid_trace {
        }
     }
 
-    for $elem (@seq) {
+    for my $elem (@seq) {
        $i++;
        if ($$elem[0] eq 'EXEC') {
            my $argv = $$elem[2];