Coverage Report

Created: 2025-11-24 06:59

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
/**
43
 * fu_struct_dpaux_dpcd_new_internal: (skip):
44
 **/
45
static FuStructDpauxDpcd *
46
fu_struct_dpaux_dpcd_new_internal(void)
47
0
{
48
0
    FuStructDpauxDpcd *st = g_new0(FuStructDpauxDpcd, 1);
49
0
    st->refcount = 1;
50
0
    return st;
51
0
}
52
53
/* getters */
54
/**
55
 * fu_struct_dpaux_dpcd_get_ieee_oui: (skip):
56
 **/
57
guint32
58
fu_struct_dpaux_dpcd_get_ieee_oui(const FuStructDpauxDpcd *st)
59
0
{
60
0
    g_return_val_if_fail(st != NULL, 0x0);
61
0
    return fu_memread_uint24(st->buf->data + 0, G_BIG_ENDIAN);
62
0
}
63
/**
64
 * fu_struct_dpaux_dpcd_get_dev_id: (skip):
65
 **/
66
gchar *
67
fu_struct_dpaux_dpcd_get_dev_id(const FuStructDpauxDpcd *st)
68
0
{
69
0
    g_return_val_if_fail(st != NULL, NULL);
70
0
    return fu_memstrsafe(st->buf->data, st->buf->len, 3, 6, NULL);
71
0
}
72
/**
73
 * fu_struct_dpaux_dpcd_get_hw_rev: (skip):
74
 **/
75
guint8
76
fu_struct_dpaux_dpcd_get_hw_rev(const FuStructDpauxDpcd *st)
77
0
{
78
0
    g_return_val_if_fail(st != NULL, 0x0);
79
0
    return st->buf->data[9];
80
0
}
81
/**
82
 * fu_struct_dpaux_dpcd_get_fw_ver: (skip):
83
 **/
84
guint32
85
fu_struct_dpaux_dpcd_get_fw_ver(const FuStructDpauxDpcd *st)
86
0
{
87
0
    g_return_val_if_fail(st != NULL, 0x0);
88
0
    return fu_memread_uint24(st->buf->data + 10, G_BIG_ENDIAN);
89
0
}
90
91
/* setters */
92
/**
93
 * fu_struct_dpaux_dpcd_to_string: (skip):
94
 **/
95
static gchar *
96
fu_struct_dpaux_dpcd_to_string(const FuStructDpauxDpcd *st)
97
0
{
98
0
    g_autoptr(GString) str = g_string_new("FuStructDpauxDpcd:\n");
99
0
    g_return_val_if_fail(st != NULL, NULL);
100
0
    g_string_append_printf(str, "  ieee_oui: 0x%x\n",
101
0
                           (guint) fu_struct_dpaux_dpcd_get_ieee_oui(st));
102
0
    {
103
0
        g_autofree gchar *tmp = fu_struct_dpaux_dpcd_get_dev_id(st);
104
0
        if (tmp != NULL)
105
0
            g_string_append_printf(str, "  dev_id: %s\n", tmp);
106
0
    }
107
0
    g_string_append_printf(str, "  hw_rev: 0x%x\n",
108
0
                           (guint) fu_struct_dpaux_dpcd_get_hw_rev(st));
109
0
    g_string_append_printf(str, "  fw_ver: 0x%x\n",
110
0
                           (guint) fu_struct_dpaux_dpcd_get_fw_ver(st));
111
0
    if (str->len > 0)
112
0
        g_string_set_size(str, str->len - 1);
113
0
    return g_string_free(g_steal_pointer(&str), FALSE);
114
0
}
115
static gboolean
116
fu_struct_dpaux_dpcd_validate_internal(FuStructDpauxDpcd *st, GError **error)
117
0
{
118
0
    g_return_val_if_fail(st != NULL, FALSE);
119
0
    return TRUE;
120
0
}
121
static gboolean
122
fu_struct_dpaux_dpcd_parse_internal(FuStructDpauxDpcd *st, GError **error)
123
0
{
124
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
125
0
        g_autofree gchar *str = fu_struct_dpaux_dpcd_to_string(st);
126
0
        g_debug("%s", str);
127
0
    }
128
0
    if (!fu_struct_dpaux_dpcd_validate_internal(st, error))
129
0
        return FALSE;
130
0
    return TRUE;
131
0
}
132
133
/**
134
 * fu_struct_dpaux_dpcd_parse: (skip):
135
 **/
136
FuStructDpauxDpcd *
137
fu_struct_dpaux_dpcd_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
138
0
{
139
0
    g_autoptr(FuStructDpauxDpcd) st = fu_struct_dpaux_dpcd_new_internal();
140
0
    g_return_val_if_fail(buf != NULL, NULL);
141
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
142
0
    if (!fu_memchk_read(bufsz, offset, 13, error)) {
143
0
        g_prefix_error_literal(error, "invalid struct FuStructDpauxDpcd: ");
144
0
        return NULL;
145
0
    }
146
0
    st->buf = g_byte_array_new();
147
0
    g_byte_array_append(st->buf, buf + offset, 13);
148
0
    if (!fu_struct_dpaux_dpcd_parse_internal(st, error))
149
0
        return NULL;
150
0
    return g_steal_pointer(&st);
151
0
}