Coverage Report

Created: 2025-07-11 06:31

/work/fu-acpi-phat-struct.c
Line
Count
Source (jump to first uncovered line)
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include "fu-acpi-phat-struct.h"
5
#include "fu-byte-array.h"
6
#include "fu-mem-private.h"
7
#include "fu-string.h"
8
9
#ifdef G_LOG_DOMAIN
10
  #undef G_LOG_DOMAIN
11
#endif
12
0
#define G_LOG_DOMAIN "FuStruct"
13
/* getters */
14
/**
15
 * fu_struct_acpi_phat_hdr_get_magic: (skip):
16
 **/
17
static gchar *
18
fu_struct_acpi_phat_hdr_get_magic(const FuStructAcpiPhatHdr *st)
19
4.76M
{
20
4.76M
    g_return_val_if_fail(st != NULL, NULL);
21
4.76M
    return fu_memstrsafe(st->data, st->len, 0, 4, NULL);
22
4.76M
}
23
24
/* setters */
25
static gboolean
26
fu_struct_acpi_phat_hdr_validate_internal(FuStructAcpiPhatHdr *st, GError **error)
27
4.76M
{
28
4.76M
    g_return_val_if_fail(st != NULL, FALSE);
29
4.76M
    if (strncmp((const gchar *) (st->data + 0), "PHAT", 4) != 0) {
30
4.76M
        g_autofree gchar *str = fu_struct_acpi_phat_hdr_get_magic(st);
31
4.76M
        g_set_error(error,
32
4.76M
                    FWUPD_ERROR,
33
4.76M
                    FWUPD_ERROR_INVALID_DATA,
34
4.76M
                    "constant FuStructAcpiPhatHdr.magic was not valid, "
35
4.76M
                    "expected 'PHAT' and got '%s'",
36
4.76M
                    str);
37
4.76M
        return FALSE;
38
4.76M
    }
39
2.16k
    return TRUE;
40
4.76M
}
41
/**
42
 * fu_struct_acpi_phat_hdr_validate_stream: (skip):
43
 **/
44
gboolean
45
fu_struct_acpi_phat_hdr_validate_stream(GInputStream *stream, gsize offset, GError **error)
46
4.76M
{
47
4.76M
    g_autoptr(GByteArray) st = NULL;
48
4.76M
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
49
4.76M
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
50
4.76M
    st = fu_input_stream_read_byte_array(stream, offset, 4, NULL, error);
51
4.76M
    if (st == NULL) {
52
0
        g_prefix_error(error, "FuStructAcpiPhatHdr failed read of 0x%x: ", (guint) 4);
53
0
        return FALSE;
54
0
    }
55
4.76M
    if (st->len != 4) {
56
382
        g_set_error(error,
57
382
                    FWUPD_ERROR,
58
382
                    FWUPD_ERROR_INVALID_DATA,
59
382
                    "FuStructAcpiPhatHdr requested 0x%x and got 0x%x",
60
382
                    (guint) 4,
61
382
                    (guint) st->len);
62
382
        return FALSE;
63
382
    }
64
4.76M
    return fu_struct_acpi_phat_hdr_validate_internal(st, error);
65
4.76M
}
66
/* getters */
67
/**
68
 * fu_struct_acpi_phat_health_record_get_signature: (skip):
69
 **/
70
guint16
71
fu_struct_acpi_phat_health_record_get_signature(const FuStructAcpiPhatHealthRecord *st)
72
0
{
73
0
    g_return_val_if_fail(st != NULL, 0x0);
74
0
    return fu_memread_uint16(st->data + 0, G_LITTLE_ENDIAN);
75
0
}
76
/**
77
 * fu_struct_acpi_phat_health_record_get_rcdlen: (skip):
78
 **/
79
guint16
80
fu_struct_acpi_phat_health_record_get_rcdlen(const FuStructAcpiPhatHealthRecord *st)
81
2.03k
{
82
2.03k
    g_return_val_if_fail(st != NULL, 0x0);
83
2.03k
    return fu_memread_uint16(st->data + 2, G_LITTLE_ENDIAN);
84
2.03k
}
85
/**
86
 * fu_struct_acpi_phat_health_record_get_version: (skip):
87
 **/
88
guint8
89
fu_struct_acpi_phat_health_record_get_version(const FuStructAcpiPhatHealthRecord *st)
90
0
{
91
0
    g_return_val_if_fail(st != NULL, 0x0);
92
0
    return st->data[4];
93
0
}
94
/**
95
 * fu_struct_acpi_phat_health_record_get_flags: (skip):
96
 **/
97
guint8
98
fu_struct_acpi_phat_health_record_get_flags(const FuStructAcpiPhatHealthRecord *st)
99
2.03k
{
100
2.03k
    g_return_val_if_fail(st != NULL, 0x0);
101
2.03k
    return st->data[7];
102
2.03k
}
103
/**
104
 * fu_struct_acpi_phat_health_record_get_device_signature: (skip):
105
 **/
106
const fwupd_guid_t *
107
fu_struct_acpi_phat_health_record_get_device_signature(const FuStructAcpiPhatHealthRecord *st)
108
2.03k
{
109
2.03k
    g_return_val_if_fail(st != NULL, NULL);
110
2.03k
    return (const fwupd_guid_t *) (st->data + 8);
111
2.03k
}
112
/**
113
 * fu_struct_acpi_phat_health_record_get_device_specific_data: (skip):
114
 **/
115
guint32
116
fu_struct_acpi_phat_health_record_get_device_specific_data(const FuStructAcpiPhatHealthRecord *st)
117
2.03k
{
118
2.03k
    g_return_val_if_fail(st != NULL, 0x0);
119
2.03k
    return fu_memread_uint32(st->data + 24, G_LITTLE_ENDIAN);
120
2.03k
}
121
122
/* setters */
123
/**
124
 * fu_struct_acpi_phat_health_record_set_signature: (skip):
125
 **/
126
void
127
fu_struct_acpi_phat_health_record_set_signature(FuStructAcpiPhatHealthRecord *st, guint16 value)
128
735
{
129
735
    g_return_if_fail(st != NULL);
130
735
    fu_memwrite_uint16(st->data + 0, value, G_LITTLE_ENDIAN);
131
735
}
132
/**
133
 * fu_struct_acpi_phat_health_record_set_rcdlen: (skip):
134
 **/
135
void
136
fu_struct_acpi_phat_health_record_set_rcdlen(FuStructAcpiPhatHealthRecord *st, guint16 value)
137
735
{
138
735
    g_return_if_fail(st != NULL);
139
735
    fu_memwrite_uint16(st->data + 2, value, G_LITTLE_ENDIAN);
140
735
}
141
/**
142
 * fu_struct_acpi_phat_health_record_set_version: (skip):
143
 **/
144
void
145
fu_struct_acpi_phat_health_record_set_version(FuStructAcpiPhatHealthRecord *st, guint8 value)
146
735
{
147
735
    g_return_if_fail(st != NULL);
148
735
    st->data[4] = value;
149
735
}
150
/**
151
 * fu_struct_acpi_phat_health_record_set_flags: (skip):
152
 **/
153
void
154
fu_struct_acpi_phat_health_record_set_flags(FuStructAcpiPhatHealthRecord *st, guint8 value)
155
735
{
156
735
    g_return_if_fail(st != NULL);
157
735
    st->data[7] = value;
158
735
}
159
/**
160
 * fu_struct_acpi_phat_health_record_set_device_signature: (skip):
161
 **/
162
void
163
fu_struct_acpi_phat_health_record_set_device_signature(FuStructAcpiPhatHealthRecord *st, const fwupd_guid_t *value)
164
735
{
165
735
    g_return_if_fail(st != NULL);
166
735
    g_return_if_fail(value != NULL);
167
735
    memcpy(st->data + 8, value, sizeof(*value)); /* nocheck:blocked */
168
735
}
169
/**
170
 * fu_struct_acpi_phat_health_record_set_device_specific_data: (skip):
171
 **/
172
void
173
fu_struct_acpi_phat_health_record_set_device_specific_data(FuStructAcpiPhatHealthRecord *st, guint32 value)
174
0
{
175
0
    g_return_if_fail(st != NULL);
176
0
    fu_memwrite_uint32(st->data + 24, value, G_LITTLE_ENDIAN);
177
0
}
178
/**
179
 * fu_struct_acpi_phat_health_record_new: (skip):
180
 **/
181
FuStructAcpiPhatHealthRecord *
182
fu_struct_acpi_phat_health_record_new(void)
183
735
{
184
735
    FuStructAcpiPhatHealthRecord *st = g_byte_array_sized_new(28);
185
735
    fu_byte_array_set_size(st, 28, 0x0);
186
735
    fu_struct_acpi_phat_health_record_set_signature(st, 0x1);
187
735
    return st;
188
735
}
189
/**
190
 * fu_struct_acpi_phat_health_record_to_string: (skip):
191
 **/
192
static gchar *
193
fu_struct_acpi_phat_health_record_to_string(const FuStructAcpiPhatHealthRecord *st)
194
0
{
195
0
    g_autoptr(GString) str = g_string_new("FuStructAcpiPhatHealthRecord:\n");
196
0
    g_return_val_if_fail(st != NULL, NULL);
197
0
    g_string_append_printf(str, "  signature: 0x%x\n",
198
0
                           (guint) fu_struct_acpi_phat_health_record_get_signature(st));
199
0
    g_string_append_printf(str, "  rcdlen: 0x%x\n",
200
0
                           (guint) fu_struct_acpi_phat_health_record_get_rcdlen(st));
201
0
    g_string_append_printf(str, "  version: 0x%x\n",
202
0
                           (guint) fu_struct_acpi_phat_health_record_get_version(st));
203
0
    g_string_append_printf(str, "  flags: 0x%x\n",
204
0
                           (guint) fu_struct_acpi_phat_health_record_get_flags(st));
205
0
    {
206
0
        g_autofree gchar *tmp = fwupd_guid_to_string(fu_struct_acpi_phat_health_record_get_device_signature(st), FWUPD_GUID_FLAG_MIXED_ENDIAN);
207
0
        g_string_append_printf(str, "  device_signature: %s\n", tmp);
208
0
    }
209
0
    g_string_append_printf(str, "  device_specific_data: 0x%x\n",
210
0
                           (guint) fu_struct_acpi_phat_health_record_get_device_specific_data(st));
211
0
    if (str->len > 0)
212
0
        g_string_set_size(str, str->len - 1);
213
0
    return g_string_free(g_steal_pointer(&str), FALSE);
214
0
}
215
static gboolean
216
fu_struct_acpi_phat_health_record_validate_internal(FuStructAcpiPhatHealthRecord *st, GError **error)
217
2.03k
{
218
2.03k
    g_return_val_if_fail(st != NULL, FALSE);
219
2.03k
    return TRUE;
220
2.03k
}
221
static gboolean
222
fu_struct_acpi_phat_health_record_parse_internal(FuStructAcpiPhatHealthRecord *st, GError **error)
223
2.03k
{
224
2.03k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
225
0
        g_autofree gchar *str = fu_struct_acpi_phat_health_record_to_string(st);
226
0
        g_debug("%s", str);
227
0
    }
228
2.03k
    if (!fu_struct_acpi_phat_health_record_validate_internal(st, error))
229
0
        return FALSE;
230
2.03k
    return TRUE;
231
2.03k
}
232
/**
233
 * fu_struct_acpi_phat_health_record_parse_stream: (skip):
234
 **/
235
FuStructAcpiPhatHealthRecord *
236
fu_struct_acpi_phat_health_record_parse_stream(GInputStream *stream, gsize offset, GError **error)
237
2.06k
{
238
2.06k
    g_autoptr(GByteArray) st = NULL;
239
2.06k
    st = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
240
2.06k
    if (st == NULL) {
241
0
        g_prefix_error(error, "FuStructAcpiPhatHealthRecord failed read of 0x%x: ", (guint) 28);
242
0
        return NULL;
243
0
    }
244
2.06k
    if (st->len != 28) {
245
29
        g_set_error(error,
246
29
                    FWUPD_ERROR,
247
29
                    FWUPD_ERROR_INVALID_DATA,
248
29
                    "FuStructAcpiPhatHealthRecord requested 0x%x and got 0x%x",
249
29
                    (guint) 28,
250
29
                    (guint) st->len);
251
29
        return NULL;
252
29
    }
253
2.03k
    if (!fu_struct_acpi_phat_health_record_parse_internal(st, error))
254
0
        return NULL;
255
2.03k
    return g_steal_pointer(&st);
256
2.03k
}
257
/* getters */
258
/**
259
 * fu_struct_acpi_phat_version_element_get_component_id: (skip):
260
 **/
261
const fwupd_guid_t *
262
fu_struct_acpi_phat_version_element_get_component_id(const FuStructAcpiPhatVersionElement *st)
263
28.3k
{
264
28.3k
    g_return_val_if_fail(st != NULL, NULL);
265
28.3k
    return (const fwupd_guid_t *) (st->data + 0);
266
28.3k
}
267
/**
268
 * fu_struct_acpi_phat_version_element_get_version_value: (skip):
269
 **/
270
guint64
271
fu_struct_acpi_phat_version_element_get_version_value(const FuStructAcpiPhatVersionElement *st)
272
28.3k
{
273
28.3k
    g_return_val_if_fail(st != NULL, 0x0);
274
28.3k
    return fu_memread_uint64(st->data + 16, G_LITTLE_ENDIAN);
275
28.3k
}
276
/**
277
 * fu_struct_acpi_phat_version_element_get_producer_id: (skip):
278
 **/
279
gchar *
280
fu_struct_acpi_phat_version_element_get_producer_id(const FuStructAcpiPhatVersionElement *st)
281
28.3k
{
282
28.3k
    g_return_val_if_fail(st != NULL, NULL);
283
28.3k
    return fu_memstrsafe(st->data, st->len, 24, 4, NULL);
284
28.3k
}
285
286
/* setters */
287
/**
288
 * fu_struct_acpi_phat_version_element_set_component_id: (skip):
289
 **/
290
void
291
fu_struct_acpi_phat_version_element_set_component_id(FuStructAcpiPhatVersionElement *st, const fwupd_guid_t *value)
292
5.96k
{
293
5.96k
    g_return_if_fail(st != NULL);
294
5.96k
    g_return_if_fail(value != NULL);
295
5.96k
    memcpy(st->data + 0, value, sizeof(*value)); /* nocheck:blocked */
296
5.96k
}
297
/**
298
 * fu_struct_acpi_phat_version_element_set_version_value: (skip):
299
 **/
300
void
301
fu_struct_acpi_phat_version_element_set_version_value(FuStructAcpiPhatVersionElement *st, guint64 value)
302
5.96k
{
303
5.96k
    g_return_if_fail(st != NULL);
304
5.96k
    fu_memwrite_uint64(st->data + 16, value, G_LITTLE_ENDIAN);
305
5.96k
}
306
/**
307
 * fu_struct_acpi_phat_version_element_set_producer_id: (skip):
308
 **/
309
gboolean
310
fu_struct_acpi_phat_version_element_set_producer_id(FuStructAcpiPhatVersionElement *st, const gchar *value, GError **error)
311
5.96k
{
312
5.96k
    gsize len;
313
5.96k
    g_return_val_if_fail(st != NULL, FALSE);
314
5.96k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
315
5.96k
    if (value == NULL) {
316
3.43k
        memset(st->data + 24, 0x0, 4);
317
3.43k
        return TRUE;
318
3.43k
    }
319
2.52k
    len = strlen(value);
320
2.52k
    if (len > 4) {
321
0
        g_set_error(error,
322
0
                    FWUPD_ERROR,
323
0
                    FWUPD_ERROR_INVALID_DATA,
324
0
                    "string '%s' (0x%x bytes) does not fit in FuStructAcpiPhatVersionElement.producer_id (0x%x bytes)",
325
0
                    value, (guint) len, (guint) 4);
326
0
        return FALSE;
327
0
    }
328
2.52k
    return fu_memcpy_safe(st->data, st->len, 24, (const guint8 *)value, len, 0x0, len, error);
329
2.52k
}
330
/**
331
 * fu_struct_acpi_phat_version_element_new: (skip):
332
 **/
333
FuStructAcpiPhatVersionElement *
334
fu_struct_acpi_phat_version_element_new(void)
335
5.96k
{
336
5.96k
    FuStructAcpiPhatVersionElement *st = g_byte_array_sized_new(28);
337
5.96k
    fu_byte_array_set_size(st, 28, 0x0);
338
5.96k
    return st;
339
5.96k
}
340
/**
341
 * fu_struct_acpi_phat_version_element_to_string: (skip):
342
 **/
343
static gchar *
344
fu_struct_acpi_phat_version_element_to_string(const FuStructAcpiPhatVersionElement *st)
345
0
{
346
0
    g_autoptr(GString) str = g_string_new("FuStructAcpiPhatVersionElement:\n");
347
0
    g_return_val_if_fail(st != NULL, NULL);
348
0
    {
349
0
        g_autofree gchar *tmp = fwupd_guid_to_string(fu_struct_acpi_phat_version_element_get_component_id(st), FWUPD_GUID_FLAG_MIXED_ENDIAN);
350
0
        g_string_append_printf(str, "  component_id: %s\n", tmp);
351
0
    }
352
0
    g_string_append_printf(str, "  version_value: 0x%x\n",
353
0
                           (guint) fu_struct_acpi_phat_version_element_get_version_value(st));
354
0
    {
355
0
        g_autofree gchar *tmp = fu_struct_acpi_phat_version_element_get_producer_id(st);
356
0
        if (tmp != NULL)
357
0
            g_string_append_printf(str, "  producer_id: %s\n", tmp);
358
0
    }
359
0
    if (str->len > 0)
360
0
        g_string_set_size(str, str->len - 1);
361
0
    return g_string_free(g_steal_pointer(&str), FALSE);
362
0
}
363
static gboolean
364
fu_struct_acpi_phat_version_element_validate_internal(FuStructAcpiPhatVersionElement *st, GError **error)
365
28.3k
{
366
28.3k
    g_return_val_if_fail(st != NULL, FALSE);
367
28.3k
    return TRUE;
368
28.3k
}
369
static gboolean
370
fu_struct_acpi_phat_version_element_parse_internal(FuStructAcpiPhatVersionElement *st, GError **error)
371
28.3k
{
372
28.3k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
373
0
        g_autofree gchar *str = fu_struct_acpi_phat_version_element_to_string(st);
374
0
        g_debug("%s", str);
375
0
    }
376
28.3k
    if (!fu_struct_acpi_phat_version_element_validate_internal(st, error))
377
0
        return FALSE;
378
28.3k
    return TRUE;
379
28.3k
}
380
/**
381
 * fu_struct_acpi_phat_version_element_parse_stream: (skip):
382
 **/
383
FuStructAcpiPhatVersionElement *
384
fu_struct_acpi_phat_version_element_parse_stream(GInputStream *stream, gsize offset, GError **error)
385
28.3k
{
386
28.3k
    g_autoptr(GByteArray) st = NULL;
387
28.3k
    st = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
388
28.3k
    if (st == NULL) {
389
0
        g_prefix_error(error, "FuStructAcpiPhatVersionElement failed read of 0x%x: ", (guint) 28);
390
0
        return NULL;
391
0
    }
392
28.3k
    if (st->len != 28) {
393
0
        g_set_error(error,
394
0
                    FWUPD_ERROR,
395
0
                    FWUPD_ERROR_INVALID_DATA,
396
0
                    "FuStructAcpiPhatVersionElement requested 0x%x and got 0x%x",
397
0
                    (guint) 28,
398
0
                    (guint) st->len);
399
0
        return NULL;
400
0
    }
401
28.3k
    if (!fu_struct_acpi_phat_version_element_parse_internal(st, error))
402
0
        return NULL;
403
28.3k
    return g_steal_pointer(&st);
404
28.3k
}
405
/* getters */
406
/**
407
 * fu_struct_acpi_phat_version_record_get_signature: (skip):
408
 **/
409
guint16
410
fu_struct_acpi_phat_version_record_get_signature(const FuStructAcpiPhatVersionRecord *st)
411
0
{
412
0
    g_return_val_if_fail(st != NULL, 0x0);
413
0
    return fu_memread_uint16(st->data + 0, G_LITTLE_ENDIAN);
414
0
}
415
/**
416
 * fu_struct_acpi_phat_version_record_get_rcdlen: (skip):
417
 **/
418
guint16
419
fu_struct_acpi_phat_version_record_get_rcdlen(const FuStructAcpiPhatVersionRecord *st)
420
0
{
421
0
    g_return_val_if_fail(st != NULL, 0x0);
422
0
    return fu_memread_uint16(st->data + 2, G_LITTLE_ENDIAN);
423
0
}
424
/**
425
 * fu_struct_acpi_phat_version_record_get_version: (skip):
426
 **/
427
guint8
428
fu_struct_acpi_phat_version_record_get_version(const FuStructAcpiPhatVersionRecord *st)
429
0
{
430
0
    g_return_val_if_fail(st != NULL, 0x0);
431
0
    return st->data[4];
432
0
}
433
/**
434
 * fu_struct_acpi_phat_version_record_get_record_count: (skip):
435
 **/
436
guint32
437
fu_struct_acpi_phat_version_record_get_record_count(const FuStructAcpiPhatVersionRecord *st)
438
23.3k
{
439
23.3k
    g_return_val_if_fail(st != NULL, 0x0);
440
23.3k
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
441
23.3k
}
442
443
/* setters */
444
/**
445
 * fu_struct_acpi_phat_version_record_set_signature: (skip):
446
 **/
447
void
448
fu_struct_acpi_phat_version_record_set_signature(FuStructAcpiPhatVersionRecord *st, guint16 value)
449
7.68k
{
450
7.68k
    g_return_if_fail(st != NULL);
451
7.68k
    fu_memwrite_uint16(st->data + 0, value, G_LITTLE_ENDIAN);
452
7.68k
}
453
/**
454
 * fu_struct_acpi_phat_version_record_set_rcdlen: (skip):
455
 **/
456
void
457
fu_struct_acpi_phat_version_record_set_rcdlen(FuStructAcpiPhatVersionRecord *st, guint16 value)
458
7.68k
{
459
7.68k
    g_return_if_fail(st != NULL);
460
7.68k
    fu_memwrite_uint16(st->data + 2, value, G_LITTLE_ENDIAN);
461
7.68k
}
462
/**
463
 * fu_struct_acpi_phat_version_record_set_version: (skip):
464
 **/
465
void
466
fu_struct_acpi_phat_version_record_set_version(FuStructAcpiPhatVersionRecord *st, guint8 value)
467
7.68k
{
468
7.68k
    g_return_if_fail(st != NULL);
469
7.68k
    st->data[4] = value;
470
7.68k
}
471
/**
472
 * fu_struct_acpi_phat_version_record_set_record_count: (skip):
473
 **/
474
void
475
fu_struct_acpi_phat_version_record_set_record_count(FuStructAcpiPhatVersionRecord *st, guint32 value)
476
7.68k
{
477
7.68k
    g_return_if_fail(st != NULL);
478
7.68k
    fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN);
479
7.68k
}
480
/**
481
 * fu_struct_acpi_phat_version_record_new: (skip):
482
 **/
483
FuStructAcpiPhatVersionRecord *
484
fu_struct_acpi_phat_version_record_new(void)
485
7.68k
{
486
7.68k
    FuStructAcpiPhatVersionRecord *st = g_byte_array_sized_new(12);
487
7.68k
    fu_byte_array_set_size(st, 12, 0x0);
488
7.68k
    fu_struct_acpi_phat_version_record_set_signature(st, 0x0);
489
7.68k
    return st;
490
7.68k
}
491
/**
492
 * fu_struct_acpi_phat_version_record_to_string: (skip):
493
 **/
494
static gchar *
495
fu_struct_acpi_phat_version_record_to_string(const FuStructAcpiPhatVersionRecord *st)
496
0
{
497
0
    g_autoptr(GString) str = g_string_new("FuStructAcpiPhatVersionRecord:\n");
498
0
    g_return_val_if_fail(st != NULL, NULL);
499
0
    g_string_append_printf(str, "  signature: 0x%x\n",
500
0
                           (guint) fu_struct_acpi_phat_version_record_get_signature(st));
501
0
    g_string_append_printf(str, "  rcdlen: 0x%x\n",
502
0
                           (guint) fu_struct_acpi_phat_version_record_get_rcdlen(st));
503
0
    g_string_append_printf(str, "  version: 0x%x\n",
504
0
                           (guint) fu_struct_acpi_phat_version_record_get_version(st));
505
0
    g_string_append_printf(str, "  record_count: 0x%x\n",
506
0
                           (guint) fu_struct_acpi_phat_version_record_get_record_count(st));
507
0
    if (str->len > 0)
508
0
        g_string_set_size(str, str->len - 1);
509
0
    return g_string_free(g_steal_pointer(&str), FALSE);
510
0
}
511
static gboolean
512
fu_struct_acpi_phat_version_record_validate_internal(FuStructAcpiPhatVersionRecord *st, GError **error)
513
23.3k
{
514
23.3k
    g_return_val_if_fail(st != NULL, FALSE);
515
23.3k
    return TRUE;
516
23.3k
}
517
static gboolean
518
fu_struct_acpi_phat_version_record_parse_internal(FuStructAcpiPhatVersionRecord *st, GError **error)
519
23.3k
{
520
23.3k
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
521
0
        g_autofree gchar *str = fu_struct_acpi_phat_version_record_to_string(st);
522
0
        g_debug("%s", str);
523
0
    }
524
23.3k
    if (!fu_struct_acpi_phat_version_record_validate_internal(st, error))
525
0
        return FALSE;
526
23.3k
    return TRUE;
527
23.3k
}
528
/**
529
 * fu_struct_acpi_phat_version_record_parse_stream: (skip):
530
 **/
531
FuStructAcpiPhatVersionRecord *
532
fu_struct_acpi_phat_version_record_parse_stream(GInputStream *stream, gsize offset, GError **error)
533
23.3k
{
534
23.3k
    g_autoptr(GByteArray) st = NULL;
535
23.3k
    st = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error);
536
23.3k
    if (st == NULL) {
537
0
        g_prefix_error(error, "FuStructAcpiPhatVersionRecord failed read of 0x%x: ", (guint) 12);
538
0
        return NULL;
539
0
    }
540
23.3k
    if (st->len != 12) {
541
49
        g_set_error(error,
542
49
                    FWUPD_ERROR,
543
49
                    FWUPD_ERROR_INVALID_DATA,
544
49
                    "FuStructAcpiPhatVersionRecord requested 0x%x and got 0x%x",
545
49
                    (guint) 12,
546
49
                    (guint) st->len);
547
49
        return NULL;
548
49
    }
549
23.3k
    if (!fu_struct_acpi_phat_version_record_parse_internal(st, error))
550
0
        return NULL;
551
23.3k
    return g_steal_pointer(&st);
552
23.3k
}