Coverage Report

Created: 2025-11-11 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-dpaux-struct.c
Line
Count
Source
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include <glib.h>
5
6
#include "fu-dpaux-struct.h"
7
#include "fu-byte-array.h"
8
#include "fu-mem-private.h"
9
#include "fu-string.h"
10
11
#ifdef G_LOG_DOMAIN
12
  #undef G_LOG_DOMAIN
13
#endif
14
0
#define G_LOG_DOMAIN "FuStruct"
15
/**
16
 * fu_struct_dpaux_dpcd_ref: (skip):
17
 **/
18
FuStructDpauxDpcd *
19
fu_struct_dpaux_dpcd_ref(FuStructDpauxDpcd *st)
20
0
{
21
0
    g_return_val_if_fail(st != NULL, NULL);
22
0
    st->refcount++;
23
0
    return st;
24
0
}
25
/**
26
 * fu_struct_dpaux_dpcd_unref: (skip):
27
 **/
28
void
29
fu_struct_dpaux_dpcd_unref(FuStructDpauxDpcd *st)
30
0
{
31
0
    g_return_if_fail(st != NULL);
32
0
    if (st->refcount == 0) {
33
0
        g_critical("FuStructDpauxDpcd refcount already zero");
34
0
        return;
35
0
    }
36
0
    if (--st->refcount > 0)
37
0
        return;
38
0
    if (st->buf != NULL)
39
0
        g_byte_array_unref(st->buf);
40
0
    g_free(st);
41
0
}
42
static FuStructDpauxDpcd *
43
fu_struct_dpaux_dpcd_new_internal(void)
44
0
{
45
0
    FuStructDpauxDpcd *st = g_new0(FuStructDpauxDpcd, 1);
46
0
    st->refcount = 1;
47
0
    return st;
48
0
}
49
50
/* getters */
51
/**
52
 * fu_struct_dpaux_dpcd_get_ieee_oui: (skip):
53
 **/
54
guint32
55
fu_struct_dpaux_dpcd_get_ieee_oui(const FuStructDpauxDpcd *st)
56
0
{
57
0
    g_return_val_if_fail(st != NULL, 0x0);
58
0
    return fu_memread_uint24(st->buf->data + 0, G_BIG_ENDIAN);
59
0
}
60
/**
61
 * fu_struct_dpaux_dpcd_get_dev_id: (skip):
62
 **/
63
gchar *
64
fu_struct_dpaux_dpcd_get_dev_id(const FuStructDpauxDpcd *st)
65
0
{
66
0
    g_return_val_if_fail(st != NULL, NULL);
67
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 6, NULL);
68
0
}
69
/**
70
 * fu_struct_dpaux_dpcd_get_hw_rev: (skip):
71
 **/
72
guint8
73
fu_struct_dpaux_dpcd_get_hw_rev(const FuStructDpauxDpcd *st)
74
0
{
75
0
    g_return_val_if_fail(st != NULL, 0x0);
76
0
    return st->buf->data[9];
77
0
}
78
/**
79
 * fu_struct_dpaux_dpcd_get_fw_ver: (skip):
80
 **/
81
guint32
82
fu_struct_dpaux_dpcd_get_fw_ver(const FuStructDpauxDpcd *st)
83
0
{
84
0
    g_return_val_if_fail(st != NULL, 0x0);
85
0
    return fu_memread_uint24(st->buf->data + 10, G_BIG_ENDIAN);
86
0
}
87
88
/* setters */
89
/**
90
 * fu_struct_dpaux_dpcd_to_string: (skip):
91
 **/
92
static gchar *
93
fu_struct_dpaux_dpcd_to_string(const FuStructDpauxDpcd *st)
94
0
{
95
0
    g_autoptr(GString) str = g_string_new("FuStructDpauxDpcd:\n");
96
0
    g_return_val_if_fail(st != NULL, NULL);
97
0
    g_string_append_printf(str, "  ieee_oui: 0x%x\n",
98
0
                           (guint) fu_struct_dpaux_dpcd_get_ieee_oui(st));
99
0
    {
100
0
        g_autofree gchar *tmp = fu_struct_dpaux_dpcd_get_dev_id(st);
101
0
        if (tmp != NULL)
102
0
            g_string_append_printf(str, "  dev_id: %s\n", tmp);
103
0
    }
104
0
    g_string_append_printf(str, "  hw_rev: 0x%x\n",
105
0
                           (guint) fu_struct_dpaux_dpcd_get_hw_rev(st));
106
0
    g_string_append_printf(str, "  fw_ver: 0x%x\n",
107
0
                           (guint) fu_struct_dpaux_dpcd_get_fw_ver(st));
108
0
    if (str->len > 0)
109
0
        g_string_set_size(str, str->len - 1);
110
0
    return g_string_free(g_steal_pointer(&str), FALSE);
111
0
}
112
static gboolean
113
fu_struct_dpaux_dpcd_validate_internal(FuStructDpauxDpcd *st, GError **error)
114
0
{
115
0
    g_return_val_if_fail(st != NULL, FALSE);
116
0
    return TRUE;
117
0
}
118
static gboolean
119
fu_struct_dpaux_dpcd_parse_internal(FuStructDpauxDpcd *st, GError **error)
120
0
{
121
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
122
0
        g_autofree gchar *str = fu_struct_dpaux_dpcd_to_string(st);
123
0
        g_debug("%s", str);
124
0
    }
125
0
    if (!fu_struct_dpaux_dpcd_validate_internal(st, error))
126
0
        return FALSE;
127
0
    return TRUE;
128
0
}
129
130
/**
131
 * fu_struct_dpaux_dpcd_parse: (skip):
132
 **/
133
FuStructDpauxDpcd *
134
fu_struct_dpaux_dpcd_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
135
0
{
136
0
    g_autoptr(FuStructDpauxDpcd) st = fu_struct_dpaux_dpcd_new_internal();
137
0
    g_return_val_if_fail(buf != NULL, NULL);
138
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
139
0
    if (!fu_memchk_read(bufsz, offset, 13, error)) {
140
0
        g_prefix_error_literal(error, "invalid struct FuStructDpauxDpcd: ");
141
0
        return NULL;
142
0
    }
143
0
    st->buf = g_byte_array_new();
144
0
    g_byte_array_append(st->buf, buf + offset, 13);
145
0
    if (!fu_struct_dpaux_dpcd_parse_internal(st, error))
146
0
        return NULL;
147
0
    return g_steal_pointer(&st);
148
0
}