From patchwork Tue Sep 6 13:44:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 603040 Delivered-To: patch@linaro.org Received: by 2002:a05:6504:2213:b0:1da:4c02:b5e7 with SMTP id z19csp3091550ltw; Tue, 6 Sep 2022 06:44:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR7JVxFtSLzgvUgy2GE6W+B8OaN6NSrsD02uaTG87v8c4Jc6apy9BqOCz18bT/4CO6a9C8RE X-Received: by 2002:a17:907:9693:b0:73d:cc84:deb with SMTP id hd19-20020a170907969300b0073dcc840debmr38992216ejc.552.1662471881355; Tue, 06 Sep 2022 06:44:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662471881; cv=none; d=google.com; s=arc-20160816; b=TnBvGukD+Nz1OefaggBYVQj8bw5T99Xer9EexgLGvl/cxjlY/8b1F12ak7Pd4PpxT7 LWRlDVpMbn0oJHvDI8lTanJlEs/aPH7VYW//GRVq7u4t0XiM4N3TLAf47SvVVHUTbYWl gkBHOwD7UFBGsBpb0WryMRbb3Nf6jPS5f17jDeYEKWa5tZ1qDSG7xVBOaLqnvVOlenR7 fHz6jwGnd6hdh/32U3EfA5FKLXXQySUJpbKRb0OvQnBIR/f59tbvJY278oHAxTrzm+Wt RoFMU3bz0wgjzqg+vAv0XVVsSsDIbdY2en7kzx2rYyP5FwSwXxFE+9Eq185uuC1/OchU lw3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=YBbhuTYZcGSI4FSsstTIADofj6ZEC8vsTpd/U8gWDlU=; b=ebLk+mP50JU19JGTzcnLsR52E90uOzArp1zzosGwcCKeBFjrQHwUMqsVrtRAxqmKh7 7NBArU/XiJM2FlED/PenPgQ3WEYgF2WtnWYWXLp17sJUwLOdy/0Hvc6PgSKuNORQZoP2 2XtT+gJztxzhv4PZ10xAYqoKjBiR6ufWUrKZo+2x+EGYawhsxGla2sybkzgWEPMaZTaV qlwGHogPpof7gRhb0Gcce2ioSiSVF23OLnV1X+mC60Q2GpHRJBgI71N0RTPeiFpSSqtl ZEA7ijfJnUIYtkzAo7PAmpGXMsZEXmj4Sk6st6HMjlyjHR/HItSJHW9TMp+Y4kocwQtW GZ4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wUY2RcfH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id rq6-20020a17090788c600b00741757d62adsi996959ejc.993.2022.09.06.06.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 06:44:41 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wUY2RcfH; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 498F2849CE; Tue, 6 Sep 2022 15:44:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wUY2RcfH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A8842849CF; Tue, 6 Sep 2022 15:44:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 403A5849AA for ; Tue, 6 Sep 2022 15:44:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ed1-x52d.google.com with SMTP id x73so8243364ede.10 for ; Tue, 06 Sep 2022 06:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=YBbhuTYZcGSI4FSsstTIADofj6ZEC8vsTpd/U8gWDlU=; b=wUY2RcfHqhMQ1dgd2my7jtmfsgHjAF8xFa3HnTkB/tUGQL/oQyls7ODcVui/VImHlf Ah33xwYqK1nwEuoS8HqkWcksTr48pKf/EikkkBbHif0XnfS4oySI3RHo7WW6Yi8HQUoP tbuQ3LPSYgo+62HaqTYVoJ2g6jc1qiEFe/+y6hR2BfmyKd0g/SxwLS9P1QuQosdhX+uO DKWWukFYFV06Nn7x/3oiyoXq33VAWatgQBv/sPC7dBgh/EpnobDpI8NhNhJAkFIcAUrU B91PBwNRtB1Lsf+Eo3WjLtQbinL3h/VvogRSvZEoKCmHY5dbTYB8G1uNzksnK6QecIRu q9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=YBbhuTYZcGSI4FSsstTIADofj6ZEC8vsTpd/U8gWDlU=; b=KfQ/P0sYI7szdfgs6GA5oPXctzQ8yfxjRs7PgVHFg7jl09SeFl3jpKzaMGbC7GlEgM JXt2VP6w9TndL/D71cR8w9BObY2mZJoLRP/s25LpSU6izkisnuueyGeqKegGEfGE+4B3 9xaG/EUlPZmHlAem6bOf9Dl6lE5WkT6SnTDopwODIbcTAWlIa8Gjtw9XBaaa8iRnVuTn S3IwY9R7DLaSFBQXTVHmAYnhCc2b5XCRKlSNwmDE65+LqvOdAu3MTbA5/YyL9pEPjHi9 4q0ZQksAE0olpQQwxyjHrvz7h7ktSuJoesa/A4dX3PEbzSbBmPI1CGtPy27/luAUCH3F e8Vw== X-Gm-Message-State: ACgBeo2YRons+T+T1+BdP4+uyEFge3LrQ/gS2VYwuVZg325XGZ8HVnXH Lq8no+qriMaFPrto6+L889ufiYLHsm+dZQ== X-Received: by 2002:aa7:c84f:0:b0:446:2bfb:5a63 with SMTP id g15-20020aa7c84f000000b004462bfb5a63mr17498596edt.172.1662471874779; Tue, 06 Sep 2022 06:44:34 -0700 (PDT) Received: from localhost.localdomain ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id p23-20020a056402501700b0043ba7df7a42sm8473330eda.26.2022.09.06.06.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 06:44:34 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, heinrich.schuchardt@canonical.com, pbrobinson@gmail.com, Ilias Apalodimas Subject: [PATCH 1/2] smbios: Simplify reporting of unknown values Date: Tue, 6 Sep 2022 16:44:25 +0300 Message-Id: <20220906134426.53748-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean If a value is not valid during the DT or SYSINFO parsing, we explicitly set that to "Unknown Product" and "Unknown" for the product and manufacturer respectively. It's cleaner if we move the checks insisde smbios_add_string() and always report "Unknown" regardless of the missing field. pre-patch dmidecode Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Unknown Product Name: Unknown Product Version: Not Specified Serial Number: Not Specified UUID: Not Settable Wake-up Type: Reserved SKU Number: Not Specified Family: Not Specified Handle 0x0002, DMI type 2, 14 bytes Base Board Information Manufacturer: Unknown Product Name: Unknown Product Version: Not Specified Serial Number: Not Specified Asset Tag: Not Specified Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0000 Type: Motherboard post-patch dmidecode: Handle 0x0001, DMI type 1, 27 bytes System Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Unknown UUID: Not Settable Wake-up Type: Reserved SKU Number: Unknown Family: Unknown Handle 0x0002, DMI type 2, 14 bytes Base Board Information Manufacturer: Unknown Product Name: Unknown Version: Unknown Serial Number: Not Specified Asset Tag: Unknown Features: Board is a hosting board Location In Chassis: Not Specified Chassis Handle: 0x0000 Type: Motherboard Signed-off-by: Ilias Apalodimas Reviewed-by: Peter Robinson Tested-by: Peter Robinson --- lib/smbios.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/smbios.c b/lib/smbios.c index d7f4999e8b2a..fcc8686993ef 100644 --- a/lib/smbios.c +++ b/lib/smbios.c @@ -102,7 +102,7 @@ static int smbios_add_string(struct smbios_ctx *ctx, const char *str) int i = 1; char *p = ctx->eos; - if (!*str) + if (!str || !*str) str = "Unknown"; for (;;) { @@ -151,8 +151,7 @@ static int smbios_add_prop_si(struct smbios_ctx *ctx, const char *prop, const char *str; str = ofnode_read_string(ctx->node, prop); - if (str) - return smbios_add_string(ctx, str); + return smbios_add_string(ctx, str); } return 0; @@ -231,7 +230,7 @@ static int smbios_write_type0(ulong *current, int handle, t->vendor = smbios_add_string(ctx, "U-Boot"); t->bios_ver = smbios_add_prop(ctx, "version"); - if (!t->bios_ver) + if (!strcmp(ctx->last_str, "Unknown")) t->bios_ver = smbios_add_string(ctx, PLAIN_VERSION); if (t->bios_ver) gd->smbios_version = ctx->last_str; @@ -281,11 +280,7 @@ static int smbios_write_type1(ulong *current, int handle, fill_smbios_header(t, SMBIOS_SYSTEM_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); t->product_name = smbios_add_prop(ctx, "product"); - if (!t->product_name) - t->product_name = smbios_add_string(ctx, "Unknown Product"); t->version = smbios_add_prop_si(ctx, "version", SYSINFO_ID_SMBIOS_SYSTEM_VERSION); if (serial_str) { @@ -315,11 +310,7 @@ static int smbios_write_type2(ulong *current, int handle, fill_smbios_header(t, SMBIOS_BOARD_INFORMATION, len, handle); smbios_set_eos(ctx, t->eos); t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); t->product_name = smbios_add_prop(ctx, "product"); - if (!t->product_name) - t->product_name = smbios_add_string(ctx, "Unknown Product"); t->version = smbios_add_prop_si(ctx, "version", SYSINFO_ID_SMBIOS_BASEBOARD_VERSION); t->asset_tag_number = smbios_add_prop(ctx, "asset-tag"); @@ -344,8 +335,6 @@ static int smbios_write_type3(ulong *current, int handle, fill_smbios_header(t, SMBIOS_SYSTEM_ENCLOSURE, len, handle); smbios_set_eos(ctx, t->eos); t->manufacturer = smbios_add_prop(ctx, "manufacturer"); - if (!t->manufacturer) - t->manufacturer = smbios_add_string(ctx, "Unknown"); t->chassis_type = SMBIOS_ENCLOSURE_DESKTOP; t->bootup_state = SMBIOS_STATE_SAFE; t->power_supply_state = SMBIOS_STATE_SAFE;