]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
scripts: enable strict warnings in Perl where missing, fix fallouts
authorViktor Szakats <commit@vsz.me>
Wed, 9 Jul 2025 19:18:29 +0000 (21:18 +0200)
committerViktor Szakats <commit@vsz.me>
Sun, 27 Jul 2025 20:35:18 +0000 (22:35 +0200)
- add 'use warnings' and 'use strict' where missing from Perl scripts.
- fix 'Use of uninitialized value'.
- fix missing declarations.
- test1140.pl: fix 'Possible precedence issue with control flow operator'.
- fix other misc issues.

Most actual errors found during this PR were fixed and merged via
separate PRs.

Likely there are remaining warnings not found and fixed in this PR.

Closes #17877

45 files changed:
.github/scripts/badwords.pl
.github/scripts/cleancmd.pl
.github/scripts/cmp-config.pl
.github/scripts/randcurl.pl
.github/scripts/trimmarkdownheader.pl
.github/scripts/verify-examples.pl
.github/scripts/verify-synopsis.pl
docs/examples/adddocsref.pl
docs/examples/version-check.pl
docs/libcurl/mksymbolsmanpage.pl
docs/libcurl/symbols.pl
lib/optiontable.pl
scripts/cd2cd
scripts/cdall
scripts/ciconfig.pl
scripts/cijobs.pl
scripts/delta
scripts/extract-unit-protos
scripts/managen
scripts/mdlinkcheck
scripts/nroff2cd
scripts/randdisable
scripts/release-notes.pl
scripts/singleuse.pl
src/mk-file-embed.pl
src/mkhelp.pl
tests/allversions.pm
tests/http2-server.pl
tests/http3-server.pl
tests/libtest/mk-lib1521.pl
tests/libtest/test1013.pl
tests/libtest/test1022.pl
tests/libtest/test307.pl
tests/libtest/test610.pl
tests/libtest/test613.pl
tests/memanalyze.pl
tests/runtests.pl
tests/test1140.pl
tests/test1175.pl
tests/test1275.pl
tests/test1276.pl
tests/test1488.pl
tests/test1707.pl
tests/test971.pl
tests/testcurl.pl

index fe30120a6f983d57148b1b8a04087b3854142f35..e51d99f0d1ab28b8962c7fe4f0a95001ec622ffc 100755 (executable)
 #
 # ---(accepted word)
 #
-my $w;
+
+use strict;
+use warnings;
+
+my @whitelist;
+my %alt;
+my %exactcase;
+
+my @w;
 while(<STDIN>) {
     chomp;
     if($_ =~ /^#/) {
index 283a9f4e934f4f8613ef718b9309db1113fe5d22..7b79c2e65aee323d0f6ecb56f27562f9dafdb5b0 100755 (executable)
 # might have a problem with that we still deem is fine.
 #
 
+use strict;
+use warnings;
+
+my @asyms;
+
 open(S, "<./docs/libcurl/symbols-in-versions")
     || die "can't find symbols-in-versions";
 while(<S>) {
index cb47870fe3945b5c2143c028115a47b9a0ce5c25..88df37b795bb072f3887a45bf985a0604c760c30 100755 (executable)
@@ -23,6 +23,9 @@
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my $autotools = $ARGV[0];
 my $cmake = $ARGV[1];
 
index 84804d69602fd5f8387f3c749d012f081c9bcee4..c07ba9b7de59bde9ff44d66f5c1902f1dfb8fe10 100755 (executable)
@@ -18,6 +18,9 @@
 # directory where it runs.
 #
 
+use strict;
+use warnings;
+
 my $curl = "../src/curl";
 my $url = "localhost:7777"; # not listening to this
 
@@ -31,6 +34,14 @@ if(!$seconds) {
 }
 print "Run $curl for $seconds seconds\n";
 
+my @opt;
+my %arg;
+my %uniq;
+my %allrc;
+
+my $totalargs = 0;
+my $totalcmds = 0;
+
 my $counter = 0xabcdef + time();
 sub getnum {
     my ($max) = @_;
@@ -164,6 +175,7 @@ sub runconfig {
         my $o = getnum($nopts);
         my $option = $opt[$o];
         my $ar = "";
+        $uniq{$option} = 0 if(!exists $uniq{$option});
         $uniq{$option}++;
         if($arg{$option}) {
             $ar = " ".randarg();
index 9c623730b9c8a3b2df304e610a614d204615128c..89b2e7d9fd0520bb2810dd88b68c33ff96bc57b7 100755 (executable)
@@ -7,7 +7,10 @@
 # Outputs: the same file, minus the header
 #
 
-my $f = $ARGV[0];
+use strict;
+use warnings;
+
+my $f = $ARGV[0] || '';
 
 open(F, "<$f") or die;
 
index 5853f46b5692295e6e0a06ae36317824230c6e34..27c4de6db85529452de4ab8614198ac5330e474b 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my @files = @ARGV;
 my $cfile = "test.c";
 my $check = "./scripts/checksrc.pl";
-my $error;
+my $error = 0;
 
-if($files[0] eq "-h") {
+if(!@files || $files[0] eq "-h") {
     print "Usage: verify-examples [markdown pages]\n";
     exit;
 }
@@ -82,7 +85,7 @@ sub extract {
     return ($fail ? 0 : $l);
 }
 
-my $count;
+my $count = 0;
 for my $m (@files) {
     #print "Verify $m\n";
     my $out = extract($m);
index aa269179461ddd4c707e9be2a1f8c157aa7d432f..1c6b00b60bd10e96dba4fbee0d1bb9d328e5c64f 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my @files = @ARGV;
 my $cfile = "test.c";
 
-if($files[0] eq "-h") {
+if(!@files || $files[0] eq "-h") {
     print "Usage: verify-synopsis [man pages]\n";
     exit;
 }
index e2e2553dc5919420312e5a8b61b96bc4e5403b3d..aba9abe2a0b77156286d4f959f7abaa26fe81c66 100755 (executable)
 
 # pass files as argument(s)
 
+use strict;
+use warnings;
+
 my $docroot="https://curl.se/libcurl/c";
 
-for $f (@ARGV) {
+for my $f (@ARGV) {
     open(NEW, ">$f.new");
     open(F, "<$f");
     while(<F>) {
index 932d154bdbc29f0c094992ffad4c63a2b3b91e9d..bc065770bc6eddd56d01867382ce4dd5b102b359 100755 (executable)
@@ -38,6 +38,9 @@
 #    version-check.pl [source file]
 #
 
+use strict;
+use warnings;
+
 open(S, "<../libcurl/symbols-in-versions") || die;
 
 my %doc;
@@ -64,7 +67,7 @@ sub age {
     my ($ver)=@_;
 
     my @s=split(/\./, $ver);
-    return $s[0]*10000+$s[1]*100+$s[2];
+    return $s[0]*10000+$s[1]*100+($s[2] || 0);
 }
 
 my %used;
index a79688953c448ab190c30ce74504b8a9a5506607..c70e9949575806ba3c4b809026c4d0a104a85bdf 100755 (executable)
@@ -22,6 +22,8 @@
 # * SPDX-License-Identifier: curl
 # *
 # ***************************************************************************
+use strict;
+use warnings;
 
 use POSIX qw(strftime);
 my @ts;
index 1105ae66b6b79f2ac0687fd6f0e3244f78356f67..1751a4887de9e9dddfc4e00d938967ed01cbb7f2 100755 (executable)
 # #endif
 #
 #
+use strict;
+use warnings;
+
 open F, "<symbols-in-versions";
 
 sub str2num {
     my ($str)=@_;
-    if($str =~ /([0-9]*)\.([0-9]*)\.*([0-9]*)/) {
-        return sprintf("0x%06x", $1<<16 | $2 << 8 | $3);
+    if($str && $str =~ /([0-9]*)\.([0-9]*)\.*([0-9]*)/) {
+        return sprintf("0x%06x", $1 <<16 | $2 << 8 | ($3 || '0'));
     }
 }
 
index cc38a922cc96194012b1cb87dda35096880ac941..43fbd39d3bfccc87d670c8e73a9fcacdc3a27c3e 100755 (executable)
@@ -1,5 +1,8 @@
 #!/usr/bin/env perl
 
+use strict;
+use warnings;
+
 print <<HEAD
 /***************************************************************************
  *                                  _   _ ____  _
@@ -37,31 +40,36 @@ HEAD
 
 my $lastnum=0;
 
+my %opt;
+my %type;
+my @names;
+my %alias;
+
 sub add {
-    my($opt, $type, $num)=@_;
+    my($optstr, $typestr, $num)=@_;
     my $name;
     # remove all spaces from the type
-    $type =~ s/ //g;
-    my $ext = $type;
+    $typestr =~ s/ //g;
+    my $ext = $typestr;
 
-    if($opt =~ /OBSOLETE/) {
+    if($optstr =~ /OBSOLETE/) {
         # skip obsolete options
         next;
     }
 
-    if($opt =~ /^CURLOPT_(.*)/) {
+    if($optstr =~ /^CURLOPT_(.*)/) {
         $name=$1;
     }
     $ext =~ s/CURLOPTTYPE_//;
     $ext =~ s/CBPOINT/CBPTR/;
     $ext =~ s/POINT\z//;
-    $type = "CURLOT_$ext";
+    $typestr = "CURLOT_$ext";
 
-    $opt{$name} = $opt;
-    $type{$name} = $type;
+    $opt{$name} = $optstr;
+    $type{$name} = $typestr;
     push @names, $name;
     if($num < $lastnum) {
-        print STDERR "ERROR: $opt has bad number: $num < $lastnum\n";
+        print STDERR "ERROR: $optstr has bad number: $num < $lastnum\n";
         exit 2;
     }
     else {
@@ -123,8 +131,8 @@ for my $name (sort @names) {
         $name = $alias{$name};
         $flag = "CURLOT_FLAG_ALIAS";
     }
-    $o = sprintf("  {\"%s\", %s, %s, %s},\n",
-                 $oname, $opt{$name}, $type{$name}, $flag);
+    my $o = sprintf("  {\"%s\", %s, %s, %s},\n",
+                    $oname, $opt{$name}, $type{$name}, $flag);
     if(length($o) < 80) {
         print $o;
     }
index 3eaa0219e72fcb8845acd1db2b3ee072768eb019..f4748f5d9bfeed671debed4ff52140dbad25f8a6 100755 (executable)
@@ -36,13 +36,16 @@ Example: cd2cd [--in-place] <file.md> > <file.md>
 =end comment
 =cut
 
+use strict;
+use warnings;
+
 my $cd2cd = "0.1"; # to keep check
 my $dir;
 my $extension;
 my $inplace = 0;
 
 while(1) {
-    if($ARGV[0] eq "--in-place") {
+    if(@ARGV && $ARGV[0] eq "--in-place") {
         shift @ARGV;
         $inplace = 1;
     }
@@ -84,6 +87,9 @@ sub single {
     my $start = 0;
     my $d;
     my $line = 0;
+    my $salist = 0;
+    my $copyright;
+    my $spdx;
     open(F, "<:crlf", "$f") ||
         return 1;
     while(<F>) {
@@ -221,6 +227,6 @@ if($inplace) {
         single($a);
     }
 }
-else {
+elsif(@ARGV) {
     exit single($ARGV[0]);
 }
index 507ccc6be2515dd079f4bfd611d04d0c9ee071ca..aab41b65059c6b7e14511c85c6111f27072b8d50 100755 (executable)
@@ -25,6 +25,9 @@
 
 # provide all dir names to scan on the cmdline
 
+use strict;
+use warnings;
+
 sub convert {
     my ($dir)=@_;
     opendir(my $dh, $dir) || die "could not open $dir";
index 93358def21dde7fd90df1ae3503e802ea3b83f5d..1d8f23556434730616c59f2148941f051b4f1746 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
+my %with;
+my %without;
+my %used;
+my %avail;
+
 # these options are enabled by default in the sense that they will attempt to
 # check for and use this feature without the configure flag
 my %defaulton = (
index 56916bcd820094ea255642f71f6b060446ae67b1..2be9d2565c9ef8880993ea1432e103d39d65e5a4 100755 (executable)
@@ -23,6 +23,9 @@
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my %filelevel= ('file' => 1,
                 'service' => 1);
 
@@ -39,6 +42,8 @@ sub submit {
     }
 }
 
+my %job;
+
 sub githubactions {
     my ($tag)=@_;
     my @files= `git ls-tree -r --name-only $tag .github/workflows 2>/dev/null`;
@@ -341,6 +346,8 @@ sub circle {
     my $cmds;
     my $jobs;
     my $workflow;
+    my $cmdname;
+    my $jobname;
     $job{'file'} = ".circleci/config.yml";
     $job{'service'} = "circleci";
     while(<G>) {
@@ -408,6 +415,10 @@ sub zuul {
     my %job;
     my $line=0;
     my $type;
+    my $jobmode;
+    my $apt = 0;
+    my $env = 0;
+    my $envcont;
     $job{'file'} = "zuul.d/jobs.yaml";
     $job{'service'} = "zuul";
     while(<G>) {
index f9500777747732928968b5d5fbaed763f64f366b..3aab7e57955159166a9e2e1cec142819b518cc55 100755 (executable)
@@ -30,6 +30,9 @@
 #
 # In the git clone root, invoke 'scripts/delta [release tag]'
 
+use strict;
+use warnings;
+
 $start = $ARGV[0];
 
 if($start eq "-h") {
index 48fa1e87915e21f35cebe8d89be9e244ef554161..80c2831eded65d3a3af11dee808be251d7fe9c59 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
+my @proto;
+my %inc;
+
 sub scanfile {
     my ($file) = @_;
     open(F, "<$file") || die "$file failed";
index bf5bca5b1a47c153889377ea0b4f1ac8eea115a4..e4fccdc065d3a0f0e9dfcadfa50309f823d614e3 100755 (executable)
@@ -39,6 +39,9 @@ Unfortunately it seems some perls like msysgit cannot handle a global input-only
 =end comment
 =cut
 
+use strict;
+use warnings;
+
 my %optshort;
 my %optlong;
 my %helplong;
@@ -65,7 +68,7 @@ my $indent = 4;
 sub manpageify {
     my ($k)=@_;
     my $l;
-    my $trail;
+    my $trail = '';
     # the matching pattern might include a trailing dot that cannot be part of
     # the option name
     if($k =~ s/\.$//) {
@@ -127,8 +130,10 @@ sub justline {
 
 sub lastline {
     my ($lvl, @line) = @_;
+    my $l = 0;
     $line[0] =~ s/^( +)//;
-    prefixline($lvl * $indent + length($1));
+    $l = length($1) if($1);
+    prefixline($lvl * $indent + $l);
     my $prev = 0;
     for(@line) {
         printf "%s%s", $prev?" ":"", $_;
@@ -174,9 +179,11 @@ sub printdesc {
     }
     else {
         my $p = -1;
-        my $para;
+        my $pnum;
+        my $para = '';
         for my $l (@desc) {
-            my $lvl;
+            my $lvl = 0;
+            my $lvlnum;
             if($l !~ /^[\n\r]+/) {
                 # get the indent level off the string
                 $l =~ s/^\[([0-9q]*)\]//;
@@ -186,15 +193,19 @@ sub printdesc {
                 # the previous was quoted, this is not
                 print "\n";
             }
-            if($lvl != $p) {
-                outputpara($baselvl + $p, $para);
+            if($lvl ne $p) {
+                $pnum = $p;
+                $pnum =~ s/q$//;
+                outputpara($baselvl + $pnum, $para);
                 $para = "";
             }
             if($lvl =~ /q/) {
                 # quoted, do not right-justify
                 chomp $l;
-                lastline($baselvl + $lvl + 1, $l);
-                my $w = ($baselvl + $lvl + 1) * $indent + length($l);
+                $lvlnum = $lvl;
+                $lvlnum =~ s/q$//;
+                lastline($baselvl + $lvlnum + 1, $l);
+                my $w = ($baselvl + $lvlnum + 1) * $indent + length($l);
                 if($w > $colwidth) {
                     print STDERR "ERROR: $w columns is too long\n";
                     print STDERR "$l\n";
@@ -207,7 +218,9 @@ sub printdesc {
 
             $p = $lvl;
         }
-        outputpara($baselvl + $p, $para);
+        $pnum = $p;
+        $pnum =~ s/q$//;
+        outputpara($baselvl + $pnum, $para);
     }
 }
 
@@ -281,10 +294,11 @@ sub render {
     my $header = 0;
     # if $top is TRUE, it means a top-level page and not a command line option
     my $top = ($line == 1);
-    my $quote;
-    my $level;
+    my $quote = 0;
+    my $level = 0;
     my $finalblank;
-    $start = 0;
+    my $blankline = 0;
+    my $start = 0;
 
     while(<$fh>) {
         my $d = $_;
@@ -575,7 +589,7 @@ sub single {
             $protocols=$1;
         }
         elsif(/^See-also: +(.+)/i) {
-            if($seealso) {
+            if(@seealso) {
                 print STDERR "ERROR: duplicated See-also in $f\n";
                 return 1;
             }
@@ -666,10 +680,6 @@ sub single {
 
     my @desc = render($manpage, $fh, $f, $line);
     close($fh);
-    if($tablemode) {
-        # end of table
-        push @desc, ".RE\n.IP\n";
-    }
     my $opt;
 
     if(defined($short) && $long) {
@@ -802,7 +812,7 @@ sub single {
         my @m=split(/ /, $mutexed);
         my $mstr;
         my $num = scalar(@m);
-        my $count;
+        my $count = 0;
         for my $k (@m) {
             if(!$helplong{$k}) {
                 print STDERR "WARN: $f mutexes a non-existing option: $k\n";
@@ -876,13 +886,13 @@ sub single {
     push @foot, seealso($standalone, $mstr);
 
     print "\n";
-    my $f = join("", @foot);
+    my $ft = join("", @foot);
     if($manpage) {
-        $f =~ s/ +\z//; # remove trailing space
-        print "$f\n";
+        $ft =~ s/ +\z//; # remove trailing space
+        print "$ft\n";
     }
     else {
-        printdesc($manpage, 2, "[1]$f");
+        printdesc($manpage, 2, "[1]$ft");
     }
     return 0;
 }
@@ -950,8 +960,8 @@ sub getshortlong {
 
 sub indexoptions {
     my ($dir, @files) = @_;
-    foreach my $f (@files) {
-        getshortlong($dir, $f);
+    foreach my $file (@files) {
+        getshortlong($dir, $file);
     }
 }
 
@@ -1122,7 +1132,6 @@ sub listglobals {
         }
         close(F);
     }
-    return $ret if($ret);
     for my $e (0 .. $#globalopts) {
         $globals .= sprintf "%s--%s",  $e?($globalopts[$e+1] ? ", " : " and "):"",
             $globalopts[$e],;
@@ -1257,7 +1266,7 @@ sub getargs {
 
 my $dir = ".";
 my $include = "../../include";
-my $cmd = shift @ARGV;
+my $cmd = shift @ARGV || '';
 
  check:
 if($cmd eq "-d") {
index 33fcac9de6e9871670160d7f29ecd548712c41ad..f5b123a24a951bd11532772970098ee36e3f8a2d 100755 (executable)
@@ -23,6 +23,9 @@
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my %whitelist = (
     'https://curl.se/' => 1,
     'https://curl.se/changes.html' => 1,
@@ -70,6 +73,9 @@ my %whitelist = (
 
     );
 
+my %url;
+my %flink;
+
 # list all .md files in the repo
 my @files=`git ls-files '**.md'`;
 
@@ -127,6 +133,7 @@ sub checkurl {
 
     print "check $url\n";
     my $curlcmd="curl -ILfsm10 --retry 2 --retry-delay 5 -A \"Mozilla/curl.se link-probe\"";
+    $url =~ s/\+/%2B/g;
     my @content = `$curlcmd \"$url\"`;
     if(!$content[0]) {
         print STDERR "FAIL\n";
@@ -146,7 +153,7 @@ for my $u (sort keys %url) {
     my $r = checkurl($u);
 
     if($r) {
-        for my $f (split(/ /, $url{$l})) {
+        for my $f (split(/ /, $url{$u})) {
             printf "%s ERROR links to missing URL %s\n", $f, $u;
             $error++;
         }
index 17361b227bf5a26cfb6bc57e208fd85f4fc5d3c0..b0308b6ef071200b1420dae3b3700245d76cadb2 100755 (executable)
@@ -36,6 +36,9 @@ for code.
 =end comment
 =cut
 
+use strict;
+use warnings;
+
 my $nroff2cd = "0.1"; # to keep check
 
 sub single {
@@ -189,4 +192,6 @@ HEAD
     return !$header;
 }
 
-exit single($ARGV[0]);
+if(@ARGV) {
+  exit single($ARGV[0]);
+}
index f8a7a147ed1408fe747a04bf0c011f3d06379d1d..1ccaf6f10d0e7f2626bacf894b94a9cdd5c68414 100755 (executable)
 # - edit the @tls array to include all TLS backends you can build with
 # - do a checkout in a ram-based filesystem
 #
+use strict;
+use warnings;
+
 use List::Util qw/shuffle/;
 
+my @disable;
+
 sub getoptions {
     my @all = `./configure --help`;
     for my $o (@all) {
index 741235a3e66e50d18547507560c7217927bf237b..331941bc9baf01e9597f7cb1ef3c4175bbb30603 100755 (executable)
 #
 ################################################
 
-my $cleanup = ($ARGV[0] eq "cleanup");
+use strict;
+use warnings;
+
+my $cleanup = (@ARGV && $ARGV[0] eq "cleanup");
 my @gitlog=`git log @^{/RELEASE-NOTES:.synced}..` if(!$cleanup);
 my @releasenotes=`cat RELEASE-NOTES`;
 
@@ -120,6 +123,12 @@ sub extract {
     # false alarm, not a valid line
 }
 
+my @fixes;
+my @closes;
+my @bug;
+my @line;
+my %moreinfo;
+
 my $short;
 my $first;
 for my $l (@gitlog) {
@@ -167,7 +176,7 @@ if($first) {
 # call at the end of a parsed commit
 sub onecommit {
     my ($short)=@_;
-    my $ref;
+    my $ref = '';
 
     if($dupe{$short}) {
         # this git commit message was found in the file
index 0251594b12b2bf3fa829e786f730891cfbed15c7..61564960198ba90cc7e759ebe8d4cc8a0d002954 100755 (executable)
 # --unit : built to support unit tests
 #
 
+use strict;
+use warnings;
+
 my $unittests;
-if($ARGV[0] eq "--unit") {
+if(@ARGV && $ARGV[0] eq "--unit") {
     $unittests = "tests/unit ";
     shift @ARGV;
 }
 
-my $file = $ARGV[0];
+my $file = $ARGV[0] || '';
 
 my %wl = (
     'Curl_xfer_write_resp' => 'internal api',
@@ -178,7 +181,6 @@ open(N, "nm $file|") ||
 
 my %exist;
 my %uses;
-my $file;
 while(<N>) {
     my $l = $_;
     chomp $l;
@@ -204,7 +206,7 @@ while(<N>) {
 }
 close(N);
 
-my $err;
+my $err = 0;
 for(sort keys %exist) {
     #printf "%s is defined in %s, used by: %s\n", $_, $exist{$_}, $uses{$_};
     if(!$uses{$_}) {
index 17530cfa14d53a4d9d2be2095ff615e501e6b39d..fcd8e041362c57b2f0d2fe7b461951c92a209964 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my $varname = "var";
-if($ARGV[0] eq "--var") {
+if(@ARGV && $ARGV[0] eq "--var") {
     shift;
     $varname = shift @ARGV;
 }
index 782c4665241fb1faf661cad101afc0fb441c2f92..d1a040c0cc6373f8c888cc63fba9bbc40c1c0508 100755 (executable)
 #
 ###########################################################################
 
-if($ARGV[0] eq "-c") {
-    $c=1;
+use strict;
+use warnings;
+
+my $c = 0;
+if(@ARGV && $ARGV[0] eq "-c") {
+    $c = 1;
     shift @ARGV;
 }
 
+my @out;
+
 push @out, "          _   _ ____  _\n";
 push @out, "      ___| | | |  _ \\| |\n";
 push @out, "     / __| | | | |_) | |\n";
@@ -67,8 +73,8 @@ if($c)
     my $gzippedContent;
     IO::Compress::Gzip::gzip(
         \$content, \$gzippedContent, Level => 9, TextFlag => 1, Time=>0) or die "gzip failed:";
-    $gzip = length($content);
-    $gzipped = length($gzippedContent);
+    my $gzip = length($content);
+    my $gzipped = length($gzippedContent);
 
     print <<HEAD
 #include <zlib.h>
index f38612403c591104e43061e5aabd972689214727..7673a5fccaa625a0d8ebc5f449ec1b1849931a88 100644 (file)
 #
 ###########################################################################
 
-# populate the has %pastversion hash table with the version number as key and
+# populate the %pastversion hash table with the version number as key and
 # release date as value
 
+use strict;
+use warnings;
+
+our %pastversion;
+
 sub allversions {
     my ($file) = @_;
     open(A, "<$file") ||
index 87620003336ebb2a3a3ad2328fd7f9b1db60909f..1a36a8b1f69b2933b7ed04f8ed7ab5276ddf25c3 100755 (executable)
@@ -23,6 +23,9 @@
 #
 #***************************************************************************
 
+use strict;
+use warnings;
+
 # This script invokes nghttpx properly to have it serve HTTP/2 for us.
 # nghttpx runs as a proxy in front of our "actual" HTTP/1 server.
 use Cwd;
index b78d712b32016c5a62f2ab0460130306c243f7cc..6b3de3d74808960ffbea818a60e7170ca5f016ef 100755 (executable)
@@ -23,6 +23,9 @@
 #
 #***************************************************************************
 
+use strict;
+use warnings;
+
 # This script invokes nghttpx properly to have it serve HTTP/3 for us.
 # nghttpx runs as a proxy in front of our "actual" HTTP/1 server.
 
index 8f207a2d14c6de5cc9fe9f48f5d95632fd0f3b7e..0dc4fe15e0e4f703d37735a7d78737ec65859cec 100755 (executable)
@@ -22,6 +22,8 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+use strict;
+use warnings;
 
 # Usage:
 #   perl mk-lib1521.pl < ../../include/curl/curl.h lib1521.c
@@ -363,6 +365,8 @@ static CURLcode test_lib1521(char *URL)
 HEADER
     ;
 
+my $infomode = 0;
+
 while(<STDIN>) {
     s/^\s*(.*?)\s*$/$1/;      # Trim.
     # Remove multi-line comment trail.
index 878077d80cf07f636be9a353b8b5e994f5c41b92..b97341d0cbc4798794fb141a8b4716655c9fef1f 100755 (executable)
@@ -22,6 +22,9 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+use strict;
+use warnings;
+
 # Determine if curl-config --protocols/--features matches the
 # curl --version protocols/features
 if($#ARGV != 2) {
@@ -41,7 +44,7 @@ close CURL;
 
 $curl_protocols =~ s/\r//;
 $curl_protocols =~ /\w+: (.*)$/;
-@curl = split / /,$1;
+my @curl = split / /,$1;
 
 # Read the output of curl-config
 my @curl_config;
index 4427d633b52101a6a8891cc1d8fae22379dd1e57..e1c3cd598eee0df13f789634f17ec4d5411d283a 100755 (executable)
@@ -22,6 +22,9 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+use strict;
+use warnings;
+
 # Determine if curl-config --version matches the curl --version
 if($#ARGV != 2) {
     print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
index ea54b59824c9f225ce437ee65a5d2f6c189ebb1a..5a0a97a3a6e0779a674809ce9bb7a7cb384059e9 100755 (executable)
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+use strict;
+use warnings;
+
 # Determine if the given curl executable supports the 'openssl' SSL engine
 if($#ARGV != 0) {
     print "Usage: $0 curl-executable\n";
     exit 3;
 }
-if(!open(CURL, "@ARGV[0] -s --engine list|")) {
+if(!open(CURL, "$ARGV[0] -s --engine list|")) {
     print "Can't get SSL engine list\n";
     exit 2;
 }
index b37c25286a88692740bdf1df53ff51c96873b07f..10f665620ae2e3161377bb722453b0c685a67f76 100755 (executable)
@@ -22,6 +22,9 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+use strict;
+use warnings;
+
 # Perform simple file and directory manipulation in a portable way
 if($#ARGV <= 0) {
     print "Usage: $0 mkdir|rmdir|rm|move|gone path1 [path2] [more commands...]\n";
index 9abc0c41cd039d895a93e3849aa425a2d011ba86..429168abfcb22dcaf8c8896e37c9e807cb3416fa 100755 (executable)
@@ -22,6 +22,9 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
+use strict;
+use warnings;
+
 # Prepare a directory with known files and clean up afterwards
 use Time::Local;
 
index 339da664e0170b0556a7e06dba86d57e8a9777ab..e794972a33b9f5dc9125de2a867a7cd8579f6025 100755 (executable)
 # MEM mprintf.c:1103 realloc(e5718, 64) = e6118
 # MEM sendf.c:232 free(f6520)
 
+use strict;
+use warnings;
+
 my $mallocs=0;
 my $callocs=0;
 my $reallocs=0;
 my $strdups=0;
 my $wcsdups=0;
-my $showlimit;
+my $showlimit=0;
 my $sends=0;
 my $recvs=0;
 my $sockets=0;
+my $verbose=0;
+my $trace=0;
 
-while(1) {
+while(@ARGV) {
     if($ARGV[0] eq "-v") {
         $verbose=1;
         shift @ARGV;
@@ -70,7 +75,7 @@ sub newtotal {
     }
 }
 
-my $file = $ARGV[0];
+my $file = $ARGV[0] || '';
 
 if(! -f $file) {
     print "Usage: memanalyze.pl [options] <dump file>\n",
@@ -94,11 +99,36 @@ if($showlimit) {
     exit;
 }
 
+my %sizeataddr;
+my %getmem;
+
+my $totalmem = 0;
+my $frees = 0;
+
+my $dup;
+my $size;
+my $addr;
+
+my %filedes;
+my %getfile;
+
+my %fopen;
+my %fopenfile;
+my $openfile = 0;
+my $fopens = 0;
 
-my $lnum=0;
+my %addrinfo;
+my %addrinfofile;
+my $addrinfos = 0;
+
+my $source;
+my $linenum;
+my $function;
+
+my $lnum = 0;
 while(<$fileh>) {
     chomp $_;
-    $line = $_;
+    my $line = $_;
     $lnum++;
     if($line =~ /^LIMIT ([^ ]*):(\d*) (.*)/) {
         # new memory limit test prefix
@@ -145,13 +175,13 @@ while(<$fileh>) {
             $size = $1;
             $addr = $2;
 
-            if($sizeataddr{$addr}>0) {
+            if($sizeataddr{$addr} && $sizeataddr{$addr}>0) {
                 # this means weeeeeirdo
                 print "Mixed debug compile ($source:$linenum at line $lnum), rebuild curl now\n";
                 print "We think $sizeataddr{$addr} bytes are already allocated at that memory address: $addr!\n";
             }
 
-            $sizeataddr{$addr}=$size;
+            $sizeataddr{$addr} = $size;
             $totalmem += $size;
             $memsum += $size;
 
@@ -169,8 +199,8 @@ while(<$fileh>) {
             $size = $1*$2;
             $addr = $3;
 
-            $arg1 = $1;
-            $arg2 = $2;
+            my $arg1 = $1;
+            my $arg2 = $2;
 
             if($sizeataddr{$addr}>0) {
                 # this means weeeeeirdo
index 3908c1a25a143d01af9a28beacc442578204ccb0..dfa35aaea5d08b6f8b31151f5a1fd6be1f3a4f1a 100755 (executable)
@@ -1722,7 +1722,7 @@ sub singletest_check {
                 $ok .= "m";
             }
             my @more=`$memanalyze -v "$logdir/$MEMDUMP"`;
-            my $allocs;
+            my $allocs = 0;
             my $max = 0;
             for(@more) {
                 if(/^Allocations: (\d+)/) {
index ac06c4af30f798a168eceb71d14eeb7a4796e7f3..8900ef439fed605acac09ccf9f701bae4adf78f6 100755 (executable)
 # scan manpages to find basic syntactic problems such as unbalanced \f
 # codes or references to non-existing curl manpages.
 
-my $docsroot = $ARGV[0];
+use strict;
+use warnings;
+
+my $docsroot = $ARGV[0] || '.';
 
 if(!$docsroot || ($docsroot eq "-g")) {
     print "Usage: test1140.pl <docs root dir> [manpages]\n";
@@ -40,6 +43,8 @@ my @f = @ARGV;
 
 my %manp;
 
+my $errors = 0;
+
 sub manpresent {
     my ($man) = @_;
     if($manp{$man}) {
@@ -111,4 +116,4 @@ foreach my $f (@f) {
 
 print "OK\n" if(!$errors);
 
-exit $errors?1:0;
+exit ($errors ? 1 : 0);
index c981046b7e3979d86735785812bb0597710d5304..2e671426137184b2c660238251cb53585dcb6548 100755 (executable)
@@ -27,7 +27,7 @@ use strict;
 use warnings;
 
 # we may get the dir root pointed out
-my $root=$ARGV[0] || ".";
+my $root = $ARGV[0] || ".";
 
 my %error; # from the include file
 my %docs; # from libcurl-errors.3
index e5f54c627e9beb7a7170e2688228504020316652..d9429ea3dc62c2a771a6b653eb22a655eed5dc7f 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 my $root=$ARGV[0] || "..";
 
 my @m = `git ls-files -- $root`;
 
-my $errors;
+my $errors = 0;
 
 my %accepted=('curl' => 1,
               'libcurl' => 1,
@@ -45,7 +48,7 @@ sub checkfile {
     }
     open(my $fh, "<", "$f");
     my $l;
-    my $prevl;
+    my $prevl = '';
     my $ignore = 0;
     my $metadata = 0;
     while(<$fh>) {
index 74d46517343ba178a905dced595f085bd829361a..3eb04c035fe09209f4af094192c83761b26fcf39 100755 (executable)
 #
 ###########################################################################
 
+use strict;
+use warnings;
+
 sub showline {
     my ($l) = @_;
     $l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
     return $l;
 }
 
-my $root = $ARGV[0];
+my $root = $ARGV[0] || '..';
 
 open(my $fh, "-|", "perl $root/lib/optiontable.pl < $root/include/curl/curl.h");
 binmode $fh;
index a8f998845e956fb96d96c2300b4ca0d7258dbe48..1994f93beeb540c0f214ade08ca2de49db1a711e 100755 (executable)
@@ -27,6 +27,7 @@
 # a late evening in the #curl IRC channel.
 #
 
+use strict;
 use warnings;
 use vars qw($Cpreprocessor);
 use allversions;
@@ -52,7 +53,7 @@ my $root=$ARGV[0] || ".";
 
 # need an include directory when building out-of-tree
 my $i = ($ARGV[1]) ? "-I$ARGV[1] " : '';
-my $error;
+my $error = 0;
 
 my $versions = $ARGV[2];
 
@@ -60,6 +61,8 @@ my @syms;
 my %manpage;
 my %symadded;
 
+our %pastversion;
+
 sub checkmanpage {
     my ($m) = @_;
 
index d9090d4f9be8a463a02621fc115e2939525e61a1..249d2914f1d0e5b152a90f8785f3964f817b9cd6 100755 (executable)
@@ -98,7 +98,7 @@ while(<R>) {
 }
 close(R);
 
-my $error;
+my $error = 0;
 if(scalar(@curlout) != scalar(@txtout)) {
     printf "curl -h $opt is %d lines, $txt says %d lines\n",
         scalar(@curlout), scalar(@txtout);
index 866914500049affe6a014ec4ecc1dfbb9c38829d..b7046ac678dc0958e3f9129211c771a37273b8c4 100755 (executable)
 #   $cmddir
 #
 
+use strict;
+use warnings;
+
 use allversions;
 
 my $opts = $ARGV[0];
 my $cmddir = $ARGV[1];
 my $versions = $ARGV[2];
 
+my %file;
+my %oiv;
+my $error = 0;
+
 sub cmdfiles {
     my ($dir)=@_;
 
@@ -93,6 +100,8 @@ sub versioncheck {
     close($fh);
 }
 
+our %pastversion;
+
 # get all the past versions
 allversions($versions);
 
index 791e366257e54002dc0e998082c611fc6a7db1d2..8d6183102bbf85e3172bd0b825ef6c6661850910 100755 (executable)
@@ -61,6 +61,7 @@
 #
 
 use strict;
+use warnings;
 
 use Cwd;
 use File::Spec;
@@ -76,6 +77,9 @@ use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
             $extvercmd $nogitpull $nobuildconf $crosscompile
             $timestamp $notes);
 
+$notes='';
+$runtestopts='';
+
 # version of this script
 $version='2024-11-28';
 $fixed=0;
@@ -338,20 +342,20 @@ logit "DESC = $desc";
 logit "NOTES = $notes";
 logit "CONFOPTS = $confopts";
 logit "RUNTESTOPTS = ".$runtestopts;
-logit "CPPFLAGS = ".$ENV{CPPFLAGS};
-logit "CFLAGS = ".$ENV{CFLAGS};
-logit "LDFLAGS = ".$ENV{LDFLAGS};
-logit "LIBS = ".$ENV{LIBS};
-logit "CC = ".$ENV{CC};
-logit "TMPDIR = ".$ENV{TMPDIR};
-logit "MAKEFLAGS = ".$ENV{MAKEFLAGS};
-logit "ACLOCAL_FLAGS = ".$ENV{ACLOCAL_FLAGS};
-logit "PKG_CONFIG_PATH = ".$ENV{PKG_CONFIG_PATH};
-logit "DYLD_LIBRARY_PATH = ".$ENV{DYLD_LIBRARY_PATH};
-logit "LD_LIBRARY_PATH = ".$ENV{LD_LIBRARY_PATH};
-logit "LIBRARY_PATH = ".$ENV{LIBRARY_PATH};
-logit "SHLIB_PATH = ".$ENV{SHLIB_PATH};
-logit "LIBPATH = ".$ENV{LIBPATH};
+logit "CPPFLAGS = ".($ENV{CPPFLAGS} || '');
+logit "CFLAGS = ".($ENV{CFLAGS} || '');
+logit "LDFLAGS = ".($ENV{LDFLAGS} || '');
+logit "LIBS = ".($ENV{LIBS} || '');
+logit "CC = ".($ENV{CC} || '');
+logit "TMPDIR = ".($ENV{TMPDIR} || '');
+logit "MAKEFLAGS = ".($ENV{MAKEFLAGS} || '');
+logit "ACLOCAL_FLAGS = ".($ENV{ACLOCAL_FLAGS} || '');
+logit "PKG_CONFIG_PATH = ".($ENV{PKG_CONFIG_PATH} || '');
+logit "DYLD_LIBRARY_PATH = ".($ENV{DYLD_LIBRARY_PATH} || '');
+logit "LD_LIBRARY_PATH = ".($ENV{LD_LIBRARY_PATH} || '');
+logit "LIBRARY_PATH = ".($ENV{LIBRARY_PATH} || '');
+logit "SHLIB_PATH = ".($ENV{SHLIB_PATH} || '');
+logit "LIBPATH = ".($ENV{LIBPATH} || '');
 logit "target = ".$targetos;
 logit "version = $version"; # script version
 logit "date = $timestamp";  # When the test build starts