From dfdde9b38a43f214f4ad06603ac0af496415d0a4 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 20 Mar 2009 14:12:27 +0000 Subject: [PATCH] Verify checksum or CRC before processing any DIMM module. That way we know how many modules we have before we start the actual work. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5697 7894878c-1315-0410-8ee3-d5d059ff63e0 --- eeprom/decode-dimms | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index 843775b..1c4604d 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -1611,8 +1611,6 @@ printh('Memory Serial Presence Detect Decoder', Jean Delvare, Trent Piepho and others'); -my $dimm_count = 0; - sub get_dimm_list { my ($dir, $file, @files); @@ -1662,9 +1660,22 @@ for my $i (0 .. $#dimm) { $dimm[$i]->{chk_spd}, $dimm[$i]->{chk_calc}) = check_crc(\@bytes); } +} + +# Checksum or CRC validation +if (!$opt_igncheck) { + for (my $i = 0; $i < @dimm; ) { + if ($dimm[$i]->{chk_valid}) { + $i++; + } else { + splice(@dimm, $i, 1); + } + } +} - next unless $dimm[$i]->{chk_valid} || $opt_igncheck; - $dimm_count++; +# Process the valid entries +for my $i (0 .. $#dimm) { + my @bytes = @{$dimm[$i]->{bytes}}; print "" if $opt_html; printl2("\n\nDecoding EEPROM", $dimm[$i]->{file}); @@ -1750,6 +1761,6 @@ for my $i (0 .. $#dimm) { print "\n" if $opt_html; } -printl2("\n\nNumber of SDRAM DIMMs detected and decoded", $dimm_count); +printl2("\n\nNumber of SDRAM DIMMs detected and decoded", scalar @dimm); print "\n" if ($opt_html && !$opt_bodyonly);