Coverage Report

Created: 2026-07-16 07:10

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
31
0
  fn = g_build_filename(fwupd_bios_setting_get_path(self),
32
0
            fwupd_bios_setting_get_filename(self),
33
0
            NULL);
34
0
  io = fu_io_channel_new_file(fn, FU_IO_CHANNEL_OPEN_FLAG_WRITE, error);
35
0
  if (io == NULL)
36
0
    return FALSE;
37
0
  if (!fu_io_channel_write_raw(io,
38
0
             (const guint8 *)value,
39
0
             strlen(value),
40
0
             1000,
41
0
             FU_IO_CHANNEL_FLAG_NONE,
42
0
             error))
43
0
    return FALSE;
44
45
  /* success */
46
0
  fwupd_bios_setting_set_current_value(self, value);
47
0
  g_debug("set %s to %s", fwupd_bios_setting_get_id(self), value);
48
0
  return TRUE;
49
0
}
50
51
static void
52
fu_bios_setting_class_init(FuBiosSettingClass *klass)
53
0
{
54
0
  FwupdBiosSettingClass *bios_setting_class = FWUPD_BIOS_SETTING_CLASS(klass);
55
0
  bios_setting_class->write_value = fu_bios_setting_write_value;
56
0
}
57
58
static void
59
fu_bios_setting_init(FuBiosSetting *self)
60
0
{
61
0
}
62
63
FwupdBiosSetting *
64
fu_bios_setting_new(void)
65
0
{
66
0
  return g_object_new(FU_TYPE_BIOS_SETTING, NULL);
67
0
}