Coverage Report

Created: 2025-11-24 06:59

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
/**
86
 * fu_struct_pxi_ota_fw_state_new_internal: (skip):
87
 **/
88
static FuStructPxiOtaFwState *
89
fu_struct_pxi_ota_fw_state_new_internal(void)
90
0
{
91
0
    FuStructPxiOtaFwState *st = g_new0(FuStructPxiOtaFwState, 1);
92
0
    st->refcount = 1;
93
0
    return st;
94
0
}
95
96
/* getters */
97
/**
98
 * fu_struct_pxi_ota_fw_state_get_status: (skip):
99
 **/
100
guint8
101
fu_struct_pxi_ota_fw_state_get_status(const FuStructPxiOtaFwState *st)
102
0
{
103
0
    g_return_val_if_fail(st != NULL, 0x0);
104
0
    return st->buf->data[0];
105
0
}
106
/**
107
 * fu_struct_pxi_ota_fw_state_get_new_flow: (skip):
108
 **/
109
guint8
110
fu_struct_pxi_ota_fw_state_get_new_flow(const FuStructPxiOtaFwState *st)
111
0
{
112
0
    g_return_val_if_fail(st != NULL, 0x0);
113
0
    return st->buf->data[1];
114
0
}
115
/**
116
 * fu_struct_pxi_ota_fw_state_get_offset: (skip):
117
 **/
118
guint16
119
fu_struct_pxi_ota_fw_state_get_offset(const FuStructPxiOtaFwState *st)
120
0
{
121
0
    g_return_val_if_fail(st != NULL, 0x0);
122
0
    return fu_memread_uint16(st->buf->data + 2, G_LITTLE_ENDIAN);
123
0
}
124
/**
125
 * fu_struct_pxi_ota_fw_state_get_checksum: (skip):
126
 **/
127
guint16
128
fu_struct_pxi_ota_fw_state_get_checksum(const FuStructPxiOtaFwState *st)
129
0
{
130
0
    g_return_val_if_fail(st != NULL, 0x0);
131
0
    return fu_memread_uint16(st->buf->data + 4, G_LITTLE_ENDIAN);
132
0
}
133
/**
134
 * fu_struct_pxi_ota_fw_state_get_max_object_size: (skip):
135
 **/
136
guint32
137
fu_struct_pxi_ota_fw_state_get_max_object_size(const FuStructPxiOtaFwState *st)
138
0
{
139
0
    g_return_val_if_fail(st != NULL, 0x0);
140
0
    return fu_memread_uint32(st->buf->data + 6, G_LITTLE_ENDIAN);
141
0
}
142
/**
143
 * fu_struct_pxi_ota_fw_state_get_mtu_size: (skip):
144
 **/
145
guint16
146
fu_struct_pxi_ota_fw_state_get_mtu_size(const FuStructPxiOtaFwState *st)
147
0
{
148
0
    g_return_val_if_fail(st != NULL, 0x0);
149
0
    return fu_memread_uint16(st->buf->data + 10, G_LITTLE_ENDIAN);
150
0
}
151
/**
152
 * fu_struct_pxi_ota_fw_state_get_prn_threshold: (skip):
153
 **/
154
guint16
155
fu_struct_pxi_ota_fw_state_get_prn_threshold(const FuStructPxiOtaFwState *st)
156
0
{
157
0
    g_return_val_if_fail(st != NULL, 0x0);
158
0
    return fu_memread_uint16(st->buf->data + 12, G_LITTLE_ENDIAN);
159
0
}
160
/**
161
 * fu_struct_pxi_ota_fw_state_get_spec_check_result: (skip):
162
 **/
163
guint8
164
fu_struct_pxi_ota_fw_state_get_spec_check_result(const FuStructPxiOtaFwState *st)
165
0
{
166
0
    g_return_val_if_fail(st != NULL, 0x0);
167
0
    return st->buf->data[14];
168
0
}
169
170
/* setters */
171
/**
172
 * fu_struct_pxi_ota_fw_state_to_string: (skip):
173
 **/
174
static gchar *
175
fu_struct_pxi_ota_fw_state_to_string(const FuStructPxiOtaFwState *st)
176
0
{
177
0
    g_autoptr(GString) str = g_string_new("FuStructPxiOtaFwState:\n");
178
0
    g_return_val_if_fail(st != NULL, NULL);
179
0
    g_string_append_printf(str, "  status: 0x%x\n",
180
0
                           (guint) fu_struct_pxi_ota_fw_state_get_status(st));
181
0
    g_string_append_printf(str, "  new_flow: 0x%x\n",
182
0
                           (guint) fu_struct_pxi_ota_fw_state_get_new_flow(st));
183
0
    g_string_append_printf(str, "  offset: 0x%x\n",
184
0
                           (guint) fu_struct_pxi_ota_fw_state_get_offset(st));
185
0
    g_string_append_printf(str, "  checksum: 0x%x\n",
186
0
                           (guint) fu_struct_pxi_ota_fw_state_get_checksum(st));
187
0
    g_string_append_printf(str, "  max_object_size: 0x%x\n",
188
0
                           (guint) fu_struct_pxi_ota_fw_state_get_max_object_size(st));
189
0
    g_string_append_printf(str, "  mtu_size: 0x%x\n",
190
0
                           (guint) fu_struct_pxi_ota_fw_state_get_mtu_size(st));
191
0
    g_string_append_printf(str, "  prn_threshold: 0x%x\n",
192
0
                           (guint) fu_struct_pxi_ota_fw_state_get_prn_threshold(st));
193
0
    g_string_append_printf(str, "  spec_check_result: 0x%x\n",
194
0
                           (guint) fu_struct_pxi_ota_fw_state_get_spec_check_result(st));
195
0
    if (str->len > 0)
196
0
        g_string_set_size(str, str->len - 1);
197
0
    return g_string_free(g_steal_pointer(&str), FALSE);
198
0
}
199
static gboolean
200
fu_struct_pxi_ota_fw_state_validate_internal(FuStructPxiOtaFwState *st, GError **error)
201
0
{
202
0
    g_return_val_if_fail(st != NULL, FALSE);
203
0
    return TRUE;
204
0
}
205
static gboolean
206
fu_struct_pxi_ota_fw_state_parse_internal(FuStructPxiOtaFwState *st, GError **error)
207
0
{
208
0
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
209
0
        g_autofree gchar *str = fu_struct_pxi_ota_fw_state_to_string(st);
210
0
        g_debug("%s", str);
211
0
    }
212
0
    if (!fu_struct_pxi_ota_fw_state_validate_internal(st, error))
213
0
        return FALSE;
214
0
    return TRUE;
215
0
}
216
217
/**
218
 * fu_struct_pxi_ota_fw_state_parse: (skip):
219
 **/
220
FuStructPxiOtaFwState *
221
fu_struct_pxi_ota_fw_state_parse(const guint8 *buf, gsize bufsz, gsize offset, GError **error)
222
0
{
223
0
    g_autoptr(FuStructPxiOtaFwState) st = fu_struct_pxi_ota_fw_state_new_internal();
224
0
    g_return_val_if_fail(buf != NULL, NULL);
225
0
    g_return_val_if_fail(error == NULL || *error == NULL, NULL);
226
0
    if (!fu_memchk_read(bufsz, offset, 15, error)) {
227
0
        g_prefix_error_literal(error, "invalid struct FuStructPxiOtaFwState: ");
228
0
        return NULL;
229
0
    }
230
0
    st->buf = g_byte_array_new();
231
0
    g_byte_array_append(st->buf, buf + offset, 15);
232
0
    if (!fu_struct_pxi_ota_fw_state_parse_internal(st, error))
233
0
        return NULL;
234
0
    return g_steal_pointer(&st);
235
0
}