Coverage Report

Created: 2026-09-14 07:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/fwupd/libfwupdplugin/fu-usb-device-ms-ds20.c
Line
Count
Source
1
/*
2
 * Copyright 2022 Richard Hughes <richard@hughsie.com>
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
7
0
#define G_LOG_DOMAIN "FuUsbDeviceDs20"
8
9
#include "config.h"
10
11
#include "fu-common.h"
12
#include "fu-input-stream.h"
13
#include "fu-usb-device-ds20-struct.h"
14
#include "fu-usb-device-ms-ds20.h"
15
16
struct _FuUsbDeviceMsDs20 {
17
  FuUsbDeviceDs20 parent_instance;
18
};
19
20
0
G_DEFINE_TYPE(FuUsbDeviceMsDs20, fu_usb_device_ms_ds20, FU_TYPE_USB_DEVICE_DS20)
21
0
22
0
static gboolean
23
0
fu_usb_device_ms_ds20_parse(FuUsbDeviceDs20 *self,
24
0
          FuInputStream *stream,
25
0
          FuUsbDevice *device,
26
0
          GError **error)
27
0
{
28
0
  gsize streamsz = 0;
29
30
  /* get length and type only */
31
0
  if (!fu_input_stream_size(stream, &streamsz, error))
32
0
    return FALSE;
33
0
  for (gsize offset = 0; offset < streamsz;) {
34
0
    guint16 desc_sz;
35
0
    guint16 desc_type;
36
0
    g_autoptr(FuStructMsDs20) st = NULL;
37
38
0
    st = fu_struct_ms_ds20_parse_stream(stream, offset, error);
39
0
    if (st == NULL)
40
0
      return FALSE;
41
0
    desc_sz = fu_struct_ms_ds20_get_size(st);
42
0
    if (desc_sz == 0)
43
0
      break;
44
0
    desc_type = fu_struct_ms_ds20_get_type(st);
45
0
    g_debug("USB OS descriptor type 0x%04x [%s], length 0x%04x",
46
0
      desc_type,
47
0
      fu_usb_device_ms_ds20_desc_to_string(desc_type),
48
0
      desc_sz);
49
0
    if (!fu_size_checked_inc(&offset, desc_sz, error))
50
0
      return FALSE;
51
0
  }
52
53
  /* success */
54
0
  return TRUE;
55
0
}
56
57
static void
58
fu_usb_device_ms_ds20_class_init(FuUsbDeviceMsDs20Class *klass)
59
0
{
60
0
  FuUsbDeviceDs20Class *usb_device_ds20_class = FU_USB_DEVICE_DS20_CLASS(klass);
61
0
  usb_device_ds20_class->parse = fu_usb_device_ms_ds20_parse;
62
0
}
63
64
static void
65
fu_usb_device_ms_ds20_init(FuUsbDeviceMsDs20 *self)
66
0
{
67
0
  fu_firmware_set_version_raw(FU_FIRMWARE(self), 0x06030000); /* Windows 8.1 */
68
0
  fu_firmware_set_id(FU_FIRMWARE(self), "d8dd60df-4589-4cc7-9cd2-659d9e648a9f");
69
0
}
70
71
/**
72
 * fu_usb_device_ms_ds20_new:
73
 *
74
 * Creates a new #FuUsbDeviceMsDs20.
75
 *
76
 * Returns: (transfer full): a #FuFirmware
77
 *
78
 * Since: 1.8.5
79
 **/
80
FuFirmware *
81
fu_usb_device_ms_ds20_new(void)
82
0
{
83
0
  return g_object_new(FU_TYPE_USB_DEVICE_MS_DS20, NULL);
84
0
}