Coverage Report

Created: 2025-07-01 07:09

/src/fwupd/libfwupdplugin/fu-hwids-kenv.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2021 Richard Hughes <richard@hughsie.com>
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#define G_LOG_DOMAIN "FuContext"
8
9
#include "config.h"
10
11
#include "fu-hwids-private.h"
12
13
gboolean
14
fu_hwids_kenv_setup(FuContext *ctx, FuHwids *self, GError **error)
15
0
{
16
#ifdef HAVE_KENV_H
17
  struct {
18
    const gchar *hwid;
19
    const gchar *key;
20
  } map[] = {{FU_HWIDS_KEY_BASEBOARD_MANUFACTURER, "smbios.planar.maker"},
21
       {FU_HWIDS_KEY_BASEBOARD_PRODUCT, "smbios.planar.product"},
22
       {FU_HWIDS_KEY_BIOS_VENDOR, "smbios.bios.vendor"},
23
       {FU_HWIDS_KEY_BIOS_VERSION, "smbios.bios.version"},
24
       {FU_HWIDS_KEY_FAMILY, "smbios.system.family"},
25
       {FU_HWIDS_KEY_MANUFACTURER, "smbios.system.maker"},
26
       {FU_HWIDS_KEY_PRODUCT_NAME, "smbios.system.product"},
27
       {FU_HWIDS_KEY_PRODUCT_SKU, "smbios.system.sku"},
28
       {{NULL, NULL}}};
29
  for (guint i = 0; map[i].key != NULL; i++) {
30
    g_autoptr(GError) error_local = NULL;
31
    g_autofree gchar *value = fu_kenv_get_string(map[i].key, error_local);
32
    if (value == NULL) {
33
      g_debug("ignoring: %s", error_local->message);
34
      continue;
35
    }
36
    fu_hwids_add_value(self, map[i].hwid, value);
37
  }
38
#endif
39
40
  /* success */
41
0
  return TRUE;
42
0
}