aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-09 13:44:16 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2019-08-09 13:45:41 -0700
commitd73b10abd5b0f4da35c7b9575e29c734be91b42d (patch)
tree81aaef3b1a13533ac1631e89b149f27af6dc1aba
parent177a05d0ce75eeee49a98944b9c7e7efa971a0a6 (diff)
downloadnasm-d73b10abd5b0f4da35c7b9575e29c734be91b42d.tar.gz
nasm-d73b10abd5b0f4da35c7b9575e29c734be91b42d.tar.xz
nasm-d73b10abd5b0f4da35c7b9575e29c734be91b42d.zip
warnings.pl: BR 3392585: don't use scalar(%hash)
The idiom scalar(%hash) seems similar to scalar(@array), and in fact is in current versions of Perl. However, in older versions of Perl, the former is totally useless: Prior to Perl 5.25 the value returned was a string consisting of the number of used buckets and the number of allocated buckets, separated by a slash. This is pretty much useful only to find out whether Perl's internal hashing algorithm is performing poorly on your data set. For example, you stick 10,000 things in a hash, but evaluating %HASH in scalar context reveals "1/16", which means only one out of sixteen buckets has been touched, and presumably contains all 10,000 of your items. This isn't supposed to happen. As of Perl 5.25 the return was changed to be the count of keys in the hash. If you need access to the old behavior you can use "Hash::Util::bucket_ratio()" instead. Use scalar(keys %hash) instead. Reported-by: Orkan Sezer <sezeroz@gmail.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rwxr-xr-xasm/warnings.pl2
1 files changed, 1 insertions, 1 deletions
diff --git a/asm/warnings.pl b/asm/warnings.pl
index 9a3d39f5..e4f1472a 100755
--- a/asm/warnings.pl
+++ b/asm/warnings.pl
@@ -210,7 +210,7 @@ if ($what eq 'c') {
print $out "\tconst char *name;\n";
print $out "\tenum warn_index warning;\n";
print $out "};\n\n";
- printf $out "#define NUM_WARNING_ALIAS %d\n", scalar(%aliases);
+ printf $out "#define NUM_WARNING_ALIAS %d\n", scalar(keys %aliases);
printf $out "extern const char * const warning_name[%d];\n",
$#warnings + 2;