Coverage Report

Created: 2025-07-01 07:09

/work/fu-dpaux-struct.c
Line
Count
Source (jump to first uncovered line)
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include "fu-dpaux-struct.h"
5
#include "fu-byte-array.h"
6
#include "fu-mem-private.h"
7
#include "fu-string.h"
8
9
#ifdef G_LOG_DOMAIN
10
  #undef G_LOG_DOMAIN
11
#endif
12
0
#define G_LOG_DOMAIN "FuStruct"
13
/* getters */
14
/**
15
 * fu_struct_dpaux_dpcd_get_ieee_oui: (skip):
16
 **/
17
guint32
18
fu_struct_dpaux_dpcd_get_ieee_oui(const FuStructDpauxDpcd *st)
19
0
{
20
0
    g_return_val_if_fail(st != NULL, 0x0);
21
0
    return fu_memread_uint24(st->data + 0, G_BIG_ENDIAN);
22
0
}
23
/**
24
 * fu_struct_dpaux_dpcd_get_dev_id: (skip):
25
 **/
26
gchar *
27
fu_struct_dpaux_dpcd_get_dev_id(const FuStructDpauxDpcd *st)
28
0
{
29
0
    g_return_val_if_fail(st != NULL, NULL);
30
0
    return fu_memstrsafe(st->data, st->len, 3, 6, NULL);
31
0
}
32
/**
33
 * fu_struct_dpaux_dpcd_get_hw_rev: (skip):
34
 **/
35
guint8
36
fu_struct_dpaux_dpcd_get_hw_rev(const FuStructDpauxDpcd *st)
37
0
{
38
0
    g_return_val_if_fail(st != NULL, 0x0);
39
0
    return st->data[9];
40
0
}
41
/**
42
 * fu_struct_dpaux_dpcd_get_fw_ver: (skip):
43
 **/
44
guint32
45
fu_struct_dpaux_dpcd_get_fw_ver(const FuStructDpauxDpcd *st)
46
0
{
47
0
    g_return_val_if_fail(st != NULL, 0x0);
48
0
    return fu_memread_uint24(st->data + 10, G_BIG_ENDIAN);
49
0
}
50
51
/* setters */
52
/**
53
 * fu_struct_dpaux_dpcd_to_string: (skip):
54
 **/
55
static gchar *
56
fu_struct_dpaux_dpcd_to_string(const FuStructDpauxDpcd *st)
57
0
{
58
0
    g_autoptr(GString) str = g_string_new("FuStructDpauxDpcd:\n");
59
0
    g_return_val_if_fail(st != NULL, NULL);
60
0
    g_string_append_printf(str, "  ieee_oui: 0x%x\n",
61
0
                           (guint) fu_struct_dpaux_dpcd_get_ieee_oui(st));
62
0
    {
63
0
        g_autofree gchar *tmp = fu_struct_dpaux_dpcd_get_dev_id(st);
64
0
        if (tmp != NULL)
65
0
            g_string_append_printf(str, "  dev_id: %s\n", tmp);
66
0
    }
67
0
    g_string_append_printf(str, "  hw_rev: 0x%x\n",
68
0
                           (guint) fu_struct_dpaux_dpcd_get_hw_rev(st));
69
0
    g_string_append_printf(str, "  fw_ver: 0x%x\n",
70
0
                           (guint) fu_struct_dpaux_dpcd_get_fw_ver(st));
71
0
    if (str->len > 0)
72
0
        g_string_set_size(str, str->len - 1);
73
0
    return g_string_free(g_steal_pointer(&str), FALSE);
74
0
}
75
static gboolean
76
fu_struct_dpaux_dpcd_validate_internal(FuStructDpauxDpcd *st, GError **error)
77
0
{
78
0
    g_return_val_if_fail(st != NULL, FALSE);
79
0
    return TRUE;
80
0
}
81
static gboolean
82
fu_struct_dpaux_dpcd_parse_internal(FuStructDpauxDpcd *st, GError **error)
83
0
{
84
0
    if (!fu_struct_dpaux_dpcd_validate_internal(st, error))
85
0
        return FALSE;
86
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
87
0
        g_autofree gchar *str = fu_struct_dpaux_dpcd_to_string(st);
88
0
        g_debug("%s", str);
89
0
    }
90
0
    return TRUE;
91
0
}
92
93
/**
94
 * fu_struct_dpaux_dpcd_parse: (skip):
95
 **/
96
FuStructDpauxDpcd *
97
fu_struct_dpaux_dpcd_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
98
0
{
99
0
    g_autoptr(GByteArray) st = g_byte_array_new();
100
0
    g_return_val_if_fail(buf != NULL, NULL);
101
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
102
0
    if (!fu_memchk_read(bufsz, offset, 13, error)) {
103
0
        g_prefix_error(error, "invalid struct FuStructDpauxDpcd: ");
104
0
        return NULL;
105
0
    }
106
0
    g_byte_array_append(st, buf + offset, 13);
107
0
    if (!fu_struct_dpaux_dpcd_parse_internal(st, error))
108
0
        return NULL;
109
0
    return g_steal_pointer(&st);
110
0
}