Coverage Report

Created: 2025-11-11 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-pxi-struct.c
Line
Count
Source
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include <glib.h>
5
6
#include "fu-pxi-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
const gchar *
17
fu_pxi_ota_spec_check_result_to_string(FuPxiOtaSpecCheckResult val)
18
0
{
19
0
    if (val == FU_PXI_OTA_SPEC_CHECK_RESULT_OK)
20
0
        return "ok";
21
0
    if (val == FU_PXI_OTA_SPEC_CHECK_RESULT_FW_OUT_OF_BOUNDS)
22
0
        return "fw-out-of-bounds";
23
0
    if (val == FU_PXI_OTA_SPEC_CHECK_RESULT_PROCESS_ILLEGAL)
24
0
        return "process-illegal";
25
0
    if (val == FU_PXI_OTA_SPEC_CHECK_RESULT_RECONNECT)
26
0
        return "reconnect";
27
0
    if (val == FU_PXI_OTA_SPEC_CHECK_RESULT_FW_IMG_VERSION_ERROR)
28
0
        return "fw-img-version-error";
29
0
    if (val == FU_PXI_OTA_SPEC_CHECK_RESULT_DEVICE_LOW_BATTERY)
30
0
        return "device-low-battery";
31
0
    return NULL;
32
0
}
33
34
const gchar *
35
fu_pxi_wireless_module_ota_rsp_code_to_string(FuPxiWirelessModuleOtaRspCode val)
36
0
{
37
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_OK)
38
0
        return "ok";
39
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_FINISH)
40
0
        return "finish";
41
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_FAIL)
42
0
        return "fail";
43
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_ERROR)
44
0
        return "error";
45
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_WRITE_PKT_LEN_ERROR)
46
0
        return "write-pkt-len-error";
47
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_WRITE_PKT_TOTAL_SIZE_ERROR)
48
0
        return "write-pkt-total-size-error";
49
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_READ_PKT_LEN_ERROR)
50
0
        return "read-pkt-len-error";
51
0
    if (val == FU_PXI_WIRELESS_MODULE_OTA_RSP_CODE_NOT_READY)
52
0
        return "not-ready";
53
0
    return NULL;
54
0
}
55
56
57
58
/**
59
 * fu_struct_pxi_ota_fw_state_ref: (skip):
60
 **/
61
FuStructPxiOtaFwState *
62
fu_struct_pxi_ota_fw_state_ref(FuStructPxiOtaFwState *st)
63
0
{
64
0
    g_return_val_if_fail(st != NULL, NULL);
65
0
    st->refcount++;
66
0
    return st;
67
0
}
68
/**
69
 * fu_struct_pxi_ota_fw_state_unref: (skip):
70
 **/
71
void
72
fu_struct_pxi_ota_fw_state_unref(FuStructPxiOtaFwState *st)
73
0
{
74
0
    g_return_if_fail(st != NULL);
75
0
    if (st->refcount == 0) {
76
0
        g_critical("FuStructPxiOtaFwState refcount already zero");
77
0
        return;
78
0
    }
79
0
    if (--st->refcount > 0)
80
0
        return;
81
0
    if (st->buf != NULL)
82
0
        g_byte_array_unref(st->buf);
83
0
    g_free(st);
84
0
}
85
static FuStructPxiOtaFwState *
86
fu_struct_pxi_ota_fw_state_new_internal(void)
87
0
{
88
0
    FuStructPxiOtaFwState *st = g_new0(FuStructPxiOtaFwState, 1);
89
0
    st->refcount = 1;
90
0
    return st;
91
0
}
92
93
/* getters */
94
/**
95
 * fu_struct_pxi_ota_fw_state_get_status: (skip):
96
 **/
97
guint8
98
fu_struct_pxi_ota_fw_state_get_status(const FuStructPxiOtaFwState *st)
99
0
{
100
0
    g_return_val_if_fail(st != NULL, 0x0);
101
0
    return st->buf->data[0];
102
0
}
103
/**
104
 * fu_struct_pxi_ota_fw_state_get_new_flow: (skip):
105
 **/
106
guint8
107
fu_struct_pxi_ota_fw_state_get_new_flow(const FuStructPxiOtaFwState *st)
108
0
{
109
0
    g_return_val_if_fail(st != NULL, 0x0);
110
0
    return st->buf->data[1];
111
0
}
112
/**
113
 * fu_struct_pxi_ota_fw_state_get_offset: (skip):
114
 **/
115
guint16
116
fu_struct_pxi_ota_fw_state_get_offset(const FuStructPxiOtaFwState *st)
117
0
{
118
0
    g_return_val_if_fail(st != NULL, 0x0);
119
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
120
0
}
121
/**
122
 * fu_struct_pxi_ota_fw_state_get_checksum: (skip):
123
 **/
124
guint16
125
fu_struct_pxi_ota_fw_state_get_checksum(const FuStructPxiOtaFwState *st)
126
0
{
127
0
    g_return_val_if_fail(st != NULL, 0x0);
128
0
    return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN);
129
0
}
130
/**
131
 * fu_struct_pxi_ota_fw_state_get_max_object_size: (skip):
132
 **/
133
guint32
134
fu_struct_pxi_ota_fw_state_get_max_object_size(const FuStructPxiOtaFwState *st)
135
0
{
136
0
    g_return_val_if_fail(st != NULL, 0x0);
137
0
    return fu_memread_uint32(st->buf->data + 6, G_LITTLE_ENDIAN);
138
0
}
139
/**
140
 * fu_struct_pxi_ota_fw_state_get_mtu_size: (skip):
141
 **/
142
guint16
143
fu_struct_pxi_ota_fw_state_get_mtu_size(const FuStructPxiOtaFwState *st)
144
0
{
145
0
    g_return_val_if_fail(st != NULL, 0x0);
146
0
    return fu_memread_uint16(st->buf->data + 10, G_LITTLE_ENDIAN);
147
0
}
148
/**
149
 * fu_struct_pxi_ota_fw_state_get_prn_threshold: (skip):
150
 **/
151
guint16
152
fu_struct_pxi_ota_fw_state_get_prn_threshold(const FuStructPxiOtaFwState *st)
153
0
{
154
0
    g_return_val_if_fail(st != NULL, 0x0);
155
0
    return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN);
156
0
}
157
/**
158
 * fu_struct_pxi_ota_fw_state_get_spec_check_result: (skip):
159
 **/
160
guint8
161
fu_struct_pxi_ota_fw_state_get_spec_check_result(const FuStructPxiOtaFwState *st)
162
0
{
163
0
    g_return_val_if_fail(st != NULL, 0x0);
164
0
    return st->buf->data[14];
165
0
}
166
167
/* setters */
168
/**
169
 * fu_struct_pxi_ota_fw_state_to_string: (skip):
170
 **/
171
static gchar *
172
fu_struct_pxi_ota_fw_state_to_string(const FuStructPxiOtaFwState *st)
173
0
{
174
0
    g_autoptr(GString) str = g_string_new("FuStructPxiOtaFwState:\n");
175
0
    g_return_val_if_fail(st != NULL, NULL);
176
0
    g_string_append_printf(str, "  status: 0x%x\n",
177
0
                           (guint) fu_struct_pxi_ota_fw_state_get_status(st));
178
0
    g_string_append_printf(str, "  new_flow: 0x%x\n",
179
0
                           (guint) fu_struct_pxi_ota_fw_state_get_new_flow(st));
180
0
    g_string_append_printf(str, "  offset: 0x%x\n",
181
0
                           (guint) fu_struct_pxi_ota_fw_state_get_offset(st));
182
0
    g_string_append_printf(str, "  checksum: 0x%x\n",
183
0
                           (guint) fu_struct_pxi_ota_fw_state_get_checksum(st));
184
0
    g_string_append_printf(str, "  max_object_size: 0x%x\n",
185
0
                           (guint) fu_struct_pxi_ota_fw_state_get_max_object_size(st));
186
0
    g_string_append_printf(str, "  mtu_size: 0x%x\n",
187
0
                           (guint) fu_struct_pxi_ota_fw_state_get_mtu_size(st));
188
0
    g_string_append_printf(str, "  prn_threshold: 0x%x\n",
189
0
                           (guint) fu_struct_pxi_ota_fw_state_get_prn_threshold(st));
190
0
    g_string_append_printf(str, "  spec_check_result: 0x%x\n",
191
0
                           (guint) fu_struct_pxi_ota_fw_state_get_spec_check_result(st));
192
0
    if (str->len > 0)
193
0
        g_string_set_size(str, str->len - 1);
194
0
    return g_string_free(g_steal_pointer(&str), FALSE);
195
0
}
196
static gboolean
197
fu_struct_pxi_ota_fw_state_validate_internal(FuStructPxiOtaFwState *st, GError **error)
198
0
{
199
0
    g_return_val_if_fail(st != NULL, FALSE);
200
0
    return TRUE;
201
0
}
202
static gboolean
203
fu_struct_pxi_ota_fw_state_parse_internal(FuStructPxiOtaFwState *st, GError **error)
204
0
{
205
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
206
0
        g_autofree gchar *str = fu_struct_pxi_ota_fw_state_to_string(st);
207
0
        g_debug("%s", str);
208
0
    }
209
0
    if (!fu_struct_pxi_ota_fw_state_validate_internal(st, error))
210
0
        return FALSE;
211
0
    return TRUE;
212
0
}
213
214
/**
215
 * fu_struct_pxi_ota_fw_state_parse: (skip):
216
 **/
217
FuStructPxiOtaFwState *
218
fu_struct_pxi_ota_fw_state_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
219
0
{
220
0
    g_autoptr(FuStructPxiOtaFwState) st = fu_struct_pxi_ota_fw_state_new_internal();
221
0
    g_return_val_if_fail(buf != NULL, NULL);
222
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
223
0
    if (!fu_memchk_read(bufsz, offset, 15, error)) {
224
0
        g_prefix_error_literal(error, "invalid struct FuStructPxiOtaFwState: ");
225
0
        return NULL;
226
0
    }
227
0
    st->buf = g_byte_array_new();
228
0
    g_byte_array_append(st->buf, buf + offset, 15);
229
0
    if (!fu_struct_pxi_ota_fw_state_parse_internal(st, error))
230
0
        return NULL;
231
0
    return g_steal_pointer(&st);
232
0
}