Coverage Report

Created: 2026-01-17 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fwupd/libfwupdplugin/fu-bios-setting.c
Line
Count
Source
1
/*
2
 * Copyright 2023 Richard Hughes <richard@hughsie.com>
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
0
#define G_LOG_DOMAIN "FuBiosSettings"
8
9
#include "config.h"
10
11
#include <fcntl.h>
12
13
#include "fu-bios-setting.h"
14
#include "fu-io-channel.h"
15
16
struct _FuBiosSetting {
17
  FwupdBiosSetting parent_instance;
18
};
19
20
0
G_DEFINE_TYPE(FuBiosSetting, fu_bios_setting, FWUPD_TYPE_BIOS_SETTING)
21
0
22
0
static gboolean
23
0
fu_bios_setting_write_value(FwupdBiosSetting *self, const gchar *value, GError **error)
24
0
{
25
0
  g_autofree gchar *fn = NULL;
26
0
  g_autoptr(FuIOChannel) io = NULL;
27
28
0
  if (fwupd_bios_setting_get_path(self) == NULL)
29
0
    return TRUE;
30
0
  fn = g_build_filename(fwupd_bios_setting_get_path(self), "current_value", NULL);
31
0
  io = fu_io_channel_new_file(fn, FU_IO_CHANNEL_OPEN_FLAG_WRITE, error);
32
0
  if (io == NULL)
33
0
    return FALSE;
34
0
  if (!fu_io_channel_write_raw(io,
35
0
             (const guint8 *)value,
36
0
             strlen(value),
37
0
             1000,
38
0
             FU_IO_CHANNEL_FLAG_NONE,
39
0
             error))
40
0
    return FALSE;
41
42
  /* success */
43
0
  fwupd_bios_setting_set_current_value(self, value);
44
0
  g_debug("set %s to %s", fwupd_bios_setting_get_id(self), value);
45
0
  return TRUE;
46
0
}
47
48
static void
49
fu_bios_setting_class_init(FuBiosSettingClass *klass)
50
0
{
51
0
  FwupdBiosSettingClass *bios_setting_class = FWUPD_BIOS_SETTING_CLASS(klass);
52
0
  bios_setting_class->write_value = fu_bios_setting_write_value;
53
0
}
54
55
static void
56
fu_bios_setting_init(FuBiosSetting *self)
57
0
{
58
0
}
59
60
FwupdBiosSetting *
61
fu_bios_setting_new(void)
62
0
{
63
0
  return g_object_new(FU_TYPE_BIOS_SETTING, NULL);
64
0
}