Coverage Report

Created: 2026-12-01 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-dpaux-struct.c
Line
Count
Source
1
/*
2
 * This file is auto-generated, do not modify!
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
#include "config.h"
8
9
#include <glib.h>
10
11
#include "fu-dpaux-struct.h"
12
#include "fu-byte-array.h"
13
#include "fu-bytes.h"
14
#include "fu-mem.h"
15
#include "fu-string.h"
16
17
#ifdef G_LOG_DOMAIN
18
  #undef G_LOG_DOMAIN
19
#endif
20
0
#define G_LOG_DOMAIN "FuStruct"
21
/**
22
 * fu_struct_dpaux_dpcd_ref: (skip):
23
 **/
24
FuStructDpauxDpcd *
25
fu_struct_dpaux_dpcd_ref(FuStructDpauxDpcd *st)
26
0
{
27
0
    g_return_val_if_fail(st != NULL, NULL);
28
0
    st->refcount++;
29
0
    return st;
30
0
}
31
/**
32
 * fu_struct_dpaux_dpcd_unref: (skip):
33
 **/
34
void
35
fu_struct_dpaux_dpcd_unref(FuStructDpauxDpcd *st)
36
0
{
37
0
    g_return_if_fail(st != NULL);
38
0
    if (st->refcount == 0) {
39
0
        g_critical("FuStructDpauxDpcd refcount already zero");
40
0
        return;
41
0
    }
42
0
    if (--st->refcount > 0)
43
0
        return;
44
0
    if (st->buf != NULL)
45
0
        g_byte_array_unref(st->buf);
46
0
    g_free(st);
47
0
}
48
/**
49
 * fu_struct_dpaux_dpcd_new_internal: (skip):
50
 **/
51
static FuStructDpauxDpcd *
52
fu_struct_dpaux_dpcd_new_internal(void)
53
0
{
54
0
    FuStructDpauxDpcd *st = g_new0(FuStructDpauxDpcd, 1);
55
0
    st->refcount = 1;
56
0
    return st;
57
0
}
58
59
/* getters */
60
/**
61
 * fu_struct_dpaux_dpcd_get_ieee_oui: (skip):
62
 **/
63
guint32
64
fu_struct_dpaux_dpcd_get_ieee_oui(const FuStructDpauxDpcd *st)
65
0
{
66
0
    g_return_val_if_fail(st != NULL, 0x0);
67
0
    return fu_memread_uint24(st->buf->data + 0, G_BIG_ENDIAN);
68
0
}
69
/**
70
 * fu_struct_dpaux_dpcd_get_dev_id: (skip):
71
 **/
72
gchar *
73
fu_struct_dpaux_dpcd_get_dev_id(const FuStructDpauxDpcd *st)
74
0
{
75
0
    g_return_val_if_fail(st != NULL, NULL);
76
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 6, NULL);
77
0
}
78
/**
79
 * fu_struct_dpaux_dpcd_get_hw_rev: (skip):
80
 **/
81
guint8
82
fu_struct_dpaux_dpcd_get_hw_rev(const FuStructDpauxDpcd *st)
83
0
{
84
0
    g_return_val_if_fail(st != NULL, 0x0);
85
0
    return st->buf->data[9];
86
0
}
87
/**
88
 * fu_struct_dpaux_dpcd_get_fw_ver: (skip):
89
 **/
90
guint32
91
fu_struct_dpaux_dpcd_get_fw_ver(const FuStructDpauxDpcd *st)
92
0
{
93
0
    g_return_val_if_fail(st != NULL, 0x0);
94
0
    return fu_memread_uint24(st->buf->data + 10, G_BIG_ENDIAN);
95
0
}
96
97
/* setters */
98
/**
99
 * fu_struct_dpaux_dpcd_set_ieee_oui: (skip):
100
 **/
101
void
102
fu_struct_dpaux_dpcd_set_ieee_oui(FuStructDpauxDpcd *st, guint32 value)
103
0
{
104
0
    g_return_if_fail(st != NULL);
105
0
    fu_memwrite_uint24(st->buf->data + 0, value, G_BIG_ENDIAN);
106
0
}
107
/**
108
 * fu_struct_dpaux_dpcd_set_dev_id: (skip):
109
 **/
110
gboolean
111
fu_struct_dpaux_dpcd_set_dev_id(FuStructDpauxDpcd *st, const gchar *value, GError **error)
112
0
{
113
0
    gsize len;
114
0
    g_return_val_if_fail(st != NULL, FALSE);
115
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
116
0
    if (value == NULL) {
117
0
        memset(st->buf->data + 3, 0x0, 6);
118
0
        return TRUE;
119
0
    }
120
0
    len = strlen(value);
121
0
    if (len > 6) {
122
0
        g_set_error(error,
123
0
                    FWUPD_ERROR,
124
0
                    FWUPD_ERROR_INVALID_DATA,
125
0
                    "string '%s' (0x%x bytes) does not fit in FuStructDpauxDpcd.dev_id (0x%x bytes)",
126
0
                    value, (guint) len, (guint) 6);
127
0
        return FALSE;
128
0
    }
129
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 3, (const guint8 *)value, len, 0x0, len, error);
130
0
}
131
/**
132
 * fu_struct_dpaux_dpcd_set_hw_rev: (skip):
133
 **/
134
void
135
fu_struct_dpaux_dpcd_set_hw_rev(FuStructDpauxDpcd *st, guint8 value)
136
0
{
137
0
    g_return_if_fail(st != NULL);
138
0
    st->buf->data[9] = value;
139
0
}
140
/**
141
 * fu_struct_dpaux_dpcd_set_fw_ver: (skip):
142
 **/
143
void
144
fu_struct_dpaux_dpcd_set_fw_ver(FuStructDpauxDpcd *st, guint32 value)
145
0
{
146
0
    g_return_if_fail(st != NULL);
147
0
    fu_memwrite_uint24(st->buf->data + 10, value, G_BIG_ENDIAN);
148
0
}
149
/**
150
 * fu_struct_dpaux_dpcd_new: (skip):
151
 **/
152
FuStructDpauxDpcd *
153
fu_struct_dpaux_dpcd_new(void)
154
0
{
155
0
    FuStructDpauxDpcd *st = fu_struct_dpaux_dpcd_new_internal();
156
0
    st->buf = g_byte_array_sized_new(13);
157
0
    fu_byte_array_set_size(st->buf, 13, 0x0);
158
0
    return st;
159
0
}
160
/**
161
 * fu_struct_dpaux_dpcd_to_string: (skip):
162
 **/
163
static gchar *
164
fu_struct_dpaux_dpcd_to_string(const FuStructDpauxDpcd *st)
165
0
{
166
0
    g_autoptr(GString) str = g_string_new("FuStructDpauxDpcd:\n");
167
0
    g_return_val_if_fail(st != NULL, NULL);
168
0
    g_string_append_printf(str, "  ieee_oui: 0x%x\n",
169
0
                           (guint) fu_struct_dpaux_dpcd_get_ieee_oui(st));
170
0
    {
171
0
        g_autofree gchar *tmp = fu_struct_dpaux_dpcd_get_dev_id(st);
172
0
        if (tmp != NULL)
173
0
            g_string_append_printf(str, "  dev_id: %s\n", tmp);
174
0
    }
175
0
    g_string_append_printf(str, "  hw_rev: 0x%x\n",
176
0
                           (guint) fu_struct_dpaux_dpcd_get_hw_rev(st));
177
0
    g_string_append_printf(str, "  fw_ver: 0x%x\n",
178
0
                           (guint) fu_struct_dpaux_dpcd_get_fw_ver(st));
179
0
    if (str->len > 0)
180
0
        g_string_set_size(str, str->len - 1);
181
0
    return g_string_free(g_steal_pointer(&str), FALSE);
182
0
}
183
static gboolean
184
fu_struct_dpaux_dpcd_parse_internal(FuStructDpauxDpcd *st, GError **error)
185
0
{
186
0
    if (g_log_get_debug_enabled()) {
187
0
        g_autofree gchar *str = fu_struct_dpaux_dpcd_to_string(st);
188
0
        g_debug("%s", str);
189
0
    }
190
0
    return TRUE;
191
0
}
192
193
/**
194
 * fu_struct_dpaux_dpcd_parse: (skip):
195
 **/
196
FuStructDpauxDpcd *
197
fu_struct_dpaux_dpcd_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
198
0
{
199
0
    g_autoptr(FuStructDpauxDpcd) st = fu_struct_dpaux_dpcd_new_internal();
200
0
    g_return_val_if_fail(buf != NULL, NULL);
201
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
202
0
    if (!fu_memchk_read(bufsz, offset, 13, error)) {
203
0
        g_prefix_error_literal(error, "invalid struct FuStructDpauxDpcd: ");
204
0
        return NULL;
205
0
    }
206
0
    st->buf = g_byte_array_new();
207
0
    g_byte_array_append(st->buf, buf + offset, 13);
208
0
    if (!fu_struct_dpaux_dpcd_parse_internal(st, error))
209
0
        return NULL;
210
0
    return g_steal_pointer(&st);
211
0
}