From 80522b55b10b2d449b37da6e589ef96fac0ba06f Mon Sep 17 00:00:00 2001 From: Harald Hope Date: Mon, 13 Jun 2022 16:32:32 -0700 Subject: [PATCH] Bug release, replace 3.3.17 asap, most users will not experience the bug, but if they do, inxi stops right before the -D line. Failed to do an if defined test on an array ref that could be undefined or an array ref. That makes Perl very unhappy! -------------------------------------------------------------------------------- KNOWN ISSUES: 1. AMD family F, K8 series, will need more granular treatments to get the data to be more accurate and less generic. We got 2 IDs nailed from raw visual data confirmations and cpuid values, which leaves many, but good start. We will chip away (pardon the pun) at these more ambiguous IDs over time, but don't need to get them all done instantly, just eventually. Thanks slackware person linuxdaddy for doing really good research and actually looking at the cpu to find dates etc. -------------------------------------------------------------------------------- BUGS: 1. Bug, fatal, caused by internal hash/array ref refactor of 3.3.17. Thanks alaymari github issue #271 for reporting this one. -------------------------------------------------------------------------------- FIXES: 1. None except for code fixes to try to avoid the cause of the bug in Bugs 1. 2. Fixed nvidia eol try --gpu, it was showing backwards, with --gpu, not without, sigh. -------------------------------------------------------------------------------- ENHANCEMENTS: 1. Added slimski dm data. That's a new fork of SLiM. Also guessing that brzdm has same version -v output: brzdm version x.xx -------------------------------------------------------------------------------- CHANGES: 1. None -------------------------------------------------------------------------------- DOCUMENTATION: 1. Refactors of core docs, ongoing, but will list those next release. -------------------------------------------------------------------------------- CODE: 1. Cleaned up some array ref handling in subs, returned as: ($var1,$var2) = @{block_data(...)}, skipped initializing and creating scalar to hold the ref, just use it directly for DiskItem::block_data(). 2. Also switched to local ref scalar array in DiskItem::scsi_data(), DiskItem::block_data(). Not set local array, set local array ref, to keep it clear. Also made DriveItem::drive_speed() return straight ref, not array then ref. Same for many other subs, switched to ref assignment so it's the same ref all through all the sub and return. 3. Fixed a redundant return \@$data to simply assinging to @$data ref, no return needed, in DiskItem::smartctl_data(). 4. Tightened some returns of ref so that tests if good test @$ref, not $ref. Trying to avoid more cases like issue #271. 5. Going along with array ref local/return, switched all hash refs to local hash ref returning ref, and working local with ref. More efficient, avoids creating new refs over and over, dugh. This made a particularly large difference in CPU because in certain parts, new references were being created over and over, and subs were returning like \@arr or \%hash instead of declaring to start: my $arr = []; my $hash = {}; Then working with the data from there on as an array or hash reference, to the same original reference, rather than creating new ones over and over, which Perl then has to track til they expire. --- inxi | 965 +++++++++++++++++++++++++------------------------ inxi.1 | 10 +- inxi.changelog | 91 ++++- 3 files changed, 591 insertions(+), 475 deletions(-) diff --git a/inxi b/inxi index 11537c6..a599e30 100755 --- a/inxi +++ b/inxi @@ -48,8 +48,8 @@ use POSIX qw(ceil uname strftime ttyname); ## INXI INFO ## my $self_name='inxi'; -my $self_version='3.3.17'; -my $self_date='2022-06-10'; +my $self_version='3.3.18'; +my $self_date='2022-06-13'; my $self_patch='00'; ## END INXI INFO ## @@ -4088,7 +4088,7 @@ sub set_program_values { 'qmake' => ['^^Using Qt version',4,'--version','Qt',0,0,0,'',''], 'qtdiag' => ['^qt',2,'--version','Qt',0,1,0,'',''], ## Display Managers (dm) ## - 'brzdm' => ['^brzdm',0,'-v','brzdm',0,1,0,'',''], # unverified, like slim + 'brzdm' => ['^brzdm version',3,'-v','brzdm',0,1,0,'',''], # unverified, slim fork 'cdm' => ['^cdm',0,'0','CDM',0,1,0,'',''], # might be xlogin, unknown output for -V 'clogin' => ['^clogin',0,'-V','clogin',0,1,0,'',''], # unverified, maybe xlogin @@ -4110,6 +4110,7 @@ sub set_program_values { 'qingy' => ['^qingy',0,'0','qingy',0,1,0,'',''], # unverified 'sddm' => ['^sddm',0,'0','SDDM',0,1,0,'',''], 'slim' => ['slim version',3,'-v','SLiM',0,1,0,'',''], + 'slimski' => ['slimski version',3,'-v','slimski',0,1,0,'',''], # slim fork 'tbsm' => ['^tbsm',0,'0','tbsm',0,1,0,'',''], # unverified 'tdm' => ['^tdm',0,'0','TDM',0,1,0,'',''], 'udm' => ['^udm',0,'0','udm',0,1,0,'',''], @@ -9403,10 +9404,10 @@ sub cpuinfo_data_grabber { sub cpu_sys_data { eval $start if $b_log; my $sys_freq = $_[0]; - my (%cpu_sys); + my $cpu_sys = {}; my $working = sys_data_grabber(); - return \%cpu_sys if !%{$working}; - $cpu_sys{'data'} = $working->{'data'} if $working->{'data'}; + return $cpu_sys if !%$working; + $cpu_sys->{'data'} = $working->{'data'} if $working->{'data'}; my ($core_id,$fake_core_id,$phys_id,) = (0,0,-1); my (%cache_ids,@ci_freq_max,@ci_freq_min,@sc_freq_max,@sc_freq_min); foreach my $key (sort keys %{$working->{'cpus'}}){ @@ -9431,14 +9432,14 @@ sub cpu_sys_data { $speed = $sys_freq->{$key}; } if (defined $speed){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'cores'}{$core_id}},$speed); - push(@{$cpu_sys{'data'}->{'speeds'}{'all'}},$speed); + push(@{$cpu_sys->{'cpus'}{$phys_id}{'cores'}{$core_id}},$speed); + push(@{$cpu_sys->{'data'}{'speeds'}{'all'}},$speed); } else { - push(@{$cpu_sys{'data'}->{'speeds'}{'all'}},0); + push(@{$cpu_sys->{'data'}{'speeds'}{'all'}},0); # seen cases, riscv, where core id, phys id, are all -1 my $id = ($core_id != -1) ? $core_id: $fake_core_id++; - push(@{$cpu_sys{'cpus'}->{$phys_id}{'cores'}{$id}},0); + push(@{$cpu_sys->{'cpus'}{$phys_id}{'cores'}{$id}},0); } # Only use if topology core-id exists, some virtualized cpus can list # frequency data for the non available cores, but those do not show @@ -9449,8 +9450,8 @@ sub cpu_sys_data { if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_max_freq'}} @ci_freq_max){ push(@ci_freq_max,$cpu->{'cpufreq'}{'cpuinfo_max_freq'}); } - if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_max_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}}){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'cpuinfo_max_freq'}); + if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_max_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}}){ + push(@{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'cpuinfo_max_freq'}); } } if (defined $cpu->{'cpufreq'}{'cpuinfo_min_freq'}){ @@ -9458,8 +9459,8 @@ sub cpu_sys_data { if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_min_freq'}} @ci_freq_min){ push(@ci_freq_min,$cpu->{'cpufreq'}{'cpuinfo_min_freq'}); } - if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_min_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}}){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'cpuinfo_min_freq'}); + if (!grep {$_ eq $cpu->{'cpufreq'}{'cpuinfo_min_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}}){ + push(@{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'cpuinfo_min_freq'}); } } if (defined $cpu->{'cpufreq'}{'scaling_max_freq'}){ @@ -9467,8 +9468,8 @@ sub cpu_sys_data { if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_max_freq'}} @sc_freq_max){ push(@sc_freq_max,$cpu->{'cpufreq'}{'scaling_max_freq'}); } - if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_max_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}}){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'scaling_max_freq'}); + if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_max_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}}){ + push(@{$cpu_sys->{'cpus'}{$phys_id}{'max-freq'}},$cpu->{'cpufreq'}{'scaling_max_freq'}); } } if (defined $cpu->{'cpufreq'}{'scaling_min_freq'}){ @@ -9476,21 +9477,21 @@ sub cpu_sys_data { if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_min_freq'}} @sc_freq_min){ push(@sc_freq_min,$cpu->{'cpufreq'}{'scaling_min_freq'}); } - if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_min_freq'}} @{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}}){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'scaling_min_freq'}); + if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_min_freq'}} @{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}}){ + push(@{$cpu_sys->{'cpus'}{$phys_id}{'min-freq'}},$cpu->{'cpufreq'}{'scaling_min_freq'}); } } if (defined $cpu->{'cpufreq'}{'scaling_governor'}){ - if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_governor'}} @{$cpu_sys{'cpus'}->{$phys_id}{'governor'}}){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'governor'}},$cpu->{'cpufreq'}{'scaling_governor'}); + if (!grep {$_ eq $cpu->{'cpufreq'}{'scaling_governor'}} @{$cpu_sys->{'cpus'}{$phys_id}{'governor'}}){ + push(@{$cpu_sys->{'cpus'}{$phys_id}{'governor'}},$cpu->{'cpufreq'}{'scaling_governor'}); } } if (defined $cpu->{'cpufreq'}{'scaling_driver'}){ - $cpu_sys{'cpus'}->{$phys_id}{'scaling-driver'} = $cpu->{'cpufreq'}{'scaling_driver'}; + $cpu_sys->{'cpus'}{$phys_id}{'scaling-driver'} = $cpu->{'cpufreq'}{'scaling_driver'}; } } - if (!defined $cpu_sys{'data'}->{'cpufreq-boost'} && defined $cpu->{'cpufreq'}{'cpb'}){ - $cpu_sys{'data'}->{'cpufreq-boost'} = $cpu->{'cpufreq'}{'cpb'}; + if (!defined $cpu_sys->{'data'}{'cpufreq-boost'} && defined $cpu->{'cpufreq'}{'cpb'}){ + $cpu_sys->{'data'}{'cpufreq-boost'} = $cpu->{'cpufreq'}{'cpb'}; } if (defined $cpu->{'topology'}{'core_cpus_list'}){ $cpu->{'topology'}{'thread_siblings_list'} = $cpu->{'topology'}{'core_cpus_list'}; @@ -9512,7 +9513,7 @@ sub cpu_sys_data { # print "cpuid: $cpu_id phys-core: $phys_id-$core_id level: $level range: $range shared: $cache->{'shared_cpu_list'}\n"; if (!(grep {$_ eq $cache->{'shared_cpu_list'}} @{$cache_ids{$phys_id}->{$level}})){ push(@{$cache_ids{$phys_id}->{$level}},$cache->{'shared_cpu_list'}); - push(@{$cpu_sys{'cpus'}->{$phys_id}{'caches'}{$level}},$size); + push(@{$cpu_sys->{'cpus'}{$phys_id}{'caches'}{$level}},$size); } } } @@ -9522,53 +9523,53 @@ sub cpu_sys_data { defined $cpu->{'topology'}{'core_siblings_list'}){ my $die = $cpu->{'topology'}{'die_id'}; $die = $cpu->{'topology'}{'core_siblings_list'} if !defined $die; - if (!grep {$_ eq $die} @{$cpu_sys{'cpus'}->{$phys_id}{'dies'}}){ - push(@{$cpu_sys{'cpus'}->{$phys_id}{'dies'}},$die); + if (!grep {$_ eq $die} @{$cpu_sys->{'cpus'}{$phys_id}{'dies'}}){ + push(@{$cpu_sys->{'cpus'}{$phys_id}{'dies'}},$die); } } } - if (defined $cpu_sys{'data'}->{'cpufreq-boost'} && - $cpu_sys{'data'}->{'cpufreq-boost'} =~ /^[01]$/){ - if ($cpu_sys{'data'}->{'cpufreq-boost'}){ - $cpu_sys{'data'}->{'cpufreq-boost'} = 'enabled'; + if (defined $cpu_sys->{'data'}{'cpufreq-boost'} && + $cpu_sys->{'data'}{'cpufreq-boost'} =~ /^[01]$/){ + if ($cpu_sys->{'data'}{'cpufreq-boost'}){ + $cpu_sys->{'data'}{'cpufreq-boost'} = 'enabled'; } else { - $cpu_sys{'data'}->{'cpufreq-boost'} = 'disabled'; + $cpu_sys->{'data'}{'cpufreq-boost'} = 'disabled'; } } # cpuinfo_max_freq:["2000000"] cpuinfo_max_freq:["1500000"] # cpuinfo_min_freq:["200000"] if (@ci_freq_max){ - $cpu_sys{'data'}->{'speeds'}{'max-freq'} = join(':',@ci_freq_max); + $cpu_sys->{'data'}{'speeds'}{'max-freq'} = join(':',@ci_freq_max); } if (@ci_freq_min){ - $cpu_sys{'data'}->{'speeds'}{'min-freq'} = join(':',@ci_freq_min); + $cpu_sys->{'data'}{'speeds'}{'min-freq'} = join(':',@ci_freq_min); } # also handle off chance that cpuinfo_min/max not set, but scaling_min/max there if (@sc_freq_max){ - $cpu_sys{'data'}->{'speeds'}{'scaling-max-freq'} = join(':',@sc_freq_max); - if (!$cpu_sys{'data'}->{'speeds'}{'max-freq'}){ - $cpu_sys{'data'}->{'speeds'}{'max-freq'} = $cpu_sys{'data'}->{'speeds'}{'scaling-max-freq'}; + $cpu_sys->{'data'}{'speeds'}{'scaling-max-freq'} = join(':',@sc_freq_max); + if (!$cpu_sys->{'data'}{'speeds'}{'max-freq'}){ + $cpu_sys->{'data'}{'speeds'}{'max-freq'} = $cpu_sys->{'data'}{'speeds'}{'scaling-max-freq'}; } } if (@sc_freq_min){ - $cpu_sys{'data'}->{'speeds'}{'scaling-min-freq'} = join(':',@sc_freq_min); - if (!$cpu_sys{'data'}->{'speeds'}{'min-freq'}){ - $cpu_sys{'data'}->{'speeds'}{'min-freq'} = $cpu_sys{'data'}->{'speeds'}{'scaling-min-freq'}; + $cpu_sys->{'data'}{'speeds'}{'scaling-min-freq'} = join(':',@sc_freq_min); + if (!$cpu_sys->{'data'}{'speeds'}{'min-freq'}){ + $cpu_sys->{'data'}{'speeds'}{'min-freq'} = $cpu_sys->{'data'}{'speeds'}{'scaling-min-freq'}; } } # this corrects a bug we see sometimes in min/max frequencies if ((scalar @ci_freq_max < 2 && scalar @ci_freq_min < 2) && - (defined $cpu_sys{'data'}->{'speeds'}{'min-freq'} && - defined $cpu_sys{'data'}->{'speeds'}{'max-freq'}) && - ($cpu_sys{'data'}->{'speeds'}{'min-freq'} > $cpu_sys{'data'}->{'speeds'}{'max-freq'} || - $cpu_sys{'data'}->{'speeds'}{'min-freq'} == $cpu_sys{'data'}->{'speeds'}{'max-freq'})){ - $cpu_sys{'data'}->{'speeds'}{'min-freq'} = 0; + (defined $cpu_sys->{'data'}{'speeds'}{'min-freq'} && + defined $cpu_sys->{'data'}{'speeds'}{'max-freq'}) && + ($cpu_sys->{'data'}{'speeds'}{'min-freq'} > $cpu_sys->{'data'}{'speeds'}{'max-freq'} || + $cpu_sys->{'data'}{'speeds'}{'min-freq'} == $cpu_sys->{'data'}{'speeds'}{'max-freq'})){ + $cpu_sys->{'data'}{'speeds'}{'min-freq'} = 0; } - main::log_data('dump','%cpu_sys',\%cpu_sys) if $b_log; - print Data::Dumper::Dumper \%cpu_sys if $dbg[8]; + main::log_data('dump','%$cpu_sys',$cpu_sys) if $b_log; + print Data::Dumper::Dumper $cpu_sys if $dbg[8]; eval $end if $b_log; - return \%cpu_sys; + return $cpu_sys; } sub sys_data_grabber { eval $start if $b_log; @@ -9614,10 +9615,11 @@ sub sys_data_grabber { } main::log_data('dump','@files',\@files) if $b_log; print Data::Dumper::Dumper \@files if $dbg[40]; - my ($b_bug,$b_cache,$b_freq,$b_topo,$b_main,%working); + my ($b_bug,$b_cache,$b_freq,$b_topo,$b_main); + my $working = {}; my ($main_id,$main_key,$holder,$id,$item,$key) = ('','','','','',''); # need to return hash reference on failure or old systems complain - return \%working if !@files; + return $working if !@files; foreach (sort @files){ if ($fake{'cpu'}){ ($_,$item) = split(/::/,$_,2); @@ -9697,24 +9699,24 @@ sub sys_data_grabber { } # print "$key_1 :: $key_2 :: $item\n"; if ($b_main){ - $working{'data'}->{$id} = $item; + $working->{'data'}{$id} = $item; } elsif ($b_bug){ my $type = ($item =~ /^Mitigation:/) ? 'mitigation': 'status'; $item =~ s/Mitigation: //; - $working{'data'}->{$id}{$key} = [$type,$item]; + $working->{'data'}{$id}{$key} = [$type,$item]; } elsif ($b_cache){ - $working{'cpus'}->{$id}{$key}{$main_id}{$main_key} = $item; + $working->{'cpus'}{$id}{$key}{$main_id}{$main_key} = $item; } elsif ($b_freq || $b_topo){ - $working{'cpus'}->{$id}{$key}{$main_key} = $item; + $working->{'cpus'}{$id}{$key}{$main_key} = $item; } } - main::log_data('dump','%working',\%working) if $b_log; - print Data::Dumper::Dumper \%working if $dbg[39]; + main::log_data('dump','%$working',$working) if $b_log; + print Data::Dumper::Dumper $working if $dbg[39]; eval $end if $b_log; - return \%working; + return $working; } sub sysctl_data { eval $start if $b_log; @@ -9893,7 +9895,7 @@ sub sysctl_data { ## DATA GENERATOR DATA SOURCES ## sub dboot_data { eval $start if $b_log; - my ($max_freq,$min_freq,@scalings,%values); + my ($max_freq,$min_freq,@scalings); my ($family,$flags,$microcode,$model,$sep,$stepping,$type) = ('','','','','','',''); my ($cores,$siblings) = (0,0); my ($l1d,$l1i,$l2,$l3) = (0,0,0,0); @@ -9988,7 +9990,7 @@ sub dboot_data { $flags = main::message('dmesg-boot-permissions'); } } - %values = ( + my $values = { 'cores' => $cores, 'family' => $family, 'flags' => $flags, @@ -10004,17 +10006,17 @@ sub dboot_data { 'siblings' => $siblings, 'stepping' => $stepping, 'type' => $type, - ); - print Data::Dumper::Dumper \%values if $dbg[27]; + }; + print Data::Dumper::Dumper $values if $dbg[27]; eval $end if $b_log; - return \%values; + return $values; } sub dmidecode_data { eval $start if $b_log; - return if !@dmi; - my %dmi_data = ('L1' => 0, 'L2' => 0,'L3' => 0, 'phys-cnt' => 0, + my $dmi_data = {'L1' => 0, 'L2' => 0,'L3' => 0, 'phys-cnt' => 0, 'ext-clock' => undef, 'socket' => undef, 'speed' => undef, - 'max-speed' => undef, 'upgrade' => undef, 'volts' => undef); + 'max-speed' => undef, 'upgrade' => undef, 'volts' => undef}; + return $dmi_data if !@dmi; my ($id,$amount,$socket,$upgrade); foreach my $item (@dmi){ next if ref $item ne 'ARRAY'; @@ -10049,7 +10051,7 @@ sub dmidecode_data { $amount = main::translate_size($1); } if ($id && $amount){ - $dmi_data{$id} = $amount; + $dmi_data->{$id} = $amount; last; } } @@ -10061,7 +10063,7 @@ sub dmidecode_data { elsif ($item->[0] == 4){ # skip first three row,s we don't need that data ($socket,$upgrade) = (); - $dmi_data{'phys-cnt'}++; # try to catch bsds without physical cpu count + $dmi_data->{'phys-cnt'}++; # try to catch bsds without physical cpu count foreach my $value (@$item[3 .. $#$item]){ next if $value =~ /^~/; # note: on single cpu systems, Socket Designation shows socket type, @@ -10080,16 +10082,16 @@ sub dmidecode_data { } # seen: Voltage: 5.0 V 2.9 V elsif ($value =~ /^Voltage:\s*([0-9\.]+)\s*(V|Volts)?\b/i){ - $dmi_data{'volts'} = main::clean_dmi($1); + $dmi_data->{'volts'} = main::clean_dmi($1); } elsif ($value =~ /^Current Speed:\s*([0-9\.]+)\s*([MGK]Hz)?\b/i){ - $dmi_data{'speed'} = main::clean_dmi($1); + $dmi_data->{'speed'} = main::clean_dmi($1); } elsif ($value =~ /^Max Speed:\s*([0-9\.]+)\s*([MGK]Hz)?\b/i){ - $dmi_data{'max-speed'} = main::clean_dmi($1); + $dmi_data->{'max-speed'} = main::clean_dmi($1); } elsif ($value =~ /^External Clock:\s*([0-9\.]+\s*[MGK]Hz)\b/){ - $dmi_data{'ext-clock'} = main::clean_dmi($1); + $dmi_data->{'ext-clock'} = main::clean_dmi($1); } } } @@ -10103,71 +10105,74 @@ sub dmidecode_data { $socket = $upgrade; undef $upgrade; } - $dmi_data{'socket'} = $socket; - $dmi_data{'upgrade'} = $upgrade; + $dmi_data->{'socket'} = $socket; + $dmi_data->{'upgrade'} = $upgrade; } - main::log_data('dump','%dmi_data',\%dmi_data) if $b_log; - print Data::Dumper::Dumper \%dmi_data if $dbg[27]; + main::log_data('dump','%$dmi_data',$dmi_data) if $b_log; + print Data::Dumper::Dumper $dmi_data if $dbg[27]; eval $end if $b_log; - return \%dmi_data; + return $dmi_data; } ## CPU PROPERTIES MAIN ## sub cpu_properties { my ($cpu) = @_; - my ($cpu_sys,%dmi_data,%tests); - my %caches = ( + my ($cpu_sys); + my $dmi_data = {}; + my $tests = {}; + my $caches = { 'cache' => 0, # general, non id'ed from cpuinfo generic cache 'l1' => 0, 'l1d' => 0, 'l1i' => 0, 'l2' => 0, 'l3' => 0, - ); - my %counts = ( + }; + my $counts = { 'dies' => 0, 'cpu-cores' => 0, 'cores' => 0, 'cores-multiplier' => 0, 'physical' => 0, 'processors' => 0, - ); + }; my ($cache_check) = (''); if (!$bsd_type && -d '/sys/devices' && !$force{'cpuinfo'}){ $cpu_sys = cpu_sys_data($cpu->{'sys-freq'}); } - cp_test_types($cpu,\%tests) if $cpu->{'type'}; + cp_test_types($cpu,$tests) if $cpu->{'type'}; undef $cpu_sys if $dbg[42]; ## START CPU DATA HANDLERS ## if (defined $cpu_sys->{'cpus'}){ cp_data_sys( $cpu, $cpu_sys, - \%caches, - \%counts + $caches, + $counts ); } - if (!defined $cpu_sys->{'cpus'} || !$counts{'physical'} || - !$counts{'cpu-cores'}){ + if (!defined $cpu_sys->{'cpus'} || !$counts->{'physical'} || + !$counts->{'cpu-cores'}){ cp_data_fallback( $cpu, - \%caches, + $caches, \$cache_check, - \%counts, - \%tests, + $counts, + $tests, ); } # some arm cpus report each core as its own die, but that's wrong - if (%risc && $counts{'dies'} > 1 && $counts{'cpu-cores'} == $counts{'dies'}){ - $counts{'dies'} = 1; + if (%risc && $counts->{'dies'} > 1 && + $counts->{'cpu-cores'} == $counts->{'dies'}){ + $counts->{'dies'} = 1; $cpu->{'dies'} = 1; } if ($type eq 'full' && ($extra > 1 || ($bsd_type && !$cpu->{'l2-cache'}))){ cp_data_dmi( $cpu, - \%dmi_data, - \%caches, - \%counts, # only to set BSD phys cpu counts if not found + $dmi_data, + $caches, + $counts, # only to set BSD phys cpu counts if not found \$cache_check, ); } @@ -10177,31 +10182,33 @@ sub cpu_properties { ## START CACHE PROCESSING ## # Get BSD and legacy linux caches if not already from dmidecode or cpu_sys. - if ($type eq 'full' && !$caches{'l1'} && !$caches{'l2'} && !$caches{'l2'}){ + if ($type eq 'full' && + !$caches->{'l1'} && !$caches->{'l2'} && !$caches->{'l2'}){ cp_caches_fallback( - \%counts, + $counts, $cpu, - \%caches, + $caches, \$cache_check, ); } # nothing to check! if ($type eq 'full'){ - if (!$caches{'l1'} && !$caches{'l2'} && !$caches{'l3'} && !$caches{'cache'}){ + if (!$caches->{'l1'} && !$caches->{'l2'} && !$caches->{'l3'} && + !$caches->{'cache'}){ $cache_check = ''; } - if ($caches{'cache'}){ + if ($caches->{'cache'}){ # we don't want any math done on this one, who knows what it is - $caches{'cache'} = cp_cache_processor($caches{'cache'},1); + $caches->{'cache'} = cp_cache_processor($caches->{'cache'},1); } - if ($caches{'l1'}){ - $caches{'l1'} = cp_cache_processor($caches{'l1'},$counts{'physical'}); + if ($caches->{'l1'}){ + $caches->{'l1'} = cp_cache_processor($caches->{'l1'},$counts->{'physical'}); } - if ($caches{'l2'}){ - $caches{'l2'} = cp_cache_processor($caches{'l2'},$counts{'physical'}); + if ($caches->{'l2'}){ + $caches->{'l2'} = cp_cache_processor($caches->{'l2'},$counts->{'physical'}); } - if ($caches{'l3'}){ - $caches{'l3'} = cp_cache_processor($caches{'l3'},$counts{'physical'}); + if ($caches->{'l3'}){ + $caches->{'l3'} = cp_cache_processor($caches->{'l3'},$counts->{'physical'}); } } ## END CACHE PROCESSING ## @@ -10209,12 +10216,12 @@ sub cpu_properties { ## START TYPE/LAYOUT/ARCH/BUGS ## my ($cpu_type) = (''); $cpu_type = cp_cpu_type( - \%counts, + $counts, $cpu, - \%tests + $tests ); - my %topology; - cp_cpu_topology(\%counts,\%topology); + my $topology = {}; + cp_cpu_topology($counts,$topology); my $arch = cp_cpu_arch( $cpu->{'type'}, $cpu->{'family'}, @@ -10225,7 +10232,7 @@ sub cpu_properties { # arm cpuinfo case only; confirm on bsds, not sure all get family/ids if ($arch->[0] && !$cpu->{'arch'}){ ($cpu->{'arch'},$cpu->{'arch-note'},$cpu->{'process'},$cpu->{'gen'}, - $cpu->{'year'}) = @{$arch}; + $cpu->{'year'}) = @$arch; } # cpu_arch comes from set_os() if (!$cpu->{'arch'} && $cpu_arch && %risc){ @@ -10244,48 +10251,48 @@ sub cpu_properties { ## END SPEED/BITS ## ## LOAD %cpu_properties - my %cpu_properties = ( + my $cpu_properties = { 'avg-speed-key' => $speed_info->{'avg-speed-key'}, 'bits-sys' => $bits_sys, - 'cache' => $caches{'cache'}, + 'cache' => $caches->{'cache'}, 'cache-check' => $cache_check, 'cpu-type' => $cpu_type, - 'dmi-max-speed' => $dmi_data{'max-speed'}, - 'dmi-speed' => $dmi_data{'speed'}, - 'ext-clock' => $dmi_data{'ext-clock'}, + 'dmi-max-speed' => $dmi_data->{'max-speed'}, + 'dmi-speed' => $dmi_data->{'speed'}, + 'ext-clock' => $dmi_data->{'ext-clock'}, 'high-speed-key' => $speed_info->{'high-speed-key'}, - 'l1-cache' => $caches{'l1'}, - 'l1d-desc' => $caches{'l1d-desc'}, - 'l1i-desc' => $caches{'l1i-desc'}, - 'l2-cache' => $caches{'l2'}, - 'l2-desc' => $caches{'l2-desc'}, - 'l3-cache' => $caches{'l3'}, - 'l3-desc' => $caches{'l3-desc'}, + 'l1-cache' => $caches->{'l1'}, + 'l1d-desc' => $caches->{'l1d-desc'}, + 'l1i-desc' => $caches->{'l1i-desc'}, + 'l2-cache' => $caches->{'l2'}, + 'l2-desc' => $caches->{'l2-desc'}, + 'l3-cache' => $caches->{'l3'}, + 'l3-desc' => $caches->{'l3-desc'}, 'min-max-key' => $speed_info->{'min-max-key'}, 'min-max' => $speed_info->{'min-max'}, - 'socket' => $dmi_data{'socket'}, + 'socket' => $dmi_data->{'socket'}, 'scaling-min-max-key' => $speed_info->{'scaling-min-max-key'}, 'scaling-min-max' => $speed_info->{'scaling-min-max'}, 'speed-key' => $speed_info->{'speed-key'}, 'speed' => $speed_info->{'speed'}, - 'topology-full' => $topology{'full'}, - 'topology-string' => $topology{'string'}, - 'upgrade' => $dmi_data{'upgrade'}, - 'volts' => $dmi_data{'volts'}, - ); + 'topology-full' => $topology->{'full'}, + 'topology-string' => $topology->{'string'}, + 'upgrade' => $dmi_data->{'upgrade'}, + 'volts' => $dmi_data->{'volts'}, + }; if ($b_log){ - main::log_data('dump','%cpu_properties',\%cpu_properties); - main::log_data('dump','%topology',\%topology); + main::log_data('dump','%$cpu_properties',$cpu_properties); + main::log_data('dump','%$topology',$topology); } # print Data::Dumper::Dumper $cpu; if ($dbg[38]){ - print Data::Dumper::Dumper \%cpu_properties; - print Data::Dumper::Dumper \%topology; + print Data::Dumper::Dumper $cpu_properties; + print Data::Dumper::Dumper $topology; } # my $dc = scalar @dies; # print 'phys: ' . $pc . ' dies: ' . $dc, "\n"; eval $end if $b_log; - return \%cpu_properties; + return $cpu_properties; } ## CPU DATA ENGINES ## @@ -10784,8 +10791,19 @@ sub cp_cpu_arch { $process = 'AMD 130-250nm'; $year = '';} } + # note: family F K8 needs granular breakdowns, was a long lived family elsif ($family eq 'F'){ - if ($model =~ /^(4|5|7|8|B|C|E|F|14|15|17|18|1B|1C|1F)$/){ + # positive IDs, but sub arch difficult, can be stepping based + if ($model =~ /^(1C)$/){ + $arch = 'K8'; # Palermo + $process = 'AMD 90nm'; + $year = '2001';} + elsif ($model =~ /^(7F)$/){ + $arch = 'K8 rev.F+'; # Lima + $process = 'AMD 65nm'; + $year = '2005';} + # generic IDs, try to reduce these to solid over time + elsif ($model =~ /^(4|5|7|8|B|C|E|F|14|15|17|18|1B|1F)$/){ $arch = 'K8'; $process = 'AMD 65-130nm'; $year = '';} @@ -10793,7 +10811,7 @@ sub cp_cpu_arch { $arch = 'K8 rev.E'; $process = 'AMD 65-130nm'; $year = '';} - elsif ($model =~ /^(41|43|48|4B|4C|4F|5D|5F|68|6B|6C|6F|7C|7F|C1)$/){ + elsif ($model =~ /^(41|43|48|4B|4C|4F|5D|5F|68|6B|6C|6F|7C|C1)$/){ $arch = 'K8 rev.F+'; $process = 'AMD 65-130nm'; $year = '';} @@ -11626,7 +11644,7 @@ sub cp_elbrus_data { sub cp_speed_data { eval $start if $b_log; my ($cpu,$cpu_sys) = @_; - my %info; + my $info = {}; if (defined $cpu_sys->{'data'}){ if (defined $cpu_sys->{'data'}{'speeds'}{'min-freq'}){ $cpu->{'min-freq'} = $cpu_sys->{'data'}{'speeds'}{'min-freq'}; @@ -11671,47 +11689,47 @@ sub cp_speed_data { if ($agg){ $cpu->{'avg-freq'} = int($agg/scalar @{$cpu->{'processors'}}); $cpu->{'cur-freq'} = $high; - $info{'avg-speed-key'} = 'avg'; - $info{'speed'} = $cpu->{'avg-freq'}; + $info->{'avg-speed-key'} = 'avg'; + $info->{'speed'} = $cpu->{'avg-freq'}; if ($high > $cpu->{'avg-freq'}){ $cpu->{'high-freq'} = $high; - $info{'high-speed-key'} = 'high'; + $info->{'high-speed-key'} = 'high'; } } } elsif ($cpu->{'processors'}[0]) { $cpu->{'cur-freq'} = $cpu->{'processors'}[0]; - $info{'speed'} = $cpu->{'cur-freq'}; + $info->{'speed'} = $cpu->{'cur-freq'}; } } # BSDs generally will have processors count, but not per core speeds - if ($cpu->{'cur-freq'} && !$info{'speed'}){ - $info{'speed'} = $cpu->{'cur-freq'}; + if ($cpu->{'cur-freq'} && !$info->{'speed'}){ + $info->{'speed'} = $cpu->{'cur-freq'}; } if ($cpu->{'min-freq'} || $cpu->{'max-freq'}){ - ($info{'min-max'},$info{'min-max-key'}) = cp_speed_min_max( + ($info->{'min-max'},$info->{'min-max-key'}) = cp_speed_min_max( $cpu->{'min-freq'}, $cpu->{'max-freq'}); } if ($cpu->{'scaling-min-freq'} || $cpu->{'scaling-max-freq'}){ - ($info{'scaling-min-max'},$info{'scaling-min-max-key'}) = cp_speed_min_max( + ($info->{'scaling-min-max'},$info->{'scaling-min-max-key'}) = cp_speed_min_max( $cpu->{'scaling-min-freq'}, $cpu->{'scaling-max-freq'}, 'sc'); } if ($cpu->{'cur-freq'}){ if ($show{'short'}){ - $info{'speed-key'} = 'speed'; + $info->{'speed-key'} = 'speed'; } elsif ($show{'cpu-basic'}){ - $info{'speed-key'} = 'speed (MHz)'; + $info->{'speed-key'} = 'speed (MHz)'; } else { - $info{'speed-key'} = 'Speed (MHz)'; + $info->{'speed-key'} = 'Speed (MHz)'; } } eval $end if $b_log; - return \%info; + return $info; } sub cp_speed_min_max { my ($min,$max,$type) = @_; @@ -11805,7 +11823,8 @@ sub set_cpu_data { } sub system_cpu_name { eval $start if $b_log; - my (%cpus,$compat,@working); + my ($compat,@working); + my $cpus = {}; if (@working = main::globber('/sys/firmware/devicetree/base/cpus/cpu@*/compatible')){ foreach my $file (@working){ $compat = main::reader($file,'',0); @@ -11814,7 +11833,7 @@ sub system_cpu_name { # splits for: null 00/start header 01/start text 02/end text 03 $compat = (split(/\x01|\x02|\x03|\x00/, $compat))[0] if $compat; $compat = (split(/,\s*/, $compat))[-1] if $compat; - $cpus{$compat} = ($cpus{$compat}) ? ++$cpus{$compat}: 1; + $cpus->{$compat} = ($cpus->{$compat}) ? ++$cpus->{$compat}: 1; } } # synthesize it, [4] will be like: cortex-a15-timer; sunxi-timer @@ -11824,12 +11843,12 @@ sub system_cpu_name { next if $working->[0] ne 'timer' || !$working->[4] || $working->[4] =~ /timer-mem$/; $working->[4] =~ s/(-system)?-timer$//; $compat = $working->[4]; - $cpus{$compat} = ($cpus{$compat}) ? ++$cpus{$compat}: 1; + $cpus->{$compat} = ($cpus->{$compat}) ? ++$cpus->{$compat}: 1; } } - main::log_data('dump','%cpus',\%cpus) if $b_log; + main::log_data('dump','%$cpus',$cpus) if $b_log; eval $end if $b_log; - return \%cpus; + return $cpus; } ## CLEANERS/OUTPUT HANDLERS ## @@ -12156,7 +12175,7 @@ sub drive_data { } if ($b_admin){ if ($alerts{'smartctl'} && $alerts{'smartctl'}->{'action'} eq 'use'){ - $data = smartctl_data($data); + smartctl_data($data); } else { $smartctl_missing = $alerts{'smartctl'}->{'message'}; @@ -12294,11 +12313,10 @@ sub proc_data_advanced { } main::log_data('data',"working path: $working_path") if $b_log; if ($b_admin && -e "/sys/block/"){ - my $block = block_data($drives->[$i]{'id'}); - $drives->[$i]{'block-logical'} = $block->[0]; - $drives->[$i]{'block-physical'} = $block->[1]; + ($drives->[$i]{'block-logical'},$drives->[$i]{'block-physical'}) = @{block_data($drives->[$i]{'id'})}; } - if ($block_type && @$scsi && @by_id && ! -e "${working_path}model" && ! -e "${working_path}name"){ + if ($block_type && $scsi && @$scsi && @by_id && ! -e "${working_path}model" && + ! -e "${working_path}name"){ ## ok, ok, it's incomprehensible, search /dev/disk/by-id for a line that contains the # discovered disk name AND ends with the correct identifier, sdx # get rid of whitespace for some drive names and ids, and extra data after - in name @@ -12354,7 +12372,8 @@ sub proc_data_advanced { if ($extra > 0){ $drives->[$i]{'temp'} = hdd_temp("$drives->[$i]{'id'}"); if ($extra > 1){ - my $speed_data = device_speed($drives->[$i]{'id'}); + my $speed_data = drive_speed($drives->[$i]{'id'}); + # only assign if defined / not 0 $drives->[$i]{'speed'} = $speed_data->[0] if $speed_data->[0]; $drives->[$i]{'lanes'} = $speed_data->[1] if $speed_data->[1]; if (@$disk_data && $disk_data->[2]){ @@ -12970,7 +12989,6 @@ sub smartctl_data { } print Data::Dumper::Dumper $data if $dbg[19]; eval $end if $b_log; - return \@$data; } # check for usb/firewire/[and thunderbolt when data found] @@ -13013,29 +13031,30 @@ sub peripheral_data { sub disk_data_advanced { eval $start if $b_log; my ($set_cmd,$id) = @_; - my ($cmd,$pt,$program,@data,@return); + my ($cmd,$pt,$program,@data); + my $advanced = []; if ($set_cmd ne 'unset'){ - $return[0] = $set_cmd; + $advanced->[0] = $set_cmd; } else { # runs as user, but is SLOW: udisksctl info -b /dev/sda # line: org.freedesktop.UDisks2.PartitionTable: # Type: dos if ($program = main::check_program('udevadm')){ - $return[0] = "$program info -q property -n "; + $advanced->[0] = "$program info -q property -n "; } elsif ($b_root && -e "/lib/udev/udisks-part-id"){ - $return[0] = "/lib/udev/udisks-part-id /dev/"; + $advanced->[0] = "/lib/udev/udisks-part-id /dev/"; } elsif ($b_root && ($program = main::check_program('fdisk'))){ - $return[0] = "$program -l /dev/"; + $advanced->[0] = "$program -l /dev/"; } - if (!$return[0]){ - $return[0] = 'na' + if (!$advanced->[0]){ + $advanced->[0] = 'na' } } - if ($return[0] ne 'na'){ - $cmd = "$return[0]$id 2>&1"; + if ($advanced->[0] ne 'na'){ + $cmd = "$advanced->[0]$id 2>&1"; main::log_data('cmd',$cmd) if $b_log; @data = main::grabber($cmd); # for pre ~ 2.30 fdisk did not show gpt, but did show gpt scheme error, so @@ -13043,33 +13062,33 @@ sub disk_data_advanced { if ($cmd =~ /fdisk/){ foreach (@data){ if (/^WARNING:\s+GPT/){ - $return[1] = 'gpt'; + $advanced->[1] = 'gpt'; last; } elsif (/^Disklabel\stype:\s*(.+)/i){ - $return[1] = $1; + $advanced->[1] = $1; last; } } - $return[1] = 'dos' if !$return[1]; + $advanced->[1] = 'dos' if !$advanced->[1]; } else { foreach (@data){ if (/^(UDISKS_PARTITION_TABLE_SCHEME|ID_PART_TABLE_TYPE)/){ my @working = split('=', $_); - $return[1] = $working[1]; + $advanced->[1] = $working[1]; } elsif (/^ID_ATA_ROTATION_RATE_RPM/){ my @working = split('=', $_); - $return[2] = $working[1]; + $advanced->[2] = $working[1]; } - last if defined $return[1] && defined $return[2]; + last if defined $advanced->[1] && defined $advanced->[2]; } } - $return[1] = 'mbr' if $return[1] && lc($return[1]) eq 'dos'; + $advanced->[1] = 'mbr' if $advanced->[1] && lc($advanced->[1]) eq 'dos'; } eval $end if $b_log; - return \@return; + return $advanced; } sub scsi_data { eval $start if $b_log; @@ -13105,7 +13124,7 @@ sub disk_data_by_id { eval $start if $b_log; my ($device) = @_; my ($model,$serial,$vendor) = ('','',''); - my (@disk_data); + my $disk_data = []; foreach (@by_id){ if ($device eq Cwd::abs_path($_)){ my @data = split('_', $_); @@ -13121,12 +13140,12 @@ sub disk_data_by_id { $vendor = $result->[0] if $result->[0]; $model = $result->[1] if $result->[1]; # print $device, '::', Cwd::abs_path($_),'::', $model, '::', $vendor, '::', $serial, "\n"; - (@disk_data) = ($model,$vendor,$serial); + @$disk_data = ($model,$vendor,$serial); last; } } eval $end if $b_log; - return \@disk_data; + return $disk_data; } ## START DISK VENDOR BLOCK ## # 0 - match pattern; 1 - replace pattern; 2 - vendor print; 3 - serial pattern @@ -13771,7 +13790,6 @@ sub block_data { eval $start if $b_log; my ($id) = @_; # 0: logical block size 1: disk physical block size/partition block size; - my @blocks = (0,0); my ($block_log,$block_size) = (0,0); # my $path_size = "/sys/block/$id/size"; my $path_log_block = "/sys/block/$id/queue/logical_block_size"; @@ -13783,15 +13801,15 @@ sub block_data { $block_log = main::reader($path_log_block,'',0) if -r $path_log_block; $block_size = main::reader($path_phy_block,'',0) if -r $path_phy_block; # print "l-b: $block_log p-b: $block_size raw: $size_raw\n"; - @blocks = ($block_log,$block_size); - main::log_data('dump','@blocks',\@blocks) if $b_log; + my $blocks = [$block_log,$block_size]; + main::log_data('dump','@blocks',$blocks) if $b_log; eval $end if $b_log; - return \@blocks; + return $blocks; } -sub device_speed { +sub drive_speed { eval $start if $b_log; my ($device) = @_; - my ($b_nvme,$lanes,$speed,@data); + my ($b_nvme,$lanes,$speed); my $working = Cwd::abs_path("/sys/class/block/$device"); # print "$working\n"; if ($working){ @@ -13846,10 +13864,9 @@ sub device_speed { } } } - @data = ($speed,$lanes); # print "$working $speed\n"; eval $end if $b_log; - return \@data; + return [$speed,$lanes]; } } @@ -14127,7 +14144,7 @@ sub display_output(){ # print "$server_string\n"; } if (!$graphics{'protocol'} && !$server_string && !$graphics{'x-server'} && - !$x_drivers){ + !@$x_drivers){ $server_string = main::message('display-server'); push(@$rows,{ main::key($num++,1,1,'Display') => '', @@ -14171,7 +14188,7 @@ sub display_output(){ # note: if no xorg log, and if wayland, there will be no xorg drivers, # obviously, so we use the last driver found on the card section in that case. # those come from lscpi kernel drivers so there should be no xorg/wayland issues. - if (!$x_drivers || !$x_drivers->[0]){ + if (!@$x_drivers || !$x_drivers->[0]){ # Fallback: specific case: in Arch/Manjaro gdm run systems, their Xorg.0.log is # located inside this directory, which is not readable unless you are root # Normally Arch gdm log is here: ~/.local/share/xorg/Xorg.1.log @@ -14198,10 +14215,10 @@ sub display_output(){ else { my $gpu_drivers = gpu_drivers_sys('all'); my $note_indent = 4; - if ($gpu_drivers || $x_drivers){ + if (@$gpu_drivers || @$x_drivers){ $rows->[$j]{main::key($num++,1,2,'driver')} = ''; # The only wayland setups with x drivers have xorg, transitional that is. - if ($x_drivers){ + if (@$x_drivers){ $rows->[$j]{main::key($num++,1,3,'X')} = ''; my $driver = ($x_drivers->[0]) ? $x_drivers->[0] : 'N/A'; $rows->[$j]{main::key($num++,1,4,'loaded')} = $driver; @@ -14216,8 +14233,8 @@ sub display_output(){ } } my $drivers; - if ($gpu_drivers){ - $drivers = join(',',@{$gpu_drivers}); + if (@$gpu_drivers){ + $drivers = join(',',@$gpu_drivers); } else { $drivers = ($graphics{'gpu-drivers'}) ? join(',',@{$graphics{'gpu-drivers'}}): 'N/A'; @@ -15549,7 +15566,8 @@ sub display_protocol { sub gpu_drivers_sys { eval $start if $b_log; my ($id) = @_; - my ($driver,@drivers); + my ($driver); + my $drivers = []; # we only want list of drivers for cards with a connected monitor, and inactive # ports are already removed by the 'all' stage. foreach my $port (keys %{$monitor_ids}){ @@ -15561,20 +15579,21 @@ sub gpu_drivers_sys { } else { foreach $driver (@{$monitor_ids->{$port}{'drivers'}}){ - push(@drivers,$driver); + push(@$drivers,$driver); } } } - if (@drivers){ - @drivers = sort(@drivers); - main::uniq(\@drivers); + if (@$drivers){ + @$drivers = sort(@$drivers); + main::uniq($drivers); } eval $end if $b_log; - @drivers ? return \@drivers : return; + return $drivers; } sub display_drivers_x { eval $start if $b_log; - my ($driver,@driver_data,,%drivers); + my ($driver,%drivers); + my $driver_data = []; my ($alternate,$failed,$loaded,$sep,$unloaded) = ('','','','',''); if (my $log = $system_files{'xorg-log'}){ if ($fake{'xorg-log'}){ @@ -15666,11 +15685,11 @@ sub display_drivers_x { } } if ($loaded || $unloaded || $failed || $alternate){ - @driver_data = ($loaded,$unloaded,$failed,$alternate); + @$driver_data = ($loaded,$unloaded,$failed,$alternate); } } eval $end if $b_log; - @driver_data ? return \@driver_data : return; + return $driver_data; } ## GPU DATA ## @@ -16037,7 +16056,7 @@ sub set_nv_data { # 0008|0009|0010|0018|0019 # and these are vendor id: 10de for 73.14 # 0020|0028|0029|002c|002d|00a0|0100|0101|0103|0150|0151|0152|0153 - my $try = ($show{'gpu-data'}) ? '-try' : ''; + my $try = ($show{'gpu-data'}) ? '' : '-try'; my $status_eol = main::message('nv-legacy-eol' . $try); my $date = $self_date; $date =~ s/-\d+$//; @@ -16748,7 +16767,8 @@ sub flip_size_x_y { ## COMPOSITOR DATA ## sub set_compositor_data { eval $start if $b_log; - if (my $compositors = get_compositors()){ + my $compositors = get_compositors(); + if (@$compositors){ my @data; foreach my $compositor (@$compositors){ # gnome-shell is incredibly slow to return version @@ -16767,7 +16787,7 @@ sub set_compositor_data { } sub get_compositors { eval $start if $b_log; - my @found; + my $found = []; main::set_ps_gui() if !$loaded{'ps-gui'}; if (@ps_gui){ # ORDER MATTES! @@ -16782,13 +16802,13 @@ sub get_compositors { my $matches = join('|',@compositors) . $wl_compositors; foreach my $psg (@ps_gui){ if ($psg =~ /^($matches)$/){ - push(@found,$1); + push(@$found,$1); } } } - main::log_data('dump','compositors:', \@found) if $b_log; + main::log_data('dump','$found compositors:', $found) if $b_log; eval $end if $b_log; - (@found) ? return \@found : return; + return $found; } ## UTILITIES ## @@ -18649,7 +18669,8 @@ sub drive_output { } sub drive_data_bsd { eval $start if $b_log; - my (%drives,@rows,@temp); + my (@rows,@temp); + my $drives = {}; my ($count,$i,$working) = (0,0,''); foreach (@{$dboot{'optical'}}){ $_ =~ s/(cd[0-9]+)\(([^:]+):([0-9]+):([0-9]+)\):/$1:$2-$3.$4,/; @@ -18660,78 +18681,78 @@ sub drive_data_bsd { $working = $row[0]; } # no dots, note: ada2: 2861588MB BUT: ada2: 600.000MB/s - if (!exists $drives{$working}){ - $drives{$working}->{'links'} = []; - $drives{$working}->{'model'} = ''; - $drives{$working}->{'rev'} = ''; - $drives{$working}->{'state'} = ''; - $drives{$working}->{'vendor'} = ''; - $drives{$working}->{'temp'} = ''; - $drives{$working}->{'type'} = ($working =~ /^cd/) ? 'optical' : 'unknown'; + if (!exists $drives->{$working}){ + $drives->{$working}{'links'} = []; + $drives->{$working}{'model'} = ''; + $drives->{$working}{'rev'} = ''; + $drives->{$working}{'state'} = ''; + $drives->{$working}{'vendor'} = ''; + $drives->{$working}{'temp'} = ''; + $drives->{$working}{'type'} = ($working =~ /^cd/) ? 'optical' : 'unknown'; } # print "$_\n"; if ($bsd_type !~ /^(net|open)bsd$/){ if ($row[1] && $row[1] =~ /^<([^>]+)>/){ - $drives{$working}->{'model'} = $1; - $count = ($drives{$working}->{'model'} =~ tr/ //); + $drives->{$working}{'model'} = $1; + $count = ($drives->{$working}{'model'} =~ tr/ //); if ($count && $count > 1){ - @temp = split(/\s+/, $drives{$working}->{'model'}); - $drives{$working}->{'vendor'} = $temp[0]; + @temp = split(/\s+/, $drives->{$working}{'model'}); + $drives->{$working}{'vendor'} = $temp[0]; my $index = ($#temp > 2) ? ($#temp - 1): $#temp; - $drives{$working}->{'model'} = join(' ', @temp[1..$index]); - $drives{$working}->{'rev'} = $temp[-1] if $count > 2; + $drives->{$working}{'model'} = join(' ', @temp[1..$index]); + $drives->{$working}{'rev'} = $temp[-1] if $count > 2; } if ($show{'optical'}){ if (/\bDVD\b/){ - $drives{$working}->{'dvd'} = 1; + $drives->{$working}{'dvd'} = 1; } if (/\bRW\b/){ - $drives{$working}->{'cdrw'} = 1; - $drives{$working}->{'dvdr'} = 1 if $drives{$working}->{'dvd'}; + $drives->{$working}{'cdrw'} = 1; + $drives->{$working}{'dvdr'} = 1 if $drives->{$working}{'dvd'}; } } } if ($row[1] && $row[1] =~ /^Serial/){ @temp = split(/\s+/,$row[1]); - $drives{$working}->{'serial'} = $temp[-1]; + $drives->{$working}{'serial'} = $temp[-1]; } if ($show{'optical'}){ if ($row[1] =~ /^([0-9\.]+[MGTP][B]?\/s)/){ - $drives{$working}->{'speed'} = $1; - $drives{$working}->{'speed'} =~ s/\.[0-9]+//; + $drives->{$working}{'speed'} = $1; + $drives->{$working}{'speed'} =~ s/\.[0-9]+//; } if (/\bDVD[-]?RAM\b/){ - $drives{$working}->{'cdr'} = 1; - $drives{$working}->{'dvdram'} = 1; + $drives->{$working}{'cdr'} = 1; + $drives->{$working}{'dvdram'} = 1; } if ($row[2] && $row[2] =~ /,\s(.*)$/){ - $drives{$working}->{'state'} = $1; - $drives{$working}->{'state'} =~ s/\s+-\s+/, /; + $drives->{$working}{'state'} = $1; + $drives->{$working}{'state'} =~ s/\s+-\s+/, /; } } } else { if ($row[2] && $row[2] =~ /<([^>]+)>/){ - $drives{$working}->{'model'} = $1; - $count = ($drives{$working}->{'model'} =~ tr/,//); + $drives->{$working}{'model'} = $1; + $count = ($drives->{$working}{'model'} =~ tr/,//); # print "c: $count $row[2]\n"; if ($count && $count > 1){ - @temp = split(/,\s*/, $drives{$working}->{'model'}); - $drives{$working}->{'vendor'} = $temp[0]; - $drives{$working}->{'model'} = $temp[1]; - $drives{$working}->{'rev'} = $temp[2]; + @temp = split(/,\s*/, $drives->{$working}{'model'}); + $drives->{$working}{'vendor'} = $temp[0]; + $drives->{$working}{'model'} = $temp[1]; + $drives->{$working}{'rev'} = $temp[2]; } if ($show{'optical'}){ if (/\bDVD\b/){ - $drives{$working}->{'dvd'} = 1; + $drives->{$working}{'dvd'} = 1; } if (/\bRW\b/){ - $drives{$working}->{'cdrw'} = 1; - $drives{$working}->{'dvdr'} = 1 if $drives{$working}->{'dvd'}; + $drives->{$working}{'cdrw'} = 1; + $drives->{$working}{'dvdr'} = 1 if $drives->{$working}{'dvd'}; } if (/\bDVD[-]?RAM\b/){ - $drives{$working}->{'cdr'} = 1; - $drives{$working}->{'dvdram'} = 1; + $drives->{$working}{'cdr'} = 1; + $drives->{$working}{'dvdram'} = 1; } } } @@ -18739,19 +18760,20 @@ sub drive_data_bsd { # print "$row[1]\n"; if (($row[1] =~ tr/,//) > 1){ @temp = split(/,\s*/, $row[1]); - $drives{$working}->{'speed'} = $temp[2]; + $drives->{$working}{'speed'} = $temp[2]; } } } } - main::log_data('dump','%drives',\%drives) if $b_log; - # print Data::Dumper::Dumper \%drives; + main::log_data('dump','%$drives',$drives) if $b_log; + # print Data::Dumper::Dumper $drives; eval $end if $b_log; - return \%drives; + return $drives; } sub drive_data_linux { eval $start if $b_log; - my (@data,%drives,@info,@rows); + my (@data,@info,@rows); + my $drives = {}; @data = main::globber('/dev/dvd* /dev/cdr* /dev/scd* /dev/sr* /dev/fd[0-9]'); # Newer kernel is NOT linking all optical drives. Some, but not all. # Get the actual disk dev location, first try default which is easier to run, @@ -18763,13 +18785,13 @@ sub drive_data_linux { # possible fix: puppy has these in /mnt not /dev they say $working =~ s/\/(dev|media|mnt)\///; $_ =~ s/\/(dev|media|mnt)\///; - if (!defined $drives{$working}){ + if (!defined $drives->{$working}){ my @temp = ($_ ne $working) ? ($_) : (); - $drives{$working}->{'links'} = \@temp; - $drives{$working}->{'type'} = ($working =~ /^fd/) ? 'floppy' : 'optical' ; + $drives->{$working}{'links'} = \@temp; + $drives->{$working}{'type'} = ($working =~ /^fd/) ? 'floppy' : 'optical' ; } else { - push(@{$drives{$working}->{'links'}}, $_) if $_ ne $working; + push(@{$drives->{$working}{'links'}}, $_) if $_ ne $working; } # print "$working\n"; } @@ -18777,22 +18799,22 @@ sub drive_data_linux { @info = main::reader('/proc/sys/dev/cdrom/info','strip'); } # print join('; ', @data), "\n"; - foreach my $key (keys %drives){ - next if $drives{$key}->{'type'} eq 'floppy'; + foreach my $key (keys %$drives){ + next if $drives->{$key}{'type'} eq 'floppy'; my $device = "/sys/block/$key/device"; if (-d $device){ if (-r "$device/vendor"){ - $drives{$key}->{'vendor'} = main::reader("$device/vendor",'',0); - $drives{$key}->{'vendor'} = main::clean($drives{$key}->{'vendor'}); - $drives{$key}->{'state'} = main::reader("$device/state",'',0); - $drives{$key}->{'model'} = main::reader("$device/model",'',0); - $drives{$key}->{'model'} = main::clean($drives{$key}->{'model'}); - $drives{$key}->{'rev'} = main::reader("$device/rev",'',0); + $drives->{$key}{'vendor'} = main::reader("$device/vendor",'',0); + $drives->{$key}{'vendor'} = main::clean($drives->{$key}{'vendor'}); + $drives->{$key}{'state'} = main::reader("$device/state",'',0); + $drives->{$key}{'model'} = main::reader("$device/model",'',0); + $drives->{$key}{'model'} = main::clean($drives->{$key}{'model'}); + $drives->{$key}{'rev'} = main::reader("$device/rev",'',0); } } elsif (-r "/proc/ide/$key/model"){ - $drives{$key}->{'vendor'} = main::reader("/proc/ide/$key/model",'',0); - $drives{$key}->{'vendor'} = main::clean($drives{$key}->{'vendor'}); + $drives->{$key}{'vendor'} = main::reader("/proc/ide/$key/model",'',0); + $drives->{$key}{'vendor'} = main::clean($drives->{$key}{'vendor'}); } if ($show{'optical'} && @info){ my $index = 0; @@ -18807,39 +18829,39 @@ sub drive_data_linux { last if !$index; # index will be > 0 if it was found } elsif ($item =~/^drive speed:/){ - $drives{$key}->{'speed'} = $split[$index]; + $drives->{$key}{'speed'} = $split[$index]; } elsif ($item =~/^Can read multisession:/){ - $drives{$key}->{'multisession'}=$split[$index+1]; + $drives->{$key}{'multisession'}=$split[$index+1]; } elsif ($item =~/^Can read MCN:/){ - $drives{$key}->{'mcn'}=$split[$index+1]; + $drives->{$key}{'mcn'}=$split[$index+1]; } elsif ($item =~/^Can play audio:/){ - $drives{$key}->{'audio'}=$split[$index+1]; + $drives->{$key}{'audio'}=$split[$index+1]; } elsif ($item =~/^Can write CD-R:/){ - $drives{$key}->{'cdr'}=$split[$index+1]; + $drives->{$key}{'cdr'}=$split[$index+1]; } elsif ($item =~/^Can write CD-RW:/){ - $drives{$key}->{'cdrw'}=$split[$index+1]; + $drives->{$key}{'cdrw'}=$split[$index+1]; } elsif ($item =~/^Can read DVD:/){ - $drives{$key}->{'dvd'}=$split[$index+1]; + $drives->{$key}{'dvd'}=$split[$index+1]; } elsif ($item =~/^Can write DVD-R:/){ - $drives{$key}->{'dvdr'}=$split[$index+1]; + $drives->{$key}{'dvdr'}=$split[$index+1]; } elsif ($item =~/^Can write DVD-RAM:/){ - $drives{$key}->{'dvdram'}=$split[$index+1]; + $drives->{$key}{'dvdram'}=$split[$index+1]; } } } } - main::log_data('dump','%drives',\%drives) if $b_log; - # print Data::Dumper::Dumper \%drives; + main::log_data('dump','%$drives',$drives) if $b_log; + # print Data::Dumper::Dumper $drives; eval $end if $b_log; - return \%drives; + return $drives; } } @@ -23986,7 +24008,7 @@ sub get { slot_data_sys(); } $data = slot_data_dmi(); - slot_output($rows,$data) if $data; + slot_output($rows,$data) if @$data; if (!@$rows){ my $key = 'Message'; push(@$rows, { @@ -24090,7 +24112,7 @@ sub children_output { sub slot_data_dmi { eval $start if $b_log; my $i = 0; - my @slots; + my $slots = []; foreach my $slot_data (@dmi){ next if $slot_data->[0] != 9; my (%data,@extra); @@ -24191,12 +24213,12 @@ sub slot_data_dmi { @extra = grep {$_ ne $data{'pci'}} @extra; } $data{'extra'} = [@extra] if @extra; - push(@slots,{%data}) if %data; + push(@$slots,{%data}) if %data; } - print '@slots: ', Data::Dumper::Dumper \@slots if $dbg[48]; - main::log_data('dump','@slots final',\@slots) if $b_log; + print '@$slots: ', Data::Dumper::Dumper $slots if $dbg[48]; + main::log_data('dump','@$slots final',$slots) if $b_log; eval $end if $b_log; - return \@slots if @slots; + return $slots; } sub slot_data_sys { eval $start if $b_log; @@ -24490,7 +24512,8 @@ sub create_output { } sub proc_data { eval $start if $b_log; - my ($dev_mapped,$fs,$label,$maj_min,$size,$uuid,$part,@unmounted); + my ($dev_mapped,$fs,$label,$maj_min,$size,$uuid,$part); + my $unmounted = []; # last filters to make sure these are dumped my @filters = ('scd[0-9]+','sr[0-9]+','cdrom[0-9]*','cdrw[0-9]*', 'dvd[0-9]*','dvdrw[0-9]*','fd[0-9]','ram[0-9]*'); @@ -24552,7 +24575,7 @@ sub proc_data { $uuid = $temp[2] if $temp[2]; } $maj_min = "$row->[0]:$row->[1]" if !$maj_min; - push(@unmounted, { + push(@$unmounted, { 'dev-base' => $row->[-1], 'dev-mapped' => $dev_mapped, 'fs' => $fs, @@ -24563,14 +24586,15 @@ sub proc_data { }); } } - print Data::Dumper::Dumper \@unmounted if $dbg[35]; - main::log_data('dump','@unmounted',\@unmounted) if $b_log; + print Data::Dumper::Dumper $unmounted if $dbg[35]; + main::log_data('dump','@$unmounted',$unmounted) if $b_log; eval $end if $b_log; - return \@unmounted; + return $unmounted; } sub bsd_data { eval $start if $b_log; - my ($fs,$label,$size,$uuid,%part,@unmounted); + my ($fs,$label,$size,$uuid,%part); + my $unmounted = []; PartitionItem::set_partitions() if !$loaded{'set-partitions'}; RaidItem::raid_data() if !$loaded{'raid'}; my $mounted = get_mounted(); @@ -24584,7 +24608,7 @@ sub bsd_data { $size = $disks_bsd{$id}->{'partitions'}{$part}{'size'}; $uuid = $disks_bsd{$id}->{'partitions'}{$part}{'uuid'}; # $fs = unmounted_filesystem($part) if !$fs; - push(@unmounted, { + push(@$unmounted, { 'dev-base' => $part, 'dev-mapped' => '', 'fs' => $fs, @@ -24596,21 +24620,22 @@ sub bsd_data { } } } - print Data::Dumper::Dumper \@unmounted if $dbg[35]; - main::log_data('dump','@unmounted',\@unmounted) if $b_log; + print Data::Dumper::Dumper $unmounted if $dbg[35]; + main::log_data('dump','@$unmounted',$unmounted) if $b_log; eval $end if $b_log; - return \@unmounted; + return $unmounted; } sub get_mounted { eval $start if $b_log; - my (@arrays,@mounted); + my (@arrays); + my $mounted = []; foreach my $row (@partitions){ - push(@mounted, $row->{'dev-base'}) if $row->{'dev-base'}; + push(@$mounted, $row->{'dev-base'}) if $row->{'dev-base'}; } # print Data::Dumper::Dumper \@zfs_raid; foreach my $row ((@btrfs_raid,@lvm_raid,@md_raid,@soft_raid,@zfs_raid)){ # we want to not show md0 etc in unmounted report - push(@mounted, $row->{'id'}) if $row->{'id'}; + push(@$mounted, $row->{'id'}) if $row->{'id'}; # print Data::Dumper::Dumper $row; # row->arrays->components: zfs; row->components: lvm,mdraid,softraid if ($row->{'arrays'} && ref $row->{'arrays'} eq 'ARRAY'){ @@ -24627,12 +24652,12 @@ sub get_mounted { foreach my $component (@components){ # md has ~, not zfs,lvm,softraid my $temp = (split('~', $component->[0]))[0]; - push(@mounted, $temp); + push(@$mounted, $temp); } } } eval $end if $b_log; - return \@mounted; + return $mounted; } # bsds do not seem to return any useful data so only for linux sub unmounted_filesystem { @@ -25081,7 +25106,8 @@ sub get_weather { eval $start if $b_log; my ($location) = @_; my $now = POSIX::strftime "%Y%m%d%H%M", localtime; - my ($date_time,$freshness,$tz,$weather_data,%weather); + my ($date_time,$freshness,$tz,$weather_data); + my $weather = {}; my $loc_name = lc($location->[0]); $loc_name =~ s/-\/|\s|,/-/g; $loc_name =~ s/--/-/g; @@ -25100,236 +25126,237 @@ sub get_weather { my @working = split(/\s*\^\^\s*/, $_); next if ! defined $working[1] || $working[1] eq ''; if ($working[0] eq 'api_source'){ - $weather{'api-source'} = $working[1]; + $weather->{'api-source'} = $working[1]; } elsif ($working[0] eq 'city'){ - $weather{'city'} = $working[1]; + $weather->{'city'} = $working[1]; } elsif ($working[0] eq 'cloud_cover'){ - $weather{'cloud-cover'} = $working[1]; + $weather->{'cloud-cover'} = $working[1]; } elsif ($working[0] eq 'country'){ - $weather{'country'} = $working[1]; + $weather->{'country'} = $working[1]; } elsif ($working[0] eq 'dewpoint_string'){ - $weather{'dewpoint'} = $working[1]; + $weather->{'dewpoint'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; - $weather{'dewpoint-c'} = $2;; - $weather{'dewpoint-f'} = $1;; + $weather->{'dewpoint-c'} = $2;; + $weather->{'dewpoint-f'} = $1;; } elsif ($working[0] eq 'dewpoint_c'){ - $weather{'dewpoint-c'} = $working[1]; + $weather->{'dewpoint-c'} = $working[1]; } elsif ($working[0] eq 'dewpoint_f'){ - $weather{'dewpoint-f'} = $working[1]; + $weather->{'dewpoint-f'} = $working[1]; } # WU: there are two elevations, we want the first one - elsif (!$weather{'elevation-m'} && $working[0] eq 'elevation'){ + elsif (!$weather->{'elevation-m'} && $working[0] eq 'elevation'){ # note: bug in source data uses ft for meters, not 100% of time, but usually - $weather{'elevation-m'} = $working[1]; - $weather{'elevation-m'} =~ s/\s*(ft|m).*$//; + $weather->{'elevation-m'} = $working[1]; + $weather->{'elevation-m'} =~ s/\s*(ft|m).*$//; } elsif ($working[0] eq 'error'){ - $weather{'error'} = $working[1]; + $weather->{'error'} = $working[1]; } elsif ($working[0] eq 'forecast'){ - $weather{'forecast'} = $working[1]; + $weather->{'forecast'} = $working[1]; } elsif ($working[0] eq 'heat_index_string'){ - $weather{'heat-index'} = $working[1]; + $weather->{'heat-index'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; - $weather{'heat-index-c'} = $2;; - $weather{'heat-index-f'} = $1; + $weather->{'heat-index-c'} = $2;; + $weather->{'heat-index-f'} = $1; } elsif ($working[0] eq 'heat_index_c'){ - $weather{'heat-index-c'} = $working[1]; + $weather->{'heat-index-c'} = $working[1]; } elsif ($working[0] eq 'heat_index_f'){ - $weather{'heat-index-f'} = $working[1]; + $weather->{'heat-index-f'} = $working[1]; } elsif ($working[0] eq 'relative_humidity'){ $working[1] =~ s/%$//; - $weather{'humidity'} = $working[1]; + $weather->{'humidity'} = $working[1]; } elsif ($working[0] eq 'local_time'){ - $weather{'local-time'} = $working[1]; + $weather->{'local-time'} = $working[1]; } elsif ($working[0] eq 'local_epoch'){ - $weather{'local-epoch'} = $working[1]; + $weather->{'local-epoch'} = $working[1]; } elsif ($working[0] eq 'moonphase'){ - $weather{'moonphase'} = $working[1]; + $weather->{'moonphase'} = $working[1]; } elsif ($working[0] eq 'moonphase_graphic'){ - $weather{'moonphase-graphic'} = $working[1]; + $weather->{'moonphase-graphic'} = $working[1]; } elsif ($working[0] eq 'observation_time_rfc822'){ - $weather{'observation-time-rfc822'} = $working[1]; + $weather->{'observation-time-rfc822'} = $working[1]; } elsif ($working[0] eq 'observation_epoch'){ - $weather{'observation-epoch'} = $working[1]; + $weather->{'observation-epoch'} = $working[1]; } elsif ($working[0] eq 'observation_time'){ - $weather{'observation-time-local'} = $working[1]; - $weather{'observation-time-local'} =~ s/Last Updated on //; + $weather->{'observation-time-local'} = $working[1]; + $weather->{'observation-time-local'} =~ s/Last Updated on //; } elsif ($working[0] eq 'precip_mm'){ - $weather{'precip-1h-mm'} = $working[1]; + $weather->{'precip-1h-mm'} = $working[1]; } elsif ($working[0] eq 'precip_in'){ - $weather{'precip-1h-in'} = $working[1]; + $weather->{'precip-1h-in'} = $working[1]; } elsif ($working[0] eq 'pressure_string'){ - $weather{'pressure'} = $working[1]; + $weather->{'pressure'} = $working[1]; } elsif ($working[0] eq 'pressure_mb'){ - $weather{'pressure-mb'} = $working[1]; + $weather->{'pressure-mb'} = $working[1]; } elsif ($working[0] eq 'pressure_in'){ - $weather{'pressure-in'} = $working[1]; + $weather->{'pressure-in'} = $working[1]; } elsif ($working[0] eq 'rain_1h_mm'){ - $weather{'rain-1h-mm'} = $working[1]; + $weather->{'rain-1h-mm'} = $working[1]; } elsif ($working[0] eq 'rain_1h_in'){ - $weather{'rain-1h-in'} = $working[1]; + $weather->{'rain-1h-in'} = $working[1]; } elsif ($working[0] eq 'snow_1h_mm'){ - $weather{'snow-1h-mm'} = $working[1]; + $weather->{'snow-1h-mm'} = $working[1]; } elsif ($working[0] eq 'snow_1h_in'){ - $weather{'snow-1h-in'} = $working[1]; + $weather->{'snow-1h-in'} = $working[1]; } elsif ($working[0] eq 'state_name'){ - $weather{'state'} = $working[1]; + $weather->{'state'} = $working[1]; } elsif ($working[0] eq 'sunrise'){ if ($working[1]){ if ($working[1] !~ /^[0-9]+$/){ - $weather{'sunrise'} = $working[1]; + $weather->{'sunrise'} = $working[1]; } # trying to figure out remote time from UTC is too hard elsif (!$show{'weather-location'}){ - $weather{'sunrise'} = POSIX::strftime "%T", localtime($working[1]); + $weather->{'sunrise'} = POSIX::strftime "%T", localtime($working[1]); } } } elsif ($working[0] eq 'sunset'){ if ($working[1]){ if ($working[1] !~ /^[0-9]+$/){ - $weather{'sunset'} = $working[1]; + $weather->{'sunset'} = $working[1]; } # trying to figure out remote time from UTC is too hard elsif (!$show{'weather-location'}){ - $weather{'sunset'} = POSIX::strftime "%T", localtime($working[1]); + $weather->{'sunset'} = POSIX::strftime "%T", localtime($working[1]); } } } elsif ($working[0] eq 'temperature_string'){ - $weather{'temp'} = $working[1]; + $weather->{'temp'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; - $weather{'temp-c'} = $2;; - $weather{'temp-f'} = $1; -# $weather{'temp'} =~ s/\sF/\xB0 F/; # B0 -# $weather{'temp'} =~ s/\sF/\x{2109}/; -# $weather{'temp'} =~ s/\sC/\x{2103}/; + $weather->{'temp-c'} = $2;; + $weather->{'temp-f'} = $1; +# $weather->{'temp'} =~ s/\sF/\xB0 F/; # B0 +# $weather->{'temp'} =~ s/\sF/\x{2109}/; +# $weather->{'temp'} =~ s/\sC/\x{2103}/; } elsif ($working[0] eq 'temp_f'){ - $weather{'temp-f'} = $working[1]; + $weather->{'temp-f'} = $working[1]; } elsif ($working[0] eq 'temp_c'){ - $weather{'temp-c'} = $working[1]; + $weather->{'temp-c'} = $working[1]; } elsif ($working[0] eq 'timezone'){ - $weather{'timezone'} = $working[1]; + $weather->{'timezone'} = $working[1]; } elsif ($working[0] eq 'visibility'){ - $weather{'visibility'} = $working[1]; + $weather->{'visibility'} = $working[1]; } elsif ($working[0] eq 'visibility_km'){ - $weather{'visibility-km'} = $working[1]; + $weather->{'visibility-km'} = $working[1]; } elsif ($working[0] eq 'visibility_mi'){ - $weather{'visibility-mi'} = $working[1]; + $weather->{'visibility-mi'} = $working[1]; } elsif ($working[0] eq 'weather'){ - $weather{'weather'} = $working[1]; + $weather->{'weather'} = $working[1]; } elsif ($working[0] eq 'wind_degrees'){ - $weather{'wind-degrees'} = $working[1]; + $weather->{'wind-degrees'} = $working[1]; } elsif ($working[0] eq 'wind_dir'){ - $weather{'wind-direction'} = $working[1]; + $weather->{'wind-direction'} = $working[1]; } elsif ($working[0] eq 'wind_mph'){ - $weather{'wind-mph'} = $working[1]; + $weather->{'wind-mph'} = $working[1]; } elsif ($working[0] eq 'wind_gust_mph'){ - $weather{'wind-gust-mph'} = $working[1]; + $weather->{'wind-gust-mph'} = $working[1]; } elsif ($working[0] eq 'wind_gust_ms'){ - $weather{'wind-gust-ms'} = $working[1]; + $weather->{'wind-gust-ms'} = $working[1]; } elsif ($working[0] eq 'wind_ms'){ - $weather{'wind-ms'} = $working[1]; + $weather->{'wind-ms'} = $working[1]; } elsif ($working[0] eq 'wind_string'){ - $weather{'wind'} = $working[1]; + $weather->{'wind'} = $working[1]; } elsif ($working[0] eq 'windchill_string'){ - $weather{'windchill'} = $working[1]; + $weather->{'windchill'} = $working[1]; $working[1] =~ /^([0-9\.]+)\sF\s\(([0-9\.]+)\sC\)/; - $weather{'windchill-c'} = $2; - $weather{'windchill-f'} = $1; + $weather->{'windchill-c'} = $2; + $weather->{'windchill-f'} = $1; } elsif ($working[0] eq 'windchill_c'){ - $weather{'windchill-c'} = $working[1]; + $weather->{'windchill-c'} = $working[1]; } elsif ($working[0] eq 'windchill_f'){ - $weather{'windchill_f'} = $working[1]; + $weather->{'windchill_f'} = $working[1]; } } if ($show{'weather-location'}){ - if ($weather{'observation-time-local'} && - $weather{'observation-time-local'} =~ /^(.*)\s([a-z_]+\/[a-z_]+)$/i){ + if ($weather->{'observation-time-local'} && + $weather->{'observation-time-local'} =~ /^(.*)\s([a-z_]+\/[a-z_]+)$/i){ $tz = $2; } - if (!$tz && $weather{'timezone'}){ - $tz = $weather{'timezone'}; - $weather{'observation-time-local'} .= ' (' . $weather{'timezone'} . ')' if $weather{'observation-time-local'}; + if (!$tz && $weather->{'timezone'}){ + $tz = $weather->{'timezone'}; + $weather->{'observation-time-local'} .= ' (' . $weather->{'timezone'} . ')' if $weather->{'observation-time-local'}; } # very clever trick, just make the system think it's in the # remote timezone for this local block only local $ENV{'TZ'} = $tz if $tz; $date_time = POSIX::strftime "%c", localtime(); $date_time = test_locale_date($date_time,'',''); - $weather{'date-time'} = $date_time; + $weather->{'date-time'} = $date_time; # only wu has rfc822 value, and we want the original observation time then - if ($weather{'observation-epoch'} && $tz){ - $date_time = POSIX::strftime "%Y-%m-%d %T ($tz %z)", localtime($weather{'observation-epoch'}); - $date_time = test_locale_date($date_time,$show{'weather-location'},$weather{'observation-epoch'}); - $weather{'observation-time-local'} = $date_time; + if ($weather->{'observation-epoch'} && $tz){ + $date_time = POSIX::strftime "%Y-%m-%d %T ($tz %z)", localtime($weather->{'observation-epoch'}); + $date_time = test_locale_date($date_time,$show{'weather-location'},$weather->{'observation-epoch'}); + $weather->{'observation-time-local'} = $date_time; } } else { $date_time = POSIX::strftime "%c", localtime(); $date_time = test_locale_date($date_time,'',''); $tz = ($location->[2]) ? " ($location->[2])" : ''; - $weather{'date-time'} = $date_time . $tz; + $weather->{'date-time'} = $date_time . $tz; } # we get the wrong time using epoch for remote -W location - if (!$show{'weather-location'} && $weather{'observation-epoch'}){ - $date_time = POSIX::strftime "%c", localtime($weather{'observation-epoch'}); - $date_time = test_locale_date($date_time,$show{'weather-location'},$weather{'observation-epoch'}); - $weather{'observation-time-local'} = $date_time; + if (!$show{'weather-location'} && $weather->{'observation-epoch'}){ + $date_time = POSIX::strftime "%c", localtime($weather->{'observation-epoch'}); + $date_time = test_locale_date($date_time,$show{'weather-location'},$weather->{'observation-epoch'}); + $weather->{'observation-time-local'} = $date_time; } eval $end if $b_log; - return \%weather; + return $weather; } sub download_weather { eval $start if $b_log; my ($now,$file_cached,$location) = @_; - my (@weather,$temp,$ua,$url); + my ($temp,$ua,$url); + my $weather = []; $url = "https://smxi.org/opt/xr2.php?loc=$location->[0]&src=$weather_source"; $ua = 'weather'; if ($fake{'weather'}){ @@ -25343,12 +25370,12 @@ sub download_weather { else { $temp = main::download_file('stdout',$url,'',$ua); } - @weather = split('\n', $temp) if $temp; - unshift(@weather, "timestamp^^$now"); - main::writer($file_cached,\@weather); + @$weather = split('\n', $temp) if $temp; + unshift(@$weather, "timestamp^^$now"); + main::writer($file_cached,$weather); # print "$file_cached: download/cleaned\n"; eval $end if $b_log; - return \@weather; + return $weather; } # resolve wide character issue, if detected, switch to iso # date format, we won't try to be too clever here. @@ -26828,7 +26855,8 @@ sub pcictl_data { sub pci_grabber { eval $start if $b_log; my ($program) = @_; - my ($args,$path,$pattern,$data,@working); + my ($args,$path,$pattern,$data); + my $working = []; if ($program eq 'lspci'){ # 2.2.8 lspci did not support -k, added in 2.2.9, but -v turned on -k $args = ' -nnv'; @@ -26875,15 +26903,15 @@ sub pci_grabber { foreach (@$data){ # this is the group separator and assign trigger if ($_ =~ /$pattern/i){ - push(@working, '~'); + push(@$working, '~'); } - push(@working, $_); + push(@$working, $_); } - push(@working, '~'); + push(@$working, '~'); } - print Data::Dumper::Dumper \@working if $dbg[30]; + print Data::Dumper::Dumper $working if $dbg[30]; eval $end if $b_log; - return \@working; + return $working; } sub soc_data { @@ -27518,7 +27546,8 @@ sub set_gpart_data { sub get_display_manager { eval $start if $b_log; - my (@data,@found,@glob,$link,$path,@temp); + my (@data,@glob,$link,$path,@temp); + my $found = []; # ldm - LTSP display manager. Note that sddm does not appear to have a .pid # extension in Arch. Guessing on cdm, qingy. pcdm uses vt, PCDM-vt9.pid # Not verified: qingy emptty; greetd.run verified, but alternate: @@ -27526,8 +27555,8 @@ sub get_display_manager { # greetd frontends: agreety dlm gtkgreet qtgreet tuigreet wlgreet # mlogin may be mlogind, not verified my @dms = qw(brzdm cdm clogin emptty entranced gdm gdm3 greetd kdm kdm3 ldm - lightdm lxdm ly mdm mlogin nodm pcdm qingy sddm slim tbsm tdm udm wdm xdm - xenodm xlogin); + lightdm lxdm ly mdm mlogin nodm pcdm qingy sddm slim slimski tbsm tdm udm wdm + xdm xenodm xlogin); # these are the only one I know of so far that have version info. xlogin / # clogin do, -V, brzdm -v, but syntax not verified. my @dms_version = qw(gdm gdm3 lightdm ly slim); @@ -27584,29 +27613,29 @@ sub get_display_manager { if (scalar @dms > 1 && (my $temp = ServiceData::get('status',$dm))){ $dm_info[2] = message('stopped') if $temp && $temp =~ /stopped|disabled/; } - push(@found,[@dm_info]); + push(@$found,[@dm_info]); } - if (!@found){ + if (!@$found){ # ly does not have a run/pid file if (grep {$_ eq 'ly'} @ps_gui){ @data = program_data('ly','ly',3); $dm_info[0] = $data[0]; $dm_info[1] = $data[1]; - $found[0] = [@dm_info]; + $found->[0] = [@dm_info]; } elsif (grep {/startx$/} @ps_gui){ - $found[0] = ['startx']; + $found->[0] = ['startx']; } elsif (grep {$_ eq 'xinit'} @ps_gui){ - $found[0] = ['xinit']; + $found->[0] = ['xinit']; } } # might add this in, but the rate of new dm's makes it more likely it's an # unknown dm, so we'll keep output to N/A # print Data::Dumper::Dumper \@found; - log_data('dump','display manager: @found',\@found) if $b_log; + log_data('dump','display manager: @$found',$found) if $b_log; eval $end if $b_log; - return \@found if @found; + return $found; } ## DistroData @@ -28760,25 +28789,25 @@ sub get_kernel_bits { sub get_kernel_data { eval $start if $b_log; my ($ksplice) = (''); - my @kernel; + my $kernel = []; # Linux; yawn; 4.9.0-3.1-liquorix-686-pae; #1 ZEN SMP PREEMPT liquorix 4.9-4 (2017-01-14); i686 # FreeBSD; siwi.pair.com; 8.2-STABLE; FreeBSD 8.2-STABLE #0: Tue May 31 14:36:14 EDT 2016 erik5@iddhi.pair.com:/usr/obj/usr/src/sys/82PAIRx-AMD64; amd64 if (@uname){ - $kernel[0] = $uname[2]; - if ((my $program = check_program('uptrack-uname')) && $kernel[0]){ + $kernel->[0] = $uname[2]; + if ((my $program = check_program('uptrack-uname')) && $kernel->[0]){ $ksplice = qx($program -rm); $ksplice = trimmer($ksplice); - $kernel[0] = $ksplice . ' (ksplice)' if $ksplice; + $kernel->[0] = $ksplice . ' (ksplice)' if $ksplice; } - $kernel[1] = $uname[-1]; + $kernel->[1] = $uname[-1]; } # we want these to have values to save validation checks for output - $kernel[0] ||= 'N/A'; - $kernel[1] ||= 'N/A'; - log_data('data',"kernel: " . join('; ', @kernel) . " ksplice: $ksplice") if $b_log; + $kernel->[0] ||= 'N/A'; + $kernel->[1] ||= 'N/A'; + log_data('data',"kernel: " . join('; ', $kernel) . " ksplice: $ksplice") if $b_log; log_data('dump','perl @uname', \@uname) if $b_log; eval $end if $b_log; - return \@kernel; + return $kernel; } ## KernelParameters @@ -32150,16 +32179,16 @@ sub info_item{ $b_gcc = 1; } $gcc ||= 'N/A'; - my %data = ( + my $data = { $data_name => [{ main::key($num++,0,1,'Processes') => scalar @ps_aux, main::key($num++,1,1,'Uptime') => main::get_uptime(), },], - ); - $index = scalar(@{$data{$data_name}}) - 1; + }; + $index = scalar(@{$data->{$data_name}}) - 1; if ($extra > 2){ my $wakeups = main::get_wakeups(); - $data{$data_name}->[$index]{main::key($num++,0,2,'wakeups')} = $wakeups if defined $wakeups; + $data->{$data_name}[$index]{main::key($num++,0,2,'wakeups')} = $wakeups if defined $wakeups; } if (!$loaded{'memory'}){ my $memory = MemoryData::get('splits'); @@ -32173,36 +32202,36 @@ sub info_item{ $gpu_ram = main::get_size($gpu_ram,'string'); } } - $data{$data_name}->[$index]{main::key($num++,1,1,'Memory')} = $total; - $data{$data_name}->[$index]{main::key($num++,0,2,'used')} = $used; + $data->{$data_name}[$index]{main::key($num++,1,1,'Memory')} = $total; + $data->{$data_name}[$index]{main::key($num++,0,2,'used')} = $used; } if ($gpu_ram){ - $data{$data_name}->[$index]{main::key($num++,0,2,'gpu')} = $gpu_ram; + $data->{$data_name}[$index]{main::key($num++,0,2,'gpu')} = $gpu_ram; } if ((!$b_display || $force{'display'}) || $extra > 0){ my $init = main::get_init_data(); my $init_type = ($init->{'init-type'}) ? $init->{'init-type'}: 'N/A'; - $data{$data_name}->[$index]{main::key($num++,1,1,'Init')} = $init_type; + $data->{$data_name}[$index]{main::key($num++,1,1,'Init')} = $init_type; if ($extra > 1){ my $init_version = ($init->{'init-version'}) ? $init->{'init-version'}: 'N/A'; - $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $init_version; + $data->{$data_name}[$index]{main::key($num++,0,2,'v')} = $init_version; } if ($init->{'rc-type'}){ - $data{$data_name}->[$index]{main::key($num++,1,2,'rc')} = $init->{'rc-type'}; + $data->{$data_name}[$index]{main::key($num++,1,2,'rc')} = $init->{'rc-type'}; if ($init->{'rc-version'}){ - $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $init->{'rc-version'}; + $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $init->{'rc-version'}; } } if ($init->{'runlevel'}){ my $key = ($init->{'init-type'} && $init->{'init-type'} eq 'systemd') ? 'target' : 'runlevel'; - $data{$data_name}->[$index]{main::key($num++,1,2,$key)} = $init->{'runlevel'}; + $data->{$data_name}[$index]{main::key($num++,1,2,$key)} = $init->{'runlevel'}; } if ($extra > 1){ if ($init->{'default'}){ - $data{$data_name}->[$index]{main::key($num++,0,3,'default')} = $init->{'default'}; + $data->{$data_name}[$index]{main::key($num++,0,3,'default')} = $init->{'default'}; } if ($b_admin && (my $tool = ServiceData::get('tool',''))){ - $data{$data_name}->[$index]{main::key($num++,0,2,'tool')} = $tool; + $data->{$data_name}[$index]{main::key($num++,0,2,'tool')} = $tool; undef %service_tool; } } @@ -32216,21 +32245,21 @@ sub info_item{ $b_clang = 1; } my $compiler = ($b_gcc || $b_clang) ? '': 'N/A'; - $data{$data_name}->[$index]{main::key($num++,1,1,'Compilers')} = $compiler; + $data->{$data_name}[$index]{main::key($num++,1,1,'Compilers')} = $compiler; if ($b_gcc){ - $data{$data_name}->[$index]{main::key($num++,1,2,'gcc')} = $gcc; + $data->{$data_name}[$index]{main::key($num++,1,2,'gcc')} = $gcc; if ($extra > 1 && $gcc_alt){ - $data{$data_name}->[$index]{main::key($num++,0,3,'alt')} = $gcc_alt; + $data->{$data_name}[$index]{main::key($num++,0,3,'alt')} = $gcc_alt; } } if ($b_clang){ - $data{$data_name}->[$index]{main::key($num++,0,2,'clang')} = $clang_version; + $data->{$data_name}[$index]{main::key($num++,0,2,'clang')} = $clang_version; } } if ($extra > 0 && !$loaded{'package-data'}){ my $packages = PackageData::get('inner',\$num); for (keys %$packages){ - $data{$data_name}->[$index]{$_} = $packages->{$_}; + $data->{$data_name}[$index]{$_} = $packages->{$_}; } } if (!$loaded{'shell-data'} && $ppid && (!$b_irc || !$client{'name-print'})){ @@ -32266,22 +32295,22 @@ sub info_item{ $client .= " ($client{'su-start'})"; } } - $data{$data_name}->[$index]{main::key($num++,1,1,$client_shell)} = $client; + $data->{$data_name}[$index]{main::key($num++,1,1,$client_shell)} = $client; if ($extra > 0 && $client{'version'}){ - $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $client{'version'}; + $data->{$data_name}[$index]{main::key($num++,0,2,'v')} = $client{'version'}; } if (!$b_irc){ if ($extra > 2 && $client{'default-shell'}){ - $data{$data_name}->[$index]{main::key($num++,1,2,'default')} = $client{'default-shell'}; - $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $client{'default-shell-v'} if $client{'default-shell-v'}; + $data->{$data_name}[$index]{main::key($num++,1,2,'default')} = $client{'default-shell'}; + $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $client{'default-shell-v'} if $client{'default-shell-v'}; } if ($running_in){ - $data{$data_name}->[$index]{main::key($num++,0,2,'running-in')} = $running_in; + $data->{$data_name}[$index]{main::key($num++,0,2,'running-in')} = $running_in; } } - $data{$data_name}->[$index]{main::key($num++,0,1,$self_name)} = main::get_self_version(); + $data->{$data_name}[$index]{main::key($num++,0,1,$self_name)} = main::get_self_version(); eval $end if $b_log; - return \%data; + return $data; } sub system_item { eval $start if $b_log; @@ -32290,27 +32319,27 @@ sub system_item { my $data_name = main::key($prefix++,1,0,'System'); my ($desktop,$desktop_info,$desktop_key,$dm_key,$toolkit,$wm) = ('','','Desktop','dm','',''); my (@desktop_data,$desktop_version,$tk_version,$wm_version); - my %data = ( + my $data = { $data_name => [{}], - ); - $index = scalar(@{$data{$data_name}}) - 1; + }; + $index = scalar(@{$data->{$data_name}}) - 1; if ($show{'host'}){ - $data{$data_name}->[$index]{main::key($num++,0,1,'Host')} = main::get_hostname(); + $data->{$data_name}[$index]{main::key($num++,0,1,'Host')} = main::get_hostname(); } my $kernel_data = main::get_kernel_data(); - $data{$data_name}->[$index]{main::key($num++,1,1,'Kernel')} = $kernel_data->[0]; - $data{$data_name}->[$index]{main::key($num++,0,2,'arch')} = $kernel_data->[1]; - $data{$data_name}->[$index]{main::key($num++,0,2,'bits')} = main::get_kernel_bits(); + $data->{$data_name}[$index]{main::key($num++,1,1,'Kernel')} = $kernel_data->[0]; + $data->{$data_name}[$index]{main::key($num++,0,2,'arch')} = $kernel_data->[1]; + $data->{$data_name}[$index]{main::key($num++,0,2,'bits')} = main::get_kernel_bits(); if ($extra > 0){ my $compiler = CompilerVersion::get(); # get compiler data if (scalar @$compiler != 2){ @$compiler = ('N/A', ''); } - $data{$data_name}->[$index]{main::key($num++,1,2,'compiler')} = $compiler->[0]; + $data->{$data_name}[$index]{main::key($num++,1,2,'compiler')} = $compiler->[0]; # if no compiler, obviously no version, so don't waste space showing. if ($compiler->[0] ne 'N/A'){ $compiler->[1] ||= 'N/A'; - $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $compiler->[1]; + $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $compiler->[1]; } } if ($b_admin && (my $params = KernelParameters::get())){ @@ -32322,8 +32351,8 @@ sub system_item { if ($use{'filter-uuid'}){ $params = main::filter_partition('system', $params, 'uuid'); } - $data{$data_name}->[$index]{main::key($num++,0,2,'parameters')} = $params; - $index = scalar(@{$data{$data_name}}); + $data->{$data_name}[$index]{main::key($num++,0,2,'parameters')} = $params; + $index = scalar(@{$data->{$data_name}}); } # note: tty can have the value of 0 but the two tools # return '' if undefined, so we test for explicit '' @@ -32373,53 +32402,53 @@ sub system_item { $cont_desk = 0; } $desktop ||= 'N/A'; - $data{$data_name}->[$index]{main::key($num++,$cont_desk,1,$desktop_key)} = $desktop; + $data->{$data_name}[$index]{main::key($num++,$cont_desk,1,$desktop_key)} = $desktop; if ($desktop_version){ - $data{$data_name}->[$index]{main::key($num++,0,2,'v')} = $desktop_version; + $data->{$data_name}[$index]{main::key($num++,0,2,'v')} = $desktop_version; } if ($toolkit){ - $data{$data_name}->[$index]{main::key($num++,1,2,'tk')} = $toolkit; + $data->{$data_name}[$index]{main::key($num++,1,2,'tk')} = $toolkit; } if ($tk_version){ - $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $tk_version; + $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $tk_version; } if ($extra > 2){ if ($desktop_info){ - $data{$data_name}->[$index]{main::key($num++,0,2,'info')} = $desktop_info; + $data->{$data_name}[$index]{main::key($num++,0,2,'info')} = $desktop_info; } } if ($extra > 1){ if ($wm){ - $data{$data_name}->[$index]{main::key($num++,1,2,'wm')} = $wm; + $data->{$data_name}[$index]{main::key($num++,1,2,'wm')} = $wm; if ($wm_version){ - $data{$data_name}->[$index]{main::key($num++,0,3,'v')} = $wm_version; + $data->{$data_name}[$index]{main::key($num++,0,3,'v')} = $wm_version; } } if ($extra > 2 && $b_display && defined $ENV{'XDG_VTNR'}){ - $data{$data_name}->[$index]{main::key($num++,0,2,'vt')} = $ENV{'XDG_VTNR'}; + $data->{$data_name}[$index]{main::key($num++,0,2,'vt')} = $ENV{'XDG_VTNR'}; } my $dms = main::get_display_manager(); # note: version only present if proper extra level so no need to test again - if ($dms || $desktop_key ne 'Console'){ - if ($dms && scalar @{$dms} > 1){ + if (@$dms || $desktop_key ne 'Console'){ + if (@$dms && scalar @$dms > 1){ my $i = 0; - $data{$data_name}->[$index]{main::key($num++,1,$ind_dm,$dm_key)} = ''; + $data->{$data_name}[$index]{main::key($num++,1,$ind_dm,$dm_key)} = ''; foreach my $dm_data (@{$dms}){ $i++; - $data{$data_name}->[$index]{main::key($num++,1,($ind_dm + 1),$i)} = $dm_data->[0]; + $data->{$data_name}[$index]{main::key($num++,1,($ind_dm + 1),$i)} = $dm_data->[0]; if ($dm_data->[1]){ - $data{$data_name}->[$index]{main::key($num++,0,($ind_dm + 2),'v')} = $dm_data->[1]; + $data->{$data_name}[$index]{main::key($num++,0,($ind_dm + 2),'v')} = $dm_data->[1]; } if ($dm_data->[2]){ - $data{$data_name}->[$index]{main::key($num++,0,($ind_dm + 2),'note')} = $dm_data->[2]; + $data->{$data_name}[$index]{main::key($num++,0,($ind_dm + 2),'note')} = $dm_data->[2]; } } } else { my $dm = ($dms && $dms->[0][0]) ? $dms->[0][0] : 'N/A'; - $data{$data_name}->[$index]{main::key($num++,1,$ind_dm,$dm_key)} = $dm; + $data->{$data_name}[$index]{main::key($num++,1,$ind_dm,$dm_key)} = $dm; if ($dms && $dms->[0][1]){ - $data{$data_name}->[$index]{main::key($num++,0,($ind_dm + 1),'v')} = $dms->[0][1]; + $data->{$data_name}[$index]{main::key($num++,0,($ind_dm + 1),'v')} = $dms->[0][1]; } } @@ -32427,18 +32456,18 @@ sub system_item { } # if ($extra > 2 && $desktop_key ne 'Console'){ # my $tty = ShellData::tty_number() if !$loaded{'tty-number'}; - # $data{$data_name}->[$index]{main::key($num++,0,1,'vc')} = $tty if $tty ne ''; + # $data->{$data_name}[$index]{main::key($num++,0,1,'vc')} = $tty if $tty ne ''; # } my $distro_key = ($bsd_type) ? 'OS': 'Distro'; my @distro_data = DistroData::get(); my $distro = $distro_data[0]; $distro ||= 'N/A'; - $data{$data_name}->[$index]{main::key($num++,1,1,$distro_key)} = $distro; + $data->{$data_name}[$index]{main::key($num++,1,1,$distro_key)} = $distro; if ($extra > 0 && $distro_data[1]){ - $data{$data_name}->[$index]{main::key($num++,0,2,'base')} = $distro_data[1]; + $data->{$data_name}[$index]{main::key($num++,0,2,'base')} = $distro_data[1]; } eval $end if $b_log; - return \%data; + return $data; } ## Item Processors ## sub assign_data { diff --git a/inxi.1 b/inxi.1 index 961ea5a..3a7e123 100644 --- a/inxi.1 +++ b/inxi.1 @@ -15,7 +15,7 @@ .\" with this program; if not, write to the Free Software Foundation, Inc., .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. .\" -.TH INXI 1 "2022\-06\-10" "inxi" "inxi manual" +.TH INXI 1 "2022\-06\-13" "inxi" "inxi manual" .SH NAME inxi \- Command line system information script for console and IRC @@ -333,7 +333,7 @@ Graphics: arch: Rankine code: NV3x process: 130\-150nm - built: 2003-05 + built: 2003\-05 ports: active: VGA\-1 empty: DVI\-I\-1,TV\-1 @@ -1937,7 +1937,7 @@ differences shown, like \fBcores:, \fBmin/max:\fR, etc. arch: Zen gen: 1 process: GF 14nm - built: 2017-19 + built: 2017\-19 family:0x17 (23) model\-id:1 stepping: 2 @@ -2074,7 +2074,7 @@ Wayland sample, with Sway/swaymsg: .nf \fBinxi \aGz Graphics: - Device-1: AMD Cedar [Radeon HD 5000/6000/7350/8350 Series] vendor: XFX Pine + Device\-1: AMD Cedar [Radeon HD 5000/6000/7350/8350 Series] vendor: XFX Pine driver: radeon v: kernel alternate: amdgpu arch: TeraScale 2 process: TSMC 32\-40nm pcie: gen: 1 speed: 2.5 GT/s lanes: 16 link\-max: gen: 2 speed: 5 GT/s ports: active: DVI\-I\-1,VGA\-1 empty: HDMI\-A\-1 @@ -2790,7 +2790,7 @@ X/Wayland). .B Developer Options These are useful only for developers. -\fBFAKE_DATA_DIR\fR - change default fake data directory location. See +\fBFAKE_DATA_DIR\fR \- change default fake data directory location. See \fB\-\-fake\-data\-dir\fR. .SH BUGS diff --git a/inxi.changelog b/inxi.changelog index c29b1a9..bb386b9 100644 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,3 +1,90 @@ +================================================================================ +Version: 3.3.18 +Patch: 00 +Date: 2022-06-13 +-------------------------------------------------------------------------------- +RELEASE NOTES: +-------------------------------------------------------------------------------- + +Bug release, replace 3.3.17 asap, most users will not experience the bug, but if +they do, inxi stops right before the -D line. Failed to do an if defined test on +an array ref that could be undefined or an array ref. That makes Perl very +unhappy! + +-------------------------------------------------------------------------------- +KNOWN ISSUES: + +1. AMD family F, K8 series, will need more granular treatments to get the data +to be more accurate and less generic. We got 2 IDs nailed from raw visual data +confirmations and cpuid values, which leaves many, but good start. We will chip +away (pardon the pun) at these more ambiguous IDs over time, but don't need to +get them all done instantly, just eventually. Thanks slackware person linuxdaddy +for doing really good research and actually looking at the cpu to find dates +etc. + +-------------------------------------------------------------------------------- +BUGS: + +1. Bug, fatal, caused by internal hash/array ref refactor of 3.3.17. Thanks +alaymari github issue #271 for reporting this one. + +-------------------------------------------------------------------------------- +FIXES: + +1. None except for code fixes to try to avoid the cause of the bug in Bugs 1. + +2. Fixed nvidia eol try --gpu, it was showing backwards, with --gpu, not +without, sigh. + +-------------------------------------------------------------------------------- +ENHANCEMENTS: + +1. Added slimski dm data. That's a new fork of SLiM. Also guessing that brzdm +has same version -v output: brzdm version x.xx + +-------------------------------------------------------------------------------- +CHANGES: + +1. None + +-------------------------------------------------------------------------------- +DOCUMENTATION: + +1. Refactors of core docs, ongoing, but will list those next release. + +-------------------------------------------------------------------------------- +CODE: + +1. Cleaned up some array ref handling in subs, returned as: ($var1,$var2) = +@{block_data(...)}, skipped initializing and creating scalar to hold the ref, +just use it directly for DiskItem::block_data(). + +2. Also switched to local ref scalar array in DiskItem::scsi_data(), +DiskItem::block_data(). Not set local array, set local array ref, to keep it +clear. Also made DriveItem::drive_speed() return straight ref, not array then +ref. Same for many other subs, switched to ref assignment so it's the same ref +all through all the sub and return. + +3. Fixed a redundant return \@$data to simply assinging to @$data ref, no return +needed, in DiskItem::smartctl_data(). + +4. Tightened some returns of ref so that tests if good test @$ref, not $ref. +Trying to avoid more cases like issue #271. + +5. Going along with array ref local/return, switched all hash refs to local hash +ref returning ref, and working local with ref. More efficient, avoids creating +new refs over and over, dugh. This made a particularly large difference in CPU +because in certain parts, new references were being created over and over, and +subs were returning like \@arr or \%hash instead of declaring to start: +my $arr = []; my $hash = {}; + +Then working with the data from there on as an array or hash reference, to the +same original reference, rather than creating new ones over and over, which Perl +then has to track til they expire. + +-------------------------------------------------------------------------------- +-- Harald Hope - Mon, 13 Jun 2022 11:22:20 -0700 + ================================================================================ Version: 3.3.17 Patch: 01 @@ -18,7 +105,7 @@ information is not correct: wikipedia links, but also be aware, sometimes these slightly contradict each- other, so research. Don't make me do all your work for you. -* Show the relelevant data, like cpu model/stepping, to correct the issue, or +* Show the relevant data, like cpu model/stepping, to correct the issue, or model name string. * There are 4 main manually updated matching tables, which use either raw regex @@ -332,7 +419,7 @@ Used non-existing $size{'output-block'} instead of correct $use{'output-block'} they change internal light shells, but all the docs say they use ash, so now it will show shell: ash (busybox) to make it clear. Hurray!! This means that tinycore users will get this long awaited feature! Ok, ok, long awaited by -probably only me, but since I package inxi for busybox, it was on my todo list. +probably only me, but since I package inxi for TinyCore, it was on my todo list. 7. Cleaned up and re-organized many disk vendor matching rules, made them easier to read and debug, going along with Code 3, vendors.pl development and release.