Coverage Report

Created: 2025-08-26 06:55

/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.69M
{
20
4.69M
    g_return_val_if_fail(st != NULL, NULL);
21
4.69M
    return fu_memstrsafe(st->data, st->len, 0, 4, NULL);
22
4.69M
}
23
24
/* setters */
25
static gboolean
26
fu_struct_acpi_phat_hdr_validate_internal(FuStructAcpiPhatHdr *st, GError **error)
27
4.70M
{
28
4.70M
    g_return_val_if_fail(st != NULL, FALSE);
29
4.70M
    if (strncmp((const gchar *) (st->data + 0), "PHAT", 4) != 0) {
30
4.69M
        g_autofree gchar *str = fu_struct_acpi_phat_hdr_get_magic(st);
31
4.69M
        g_set_error(error,
32
4.69M
                    FWUPD_ERROR,
33
4.69M
                    FWUPD_ERROR_INVALID_DATA,
34
4.69M
                    "constant FuStructAcpiPhatHdr.magic was not valid, "
35
4.69M
                    "expected 'PHAT' and got '%s'",
36
4.69M
                    str);
37
4.69M
        return FALSE;
38
4.69M
    }
39
2.27k
    return TRUE;
40
4.70M
}
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.70M
{
47
4.70M
    g_autoptr(GByteArray) st = NULL;
48
4.70M
    g_return_val_if_fail(G_IS_INPUT_STREAM(stream), FALSE);
49
4.70M
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
50
4.70M
    st = fu_input_stream_read_byte_array(stream, offset, 4, NULL, error);
51
4.70M
    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.70M
    if (st->len != 4) {
56
405
        g_set_error(error,
57
405
                    FWUPD_ERROR,
58
405
                    FWUPD_ERROR_INVALID_DATA,
59
405
                    "FuStructAcpiPhatHdr requested 0x%x and got 0x%x",
60
405
                    (guint) 4,
61
405
                    (guint) st->len);
62
405
        return FALSE;
63
405
    }
64
4.70M
    return fu_struct_acpi_phat_hdr_validate_internal(st, error);
65
4.70M
}
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.07k
{
82
2.07k
    g_return_val_if_fail(st != NULL, 0x0);
83
2.07k
    return fu_memread_uint16(st->data + 2, G_LITTLE_ENDIAN);
84
2.07k
}
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.07k
{
100
2.07k
    g_return_val_if_fail(st != NULL, 0x0);
101
2.07k
    return st->data[7];
102
2.07k
}
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.07k
{
109
2.07k
    g_return_val_if_fail(st != NULL, NULL);
110
2.07k
    return (const fwupd_guid_t *) (st->data + 8);
111
2.07k
}
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.07k
{
118
2.07k
    g_return_val_if_fail(st != NULL, 0x0);
119
2.07k
    return fu_memread_uint32(st->data + 24, G_LITTLE_ENDIAN);
120
2.07k
}
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
763
{
129
763
    g_return_if_fail(st != NULL);
130
763
    fu_memwrite_uint16(st->data + 0, value, G_LITTLE_ENDIAN);
131
763
}
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
763
{
138
763
    g_return_if_fail(st != NULL);
139
763
    fu_memwrite_uint16(st->data + 2, value, G_LITTLE_ENDIAN);
140
763
}
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
763
{
147
763
    g_return_if_fail(st != NULL);
148
763
    st->data[4] = value;
149
763
}
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
763
{
156
763
    g_return_if_fail(st != NULL);
157
763
    st->data[7] = value;
158
763
}
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
763
{
165
763
    g_return_if_fail(st != NULL);
166
763
    g_return_if_fail(value != NULL);
167
763
    memcpy(st->data + 8, value, sizeof(*value)); /* nocheck:blocked */
168
763
}
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
763
{
184
763
    FuStructAcpiPhatHealthRecord *st = g_byte_array_sized_new(28);
185
763
    fu_byte_array_set_size(st, 28, 0x0);
186
763
    fu_struct_acpi_phat_health_record_set_signature(st, 0x1);
187
763
    return st;
188
763
}
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.07k
{
218
2.07k
    g_return_val_if_fail(st != NULL, FALSE);
219
2.07k
    return TRUE;
220
2.07k
}
221
static gboolean
222
fu_struct_acpi_phat_health_record_parse_internal(FuStructAcpiPhatHealthRecord *st, GError **error)
223
2.07k
{
224
2.07k
    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.07k
    if (!fu_struct_acpi_phat_health_record_validate_internal(st, error))
229
0
        return FALSE;
230
2.07k
    return TRUE;
231
2.07k
}
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.10k
{
238
2.10k
    g_autoptr(GByteArray) st = NULL;
239
2.10k
    st = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
240
2.10k
    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.10k
    if (st->len != 28) {
245
33
        g_set_error(error,
246
33
                    FWUPD_ERROR,
247
33
                    FWUPD_ERROR_INVALID_DATA,
248
33
                    "FuStructAcpiPhatHealthRecord requested 0x%x and got 0x%x",
249
33
                    (guint) 28,
250
33
                    (guint) st->len);
251
33
        return NULL;
252
33
    }
253
2.07k
    if (!fu_struct_acpi_phat_health_record_parse_internal(st, error))
254
0
        return NULL;
255
2.07k
    return g_steal_pointer(&st);
256
2.07k
}
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
31.5k
{
264
31.5k
    g_return_val_if_fail(st != NULL, NULL);
265
31.5k
    return (const fwupd_guid_t *) (st->data + 0);
266
31.5k
}
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
31.5k
{
273
31.5k
    g_return_val_if_fail(st != NULL, 0x0);
274
31.5k
    return fu_memread_uint64(st->data + 16, G_LITTLE_ENDIAN);
275
31.5k
}
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
31.5k
{
282
31.5k
    g_return_val_if_fail(st != NULL, NULL);
283
31.5k
    return fu_memstrsafe(st->data, st->len, 24, 4, NULL);
284
31.5k
}
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
6.98k
{
293
6.98k
    g_return_if_fail(st != NULL);
294
6.98k
    g_return_if_fail(value != NULL);
295
6.98k
    memcpy(st->data + 0, value, sizeof(*value)); /* nocheck:blocked */
296
6.98k
}
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
6.98k
{
303
6.98k
    g_return_if_fail(st != NULL);
304
6.98k
    fu_memwrite_uint64(st->data + 16, value, G_LITTLE_ENDIAN);
305
6.98k
}
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
6.98k
{
312
6.98k
    gsize len;
313
6.98k
    g_return_val_if_fail(st != NULL, FALSE);
314
6.98k
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
315
6.98k
    if (value == NULL) {
316
3.67k
        memset(st->data + 24, 0x0, 4);
317
3.67k
        return TRUE;
318
3.67k
    }
319
3.30k
    len = strlen(value);
320
3.30k
    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
3.30k
    return fu_memcpy_safe(st->data, st->len, 24, (const guint8 *)value, len, 0x0, len, error);
329
3.30k
}
330
/**
331
 * fu_struct_acpi_phat_version_element_new: (skip):
332
 **/
333
FuStructAcpiPhatVersionElement *
334
fu_struct_acpi_phat_version_element_new(void)
335
6.98k
{
336
6.98k
    FuStructAcpiPhatVersionElement *st = g_byte_array_sized_new(28);
337
6.98k
    fu_byte_array_set_size(st, 28, 0x0);
338
6.98k
    return st;
339
6.98k
}
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
31.5k
{
366
31.5k
    g_return_val_if_fail(st != NULL, FALSE);
367
31.5k
    return TRUE;
368
31.5k
}
369
static gboolean
370
fu_struct_acpi_phat_version_element_parse_internal(FuStructAcpiPhatVersionElement *st, GError **error)
371
31.5k
{
372
31.5k
    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
31.5k
    if (!fu_struct_acpi_phat_version_element_validate_internal(st, error))
377
0
        return FALSE;
378
31.5k
    return TRUE;
379
31.5k
}
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
31.5k
{
386
31.5k
    g_autoptr(GByteArray) st = NULL;
387
31.5k
    st = fu_input_stream_read_byte_array(stream, offset, 28, NULL, error);
388
31.5k
    if (st == NULL) {
389
0
        g_prefix_error(error, "FuStructAcpiPhatVersionElement failed read of 0x%x: ", (guint) 28);
390
0
        return NULL;
391
0
    }
392
31.5k
    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
31.5k
    if (!fu_struct_acpi_phat_version_element_parse_internal(st, error))
402
0
        return NULL;
403
31.5k
    return g_steal_pointer(&st);
404
31.5k
}
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
21.2k
{
439
21.2k
    g_return_val_if_fail(st != NULL, 0x0);
440
21.2k
    return fu_memread_uint32(st->data + 8, G_LITTLE_ENDIAN);
441
21.2k
}
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
5.91k
{
450
5.91k
    g_return_if_fail(st != NULL);
451
5.91k
    fu_memwrite_uint16(st->data + 0, value, G_LITTLE_ENDIAN);
452
5.91k
}
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
5.91k
{
459
5.91k
    g_return_if_fail(st != NULL);
460
5.91k
    fu_memwrite_uint16(st->data + 2, value, G_LITTLE_ENDIAN);
461
5.91k
}
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
5.91k
{
468
5.91k
    g_return_if_fail(st != NULL);
469
5.91k
    st->data[4] = value;
470
5.91k
}
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
5.91k
{
477
5.91k
    g_return_if_fail(st != NULL);
478
5.91k
    fu_memwrite_uint32(st->data + 8, value, G_LITTLE_ENDIAN);
479
5.91k
}
480
/**
481
 * fu_struct_acpi_phat_version_record_new: (skip):
482
 **/
483
FuStructAcpiPhatVersionRecord *
484
fu_struct_acpi_phat_version_record_new(void)
485
5.91k
{
486
5.91k
    FuStructAcpiPhatVersionRecord *st = g_byte_array_sized_new(12);
487
5.91k
    fu_byte_array_set_size(st, 12, 0x0);
488
5.91k
    fu_struct_acpi_phat_version_record_set_signature(st, 0x0);
489
5.91k
    return st;
490
5.91k
}
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
21.2k
{
514
21.2k
    g_return_val_if_fail(st != NULL, FALSE);
515
21.2k
    return TRUE;
516
21.2k
}
517
static gboolean
518
fu_struct_acpi_phat_version_record_parse_internal(FuStructAcpiPhatVersionRecord *st, GError **error)
519
21.2k
{
520
21.2k
    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
21.2k
    if (!fu_struct_acpi_phat_version_record_validate_internal(st, error))
525
0
        return FALSE;
526
21.2k
    return TRUE;
527
21.2k
}
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
21.3k
{
534
21.3k
    g_autoptr(GByteArray) st = NULL;
535
21.3k
    st = fu_input_stream_read_byte_array(stream, offset, 12, NULL, error);
536
21.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
21.3k
    if (st->len != 12) {
541
53
        g_set_error(error,
542
53
                    FWUPD_ERROR,
543
53
                    FWUPD_ERROR_INVALID_DATA,
544
53
                    "FuStructAcpiPhatVersionRecord requested 0x%x and got 0x%x",
545
53
                    (guint) 12,
546
53
                    (guint) st->len);
547
53
        return NULL;
548
53
    }
549
21.2k
    if (!fu_struct_acpi_phat_version_record_parse_internal(st, error))
550
0
        return NULL;
551
21.2k
    return g_steal_pointer(&st);
552
21.2k
}