Coverage Report

Created: 2025-11-24 06:59

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