Coverage Report

Created: 2025-11-11 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/fu-edid-struct.c
Line
Count
Source
1
/* auto-generated, do not modify */
2
#include "config.h"
3
4
#include <glib.h>
5
6
#include "fu-edid-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
static const gchar *
17
fu_edid_descriptor_tag_to_string(FuEdidDescriptorTag val)
18
0
{
19
0
    if (val == FU_EDID_DESCRIPTOR_TAG_DISPLAY_PRODUCT_SERIAL_NUMBER)
20
0
        return "display-product-serial-number";
21
0
    if (val == FU_EDID_DESCRIPTOR_TAG_ALPHANUMERIC_DATA_STRING)
22
0
        return "alphanumeric-data-string";
23
0
    if (val == FU_EDID_DESCRIPTOR_TAG_DISPLAY_RANGE_LIMITS)
24
0
        return "display-range-limits";
25
0
    if (val == FU_EDID_DESCRIPTOR_TAG_DISPLAY_PRODUCT_NAME)
26
0
        return "display-product-name";
27
0
    if (val == FU_EDID_DESCRIPTOR_TAG_COLOR_POINT_DATA)
28
0
        return "color-point-data";
29
0
    if (val == FU_EDID_DESCRIPTOR_TAG_STANDARD_TIMING_IDENTIFICATIONS)
30
0
        return "standard-timing-identifications";
31
0
    if (val == FU_EDID_DESCRIPTOR_TAG_DISPLAY_COLOR_MANAGEMENT_DATA)
32
0
        return "display-color-management-data";
33
0
    if (val == FU_EDID_DESCRIPTOR_TAG_CVT_TIMING_CODES)
34
0
        return "cvt-timing-codes";
35
0
    if (val == FU_EDID_DESCRIPTOR_TAG_ESTABLISHED_TIMINGS)
36
0
        return "established-timings";
37
0
    if (val == FU_EDID_DESCRIPTOR_TAG_DUMMY_DESCRIPTOR)
38
0
        return "dummy-descriptor";
39
0
    return NULL;
40
0
}
41
/**
42
 * fu_struct_edid_descriptor_ref: (skip):
43
 **/
44
FuStructEdidDescriptor *
45
fu_struct_edid_descriptor_ref(FuStructEdidDescriptor *st)
46
0
{
47
0
    g_return_val_if_fail(st != NULL, NULL);
48
0
    st->refcount++;
49
0
    return st;
50
0
}
51
/**
52
 * fu_struct_edid_descriptor_unref: (skip):
53
 **/
54
void
55
fu_struct_edid_descriptor_unref(FuStructEdidDescriptor *st)
56
1.16k
{
57
1.16k
    g_return_if_fail(st != NULL);
58
1.16k
    if (st->refcount == 0) {
59
0
        g_critical("FuStructEdidDescriptor refcount already zero");
60
0
        return;
61
0
    }
62
1.16k
    if (--st->refcount > 0)
63
0
        return;
64
1.16k
    if (st->buf != NULL)
65
1.16k
        g_byte_array_unref(st->buf);
66
1.16k
    g_free(st);
67
1.16k
}
68
static FuStructEdidDescriptor *
69
fu_struct_edid_descriptor_new_internal(void)
70
1.16k
{
71
1.16k
    FuStructEdidDescriptor *st = g_new0(FuStructEdidDescriptor, 1);
72
1.16k
    st->refcount = 1;
73
1.16k
    return st;
74
1.16k
}
75
76
/* getters */
77
/**
78
 * fu_struct_edid_descriptor_get_kind: (skip):
79
 **/
80
guint16
81
fu_struct_edid_descriptor_get_kind(const FuStructEdidDescriptor *st)
82
924
{
83
924
    g_return_val_if_fail(st != NULL, 0x0);
84
924
    return fu_memread_uint16(st->buf->data + 0, G_LITTLE_ENDIAN);
85
924
}
86
/**
87
 * fu_struct_edid_descriptor_get_subkind: (skip):
88
 **/
89
guint8
90
fu_struct_edid_descriptor_get_subkind(const FuStructEdidDescriptor *st)
91
371
{
92
371
    g_return_val_if_fail(st != NULL, 0x0);
93
371
    return st->buf->data[2];
94
371
}
95
/**
96
 * fu_struct_edid_descriptor_get_tag: (skip):
97
 **/
98
FuEdidDescriptorTag
99
fu_struct_edid_descriptor_get_tag(const FuStructEdidDescriptor *st)
100
720
{
101
720
    g_return_val_if_fail(st != NULL, 0x0);
102
720
    return st->buf->data[3];
103
720
}
104
/**
105
 * fu_struct_edid_descriptor_get_data: (skip):
106
 **/
107
const guint8 *
108
fu_struct_edid_descriptor_get_data(const FuStructEdidDescriptor *st, gsize *bufsz)
109
318
{
110
318
    g_return_val_if_fail(st != NULL, NULL);
111
318
    if (bufsz != NULL)
112
318
        *bufsz = 13;
113
318
    return st->buf->data + 5;
114
318
}
115
116
/* setters */
117
/**
118
 * fu_struct_edid_descriptor_set_kind: (skip):
119
 **/
120
void
121
fu_struct_edid_descriptor_set_kind(FuStructEdidDescriptor *st, guint16 value)
122
0
{
123
0
    g_return_if_fail(st != NULL);
124
0
    fu_memwrite_uint16(st->buf->data + 0, value, G_LITTLE_ENDIAN);
125
0
}
126
/**
127
 * fu_struct_edid_descriptor_set_subkind: (skip):
128
 **/
129
void
130
fu_struct_edid_descriptor_set_subkind(FuStructEdidDescriptor *st, guint8 value)
131
0
{
132
0
    g_return_if_fail(st != NULL);
133
0
    st->buf->data[2] = value;
134
0
}
135
/**
136
 * fu_struct_edid_descriptor_set_tag: (skip):
137
 **/
138
void
139
fu_struct_edid_descriptor_set_tag(FuStructEdidDescriptor *st, FuEdidDescriptorTag value)
140
238
{
141
238
    g_return_if_fail(st != NULL);
142
238
    st->buf->data[3] = value;
143
238
}
144
/**
145
 * fu_struct_edid_descriptor_set_data: (skip):
146
 **/
147
gboolean
148
fu_struct_edid_descriptor_set_data(FuStructEdidDescriptor *st, const guint8 *buf, gsize bufsz, GError **error)
149
238
{
150
238
    g_return_val_if_fail(st != NULL, FALSE);
151
238
    g_return_val_if_fail(buf != NULL, FALSE);
152
238
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
153
238
    return fu_memcpy_safe(st->buf->data, st->buf->len, 5, buf, bufsz, 0x0, bufsz, error);
154
238
}
155
/**
156
 * fu_struct_edid_descriptor_new: (skip):
157
 **/
158
FuStructEdidDescriptor *
159
fu_struct_edid_descriptor_new(void)
160
238
{
161
238
    FuStructEdidDescriptor *st = fu_struct_edid_descriptor_new_internal();
162
238
    st->buf = g_byte_array_sized_new(18);
163
238
    fu_byte_array_set_size(st->buf, 18, 0x0);
164
238
    return st;
165
238
}
166
/**
167
 * fu_struct_edid_descriptor_to_string: (skip):
168
 **/
169
static gchar *
170
fu_struct_edid_descriptor_to_string(const FuStructEdidDescriptor *st)
171
0
{
172
0
    g_autoptr(GString) str = g_string_new("FuStructEdidDescriptor:\n");
173
0
    g_return_val_if_fail(st != NULL, NULL);
174
0
    g_string_append_printf(str, "  kind: 0x%x\n",
175
0
                           (guint) fu_struct_edid_descriptor_get_kind(st));
176
0
    g_string_append_printf(str, "  subkind: 0x%x\n",
177
0
                           (guint) fu_struct_edid_descriptor_get_subkind(st));
178
0
    {
179
0
        const gchar *tmp = fu_edid_descriptor_tag_to_string(fu_struct_edid_descriptor_get_tag(st));
180
0
        if (tmp != NULL) {
181
0
            g_string_append_printf(str, "  tag: 0x%x [%s]\n", (guint) fu_struct_edid_descriptor_get_tag(st), tmp);
182
0
        } else {
183
0
            g_string_append_printf(str, "  tag: 0x%x\n", (guint) fu_struct_edid_descriptor_get_tag(st));
184
0
        }
185
0
    }
186
0
    {
187
0
        gsize bufsz = 0;
188
0
        const guint8 *buf = fu_struct_edid_descriptor_get_data(st, &bufsz);
189
0
        g_autoptr(GString) tmp = g_string_new(NULL);
190
0
        for (gsize i = 0; i < bufsz; i++)
191
0
            g_string_append_printf(tmp, "%02X", buf[i]);
192
0
        g_string_append_printf(str, "  data: 0x%s\n", tmp->str);
193
0
    }
194
0
    if (str->len > 0)
195
0
        g_string_set_size(str, str->len - 1);
196
0
    return g_string_free(g_steal_pointer(&str), FALSE);
197
0
}
198
static gboolean
199
fu_struct_edid_descriptor_validate_internal(FuStructEdidDescriptor *st, GError **error)
200
924
{
201
924
    g_return_val_if_fail(st != NULL, FALSE);
202
924
    return TRUE;
203
924
}
204
static gboolean
205
fu_struct_edid_descriptor_parse_internal(FuStructEdidDescriptor *st, GError **error)
206
924
{
207
924
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
208
0
        g_autofree gchar *str = fu_struct_edid_descriptor_to_string(st);
209
0
        g_debug("%s", str);
210
0
    }
211
924
    if (!fu_struct_edid_descriptor_validate_internal(st, error))
212
0
        return FALSE;
213
924
    return TRUE;
214
924
}
215
/**
216
 * fu_struct_edid_descriptor_parse_stream: (skip):
217
 **/
218
FuStructEdidDescriptor *
219
fu_struct_edid_descriptor_parse_stream(GInputStream *stream, gsize offset, GError **error)
220
924
{
221
924
    g_autoptr(FuStructEdidDescriptor) st = fu_struct_edid_descriptor_new_internal();
222
924
    st->buf = fu_input_stream_read_byte_array(stream, offset, 18, NULL, error);
223
924
    if (st->buf == NULL) {
224
0
        g_prefix_error(error, "FuStructEdidDescriptor failed read of 0x%x: ", (guint) 18);
225
0
        return NULL;
226
0
    }
227
924
    if (st->buf->len != 18) {
228
0
        g_set_error(error,
229
0
                    FWUPD_ERROR,
230
0
                    FWUPD_ERROR_INVALID_DATA,
231
0
                    "FuStructEdidDescriptor requested 0x%x and got 0x%x",
232
0
                    (guint) 18,
233
0
                    (guint) st->buf->len);
234
0
        return NULL;
235
0
    }
236
924
    if (!fu_struct_edid_descriptor_parse_internal(st, error))
237
0
        return NULL;
238
924
    return g_steal_pointer(&st);
239
924
}
240
/**
241
 * fu_struct_edid_ref: (skip):
242
 **/
243
FuStructEdid *
244
fu_struct_edid_ref(FuStructEdid *st)
245
0
{
246
0
    g_return_val_if_fail(st != NULL, NULL);
247
0
    st->refcount++;
248
0
    return st;
249
0
}
250
/**
251
 * fu_struct_edid_unref: (skip):
252
 **/
253
void
254
fu_struct_edid_unref(FuStructEdid *st)
255
570
{
256
570
    g_return_if_fail(st != NULL);
257
570
    if (st->refcount == 0) {
258
0
        g_critical("FuStructEdid refcount already zero");
259
0
        return;
260
0
    }
261
570
    if (--st->refcount > 0)
262
0
        return;
263
570
    if (st->buf != NULL)
264
339
        g_byte_array_unref(st->buf);
265
570
    g_free(st);
266
570
}
267
static FuStructEdid *
268
fu_struct_edid_new_internal(void)
269
570
{
270
570
    FuStructEdid *st = g_new0(FuStructEdid, 1);
271
570
    st->refcount = 1;
272
570
    return st;
273
570
}
274
275
/* getters */
276
/**
277
 * fu_struct_edid_get_manufacturer_name: (skip):
278
 **/
279
const guint8 *
280
fu_struct_edid_get_manufacturer_name(const FuStructEdid *st, gsize *bufsz)
281
231
{
282
231
    g_return_val_if_fail(st != NULL, NULL);
283
231
    if (bufsz != NULL)
284
0
        *bufsz = 2;
285
231
    return st->buf->data + 8;
286
231
}
287
/**
288
 * fu_struct_edid_get_product_code: (skip):
289
 **/
290
guint16
291
fu_struct_edid_get_product_code(const FuStructEdid *st)
292
231
{
293
231
    g_return_val_if_fail(st != NULL, 0x0);
294
231
    return fu_memread_uint16(st->buf->data + 10, G_LITTLE_ENDIAN);
295
231
}
296
/**
297
 * fu_struct_edid_get_serial_number: (skip):
298
 **/
299
guint32
300
fu_struct_edid_get_serial_number(const FuStructEdid *st)
301
456
{
302
456
    g_return_val_if_fail(st != NULL, 0x0);
303
456
    return fu_memread_uint32(st->buf->data + 12, G_LITTLE_ENDIAN);
304
456
}
305
/**
306
 * fu_struct_edid_get_week_of_manufacture: (skip):
307
 **/
308
guint8
309
fu_struct_edid_get_week_of_manufacture(const FuStructEdid *st)
310
0
{
311
0
    g_return_val_if_fail(st != NULL, 0x0);
312
0
    return st->buf->data[16];
313
0
}
314
/**
315
 * fu_struct_edid_get_year_of_manufacture: (skip):
316
 **/
317
guint8
318
fu_struct_edid_get_year_of_manufacture(const FuStructEdid *st)
319
0
{
320
0
    g_return_val_if_fail(st != NULL, 0x0);
321
0
    return st->buf->data[17];
322
0
}
323
/**
324
 * fu_struct_edid_get_edid_version_number: (skip):
325
 **/
326
static guint8
327
fu_struct_edid_get_edid_version_number(const FuStructEdid *st)
328
239
{
329
239
    g_return_val_if_fail(st != NULL, 0x0);
330
239
    return st->buf->data[18];
331
239
}
332
/**
333
 * fu_struct_edid_get_revision_number: (skip):
334
 **/
335
guint8
336
fu_struct_edid_get_revision_number(const FuStructEdid *st)
337
0
{
338
0
    g_return_val_if_fail(st != NULL, 0x0);
339
0
    return st->buf->data[19];
340
0
}
341
/**
342
 * fu_struct_edid_get_data_blocks: (skip):
343
 **/
344
const guint8 *
345
fu_struct_edid_get_data_blocks(const FuStructEdid *st, gsize *bufsz)
346
0
{
347
0
    g_return_val_if_fail(st != NULL, NULL);
348
0
    if (bufsz != NULL)
349
0
        *bufsz = 72;
350
0
    return st->buf->data + 54;
351
0
}
352
/**
353
 * fu_struct_edid_get_extension_block_count: (skip):
354
 **/
355
guint8
356
fu_struct_edid_get_extension_block_count(const FuStructEdid *st)
357
0
{
358
0
    g_return_val_if_fail(st != NULL, 0x0);
359
0
    return st->buf->data[126];
360
0
}
361
/**
362
 * fu_struct_edid_get_checksum: (skip):
363
 **/
364
guint8
365
fu_struct_edid_get_checksum(const FuStructEdid *st)
366
0
{
367
0
    g_return_val_if_fail(st != NULL, 0x0);
368
0
    return st->buf->data[127];
369
0
}
370
371
/* setters */
372
/**
373
 * fu_struct_edid_set_manufacturer_name: (skip):
374
 **/
375
gboolean
376
fu_struct_edid_set_manufacturer_name(FuStructEdid *st, const guint8 *buf, gsize bufsz, GError **error)
377
0
{
378
0
    g_return_val_if_fail(st != NULL, FALSE);
379
0
    g_return_val_if_fail(buf != NULL, FALSE);
380
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
381
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 8, buf, bufsz, 0x0, bufsz, error);
382
0
}
383
/**
384
 * fu_struct_edid_set_product_code: (skip):
385
 **/
386
void
387
fu_struct_edid_set_product_code(FuStructEdid *st, guint16 value)
388
231
{
389
231
    g_return_if_fail(st != NULL);
390
231
    fu_memwrite_uint16(st->buf->data + 10, value, G_LITTLE_ENDIAN);
391
231
}
392
/**
393
 * fu_struct_edid_set_serial_number: (skip):
394
 **/
395
void
396
fu_struct_edid_set_serial_number(FuStructEdid *st, guint32 value)
397
92
{
398
92
    g_return_if_fail(st != NULL);
399
92
    fu_memwrite_uint32(st->buf->data + 12, value, G_LITTLE_ENDIAN);
400
92
}
401
/**
402
 * fu_struct_edid_set_week_of_manufacture: (skip):
403
 **/
404
void
405
fu_struct_edid_set_week_of_manufacture(FuStructEdid *st, guint8 value)
406
0
{
407
0
    g_return_if_fail(st != NULL);
408
0
    st->buf->data[16] = value;
409
0
}
410
/**
411
 * fu_struct_edid_set_year_of_manufacture: (skip):
412
 **/
413
void
414
fu_struct_edid_set_year_of_manufacture(FuStructEdid *st, guint8 value)
415
0
{
416
0
    g_return_if_fail(st != NULL);
417
0
    st->buf->data[17] = value;
418
0
}
419
/**
420
 * fu_struct_edid_set_edid_version_number: (skip):
421
 **/
422
static void
423
fu_struct_edid_set_edid_version_number(FuStructEdid *st, guint8 value)
424
231
{
425
231
    g_return_if_fail(st != NULL);
426
231
    st->buf->data[18] = value;
427
231
}
428
/**
429
 * fu_struct_edid_set_revision_number: (skip):
430
 **/
431
void
432
fu_struct_edid_set_revision_number(FuStructEdid *st, guint8 value)
433
231
{
434
231
    g_return_if_fail(st != NULL);
435
231
    st->buf->data[19] = value;
436
231
}
437
/**
438
 * fu_struct_edid_set_data_blocks: (skip):
439
 **/
440
gboolean
441
fu_struct_edid_set_data_blocks(FuStructEdid *st, const guint8 *buf, gsize bufsz, GError **error)
442
0
{
443
0
    g_return_val_if_fail(st != NULL, FALSE);
444
0
    g_return_val_if_fail(buf != NULL, FALSE);
445
0
    g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
446
0
    return fu_memcpy_safe(st->buf->data, st->buf->len, 54, buf, bufsz, 0x0, bufsz, error);
447
0
}
448
/**
449
 * fu_struct_edid_set_extension_block_count: (skip):
450
 **/
451
void
452
fu_struct_edid_set_extension_block_count(FuStructEdid *st, guint8 value)
453
0
{
454
0
    g_return_if_fail(st != NULL);
455
0
    st->buf->data[126] = value;
456
0
}
457
/**
458
 * fu_struct_edid_set_checksum: (skip):
459
 **/
460
void
461
fu_struct_edid_set_checksum(FuStructEdid *st, guint8 value)
462
0
{
463
0
    g_return_if_fail(st != NULL);
464
0
    st->buf->data[127] = value;
465
0
}
466
/**
467
 * fu_struct_edid_new: (skip):
468
 **/
469
FuStructEdid *
470
fu_struct_edid_new(void)
471
231
{
472
231
    FuStructEdid *st = fu_struct_edid_new_internal();
473
231
    st->buf = g_byte_array_sized_new(128);
474
231
    fu_byte_array_set_size(st->buf, 128, 0x0);
475
231
    memcpy(st->buf->data + 0x0, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8); /* nocheck:blocked */
476
231
    fu_struct_edid_set_edid_version_number(st, 0x1);
477
231
    fu_struct_edid_set_revision_number(st, 0x3);
478
231
    return st;
479
231
}
480
/**
481
 * fu_struct_edid_to_string: (skip):
482
 **/
483
static gchar *
484
fu_struct_edid_to_string(const FuStructEdid *st)
485
0
{
486
0
    g_autoptr(GString) str = g_string_new("FuStructEdid:\n");
487
0
    g_return_val_if_fail(st != NULL, NULL);
488
0
    {
489
0
        gsize bufsz = 0;
490
0
        const guint8 *buf = fu_struct_edid_get_manufacturer_name(st, &bufsz);
491
0
        g_autoptr(GString) tmp = g_string_new(NULL);
492
0
        for (gsize i = 0; i < bufsz; i++)
493
0
            g_string_append_printf(tmp, "%02X", buf[i]);
494
0
        g_string_append_printf(str, "  manufacturer_name: 0x%s\n", tmp->str);
495
0
    }
496
0
    g_string_append_printf(str, "  product_code: 0x%x\n",
497
0
                           (guint) fu_struct_edid_get_product_code(st));
498
0
    g_string_append_printf(str, "  serial_number: 0x%x\n",
499
0
                           (guint) fu_struct_edid_get_serial_number(st));
500
0
    g_string_append_printf(str, "  week_of_manufacture: 0x%x\n",
501
0
                           (guint) fu_struct_edid_get_week_of_manufacture(st));
502
0
    g_string_append_printf(str, "  year_of_manufacture: 0x%x\n",
503
0
                           (guint) fu_struct_edid_get_year_of_manufacture(st));
504
0
    g_string_append_printf(str, "  revision_number: 0x%x\n",
505
0
                           (guint) fu_struct_edid_get_revision_number(st));
506
0
    {
507
0
        gsize bufsz = 0;
508
0
        const guint8 *buf = fu_struct_edid_get_data_blocks(st, &bufsz);
509
0
        g_autoptr(GString) tmp = g_string_new(NULL);
510
0
        for (gsize i = 0; i < bufsz; i++)
511
0
            g_string_append_printf(tmp, "%02X", buf[i]);
512
0
        g_string_append_printf(str, "  data_blocks: 0x%s\n", tmp->str);
513
0
    }
514
0
    g_string_append_printf(str, "  extension_block_count: 0x%x\n",
515
0
                           (guint) fu_struct_edid_get_extension_block_count(st));
516
0
    g_string_append_printf(str, "  checksum: 0x%x\n",
517
0
                           (guint) fu_struct_edid_get_checksum(st));
518
0
    if (str->len > 0)
519
0
        g_string_set_size(str, str->len - 1);
520
0
    return g_string_free(g_steal_pointer(&str), FALSE);
521
0
}
522
static gboolean
523
fu_struct_edid_validate_internal(FuStructEdid *st, GError **error)
524
314
{
525
314
    g_return_val_if_fail(st != NULL, FALSE);
526
314
    if (memcmp(st->buf->data + 0, "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", 8) != 0) {
527
75
        g_set_error_literal(error,
528
75
                            FWUPD_ERROR,
529
75
                            FWUPD_ERROR_INVALID_DATA,
530
75
                            "constant FuStructEdid.header was not valid");
531
75
        return FALSE;
532
75
    }
533
239
    if (fu_struct_edid_get_edid_version_number(st) != 0x1) {
534
8
        g_set_error_literal(error,
535
8
                            FWUPD_ERROR,
536
8
                            FWUPD_ERROR_INVALID_DATA,
537
8
                            "constant FuStructEdid.edid_version_number was not valid");
538
8
        return FALSE;
539
8
    }
540
231
    return TRUE;
541
239
}
542
static gboolean
543
fu_struct_edid_parse_internal(FuStructEdid *st, GError **error)
544
314
{
545
314
    if (g_getenv("FWUPD_VERBOSE") != NULL) {
546
0
        g_autofree gchar *str = fu_struct_edid_to_string(st);
547
0
        g_debug("%s", str);
548
0
    }
549
314
    if (!fu_struct_edid_validate_internal(st, error))
550
83
        return FALSE;
551
231
    return TRUE;
552
314
}
553
/**
554
 * fu_struct_edid_parse_stream: (skip):
555
 **/
556
FuStructEdid *
557
fu_struct_edid_parse_stream(GInputStream *stream, gsize offset, GError **error)
558
339
{
559
339
    g_autoptr(FuStructEdid) st = fu_struct_edid_new_internal();
560
339
    st->buf = fu_input_stream_read_byte_array(stream, offset, 128, NULL, error);
561
339
    if (st->buf == NULL) {
562
0
        g_prefix_error(error, "FuStructEdid failed read of 0x%x: ", (guint) 128);
563
0
        return NULL;
564
0
    }
565
339
    if (st->buf->len != 128) {
566
25
        g_set_error(error,
567
25
                    FWUPD_ERROR,
568
25
                    FWUPD_ERROR_INVALID_DATA,
569
25
                    "FuStructEdid requested 0x%x and got 0x%x",
570
25
                    (guint) 128,
571
25
                    (guint) st->buf->len);
572
25
        return NULL;
573
25
    }
574
314
    if (!fu_struct_edid_parse_internal(st, error))
575
83
        return NULL;
576
231
    return g_steal_pointer(&st);
577
314
}