Coverage Report

Created: 2026-02-26 06:27

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-private.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_to_string: (skip):
100
 **/
101
static gchar *
102
fu_struct_dpaux_dpcd_to_string(const FuStructDpauxDpcd *st)
103
0
{
104
0
    g_autoptr(GString) str = g_string_new("FuStructDpauxDpcd:\n");
105
0
    g_return_val_if_fail(st != NULL, NULL);
106
0
    g_string_append_printf(str, "  ieee_oui: 0x%x\n",
107
0
                           (guint) fu_struct_dpaux_dpcd_get_ieee_oui(st));
108
0
    {
109
0
        g_autofree gchar *tmp = fu_struct_dpaux_dpcd_get_dev_id(st);
110
0
        if (tmp != NULL)
111
0
            g_string_append_printf(str, "  dev_id: %s\n", tmp);
112
0
    }
113
0
    g_string_append_printf(str, "  hw_rev: 0x%x\n",
114
0
                           (guint) fu_struct_dpaux_dpcd_get_hw_rev(st));
115
0
    g_string_append_printf(str, "  fw_ver: 0x%x\n",
116
0
                           (guint) fu_struct_dpaux_dpcd_get_fw_ver(st));
117
0
    if (str->len > 0)
118
0
        g_string_set_size(str, str->len - 1);
119
0
    return g_string_free(g_steal_pointer(&str), FALSE);
120
0
}
121
static gboolean
122
fu_struct_dpaux_dpcd_validate_internal(FuStructDpauxDpcd *st, GError **error)
123
0
{
124
0
    g_return_val_if_fail(st != NULL, FALSE);
125
0
    return TRUE;
126
0
}
127
static gboolean
128
fu_struct_dpaux_dpcd_parse_internal(FuStructDpauxDpcd *st, GError **error)
129
0
{
130
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
131
0
        g_autofree gchar *str = fu_struct_dpaux_dpcd_to_string(st);
132
0
        g_debug("%s", str);
133
0
    }
134
0
    if (!fu_struct_dpaux_dpcd_validate_internal(st, error))
135
0
        return FALSE;
136
0
    return TRUE;
137
0
}
138
139
/**
140
 * fu_struct_dpaux_dpcd_parse: (skip):
141
 **/
142
FuStructDpauxDpcd *
143
fu_struct_dpaux_dpcd_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
144
0
{
145
0
    g_autoptr(FuStructDpauxDpcd) st = fu_struct_dpaux_dpcd_new_internal();
146
0
    g_return_val_if_fail(buf != NULL, NULL);
147
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
148
0
    if (!fu_memchk_read(bufsz, offset, 13, error)) {
149
0
        g_prefix_error_literal(error, "invalid struct FuStructDpauxDpcd: ");
150
0
        return NULL;
151
0
    }
152
0
    st->buf = g_byte_array_new();
153
0
    g_byte_array_append(st->buf, buf + offset, 13);
154
0
    if (!fu_struct_dpaux_dpcd_parse_internal(st, error))
155
0
        return NULL;
156
0
    return g_steal_pointer(&st);
157
0
}