[PATCH 08/22] ddr_spd: fix always true sub-condition

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Mar 13 00:34:31 PDT 2025


The last subcondition is always true, because it compares the left-hand
side against two different values and ORs the result.

I think the intention of the code is to avoid printing bogus serial
numbers that are either all zeroes or all ones, so let's check for that.

This is a debug print, so there is no fallout expected if the guess
turns out wrong..

Cc: Denis Orlov <denorl2009 at gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/ddr_spd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/common/ddr_spd.c b/common/ddr_spd.c
index b7693f3fd25c..7ca8e9887a55 100644
--- a/common/ddr_spd.c
+++ b/common/ddr_spd.c
@@ -927,10 +927,8 @@ static void ddr3_spd_print(uint8_t *record)
 	    && !((s->mdate[0] == 0x0) && (s->mdate[1] == 0x0)))
 		spd_print_manufacturing_date(s->mdate[0], s->mdate[1]);
 
-	if ((s->sernum[0] != s->sernum[1])
-	    && (s->sernum[0] != s->sernum[2])
-	    && (s->sernum[1] != s->sernum[3])
-	    && ((s->sernum[0] != 0xff) || (s->sernum[0] != 0x0)))
+	if (memcmp(s->sernum, "\xFF\xFF\xFF\xFF", 4) &&
+	    memcmp(s->sernum, "\x00\x00\x00\x00", 4))
 		printf("%-48s 0x%02X%02X%02X%02X\n", "Assembly Serial Number",
 		       s->sernum[0], s->sernum[1], s->sernum[2], s->sernum[3]);
 
-- 
2.39.5




More information about the barebox mailing list