Skip to content

Commit f93ef5d

Browse files
USB: prevent compiler warning
1 parent a3b101d commit f93ef5d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Components/USB/Source/usbd_lib_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "usbd_lib_core.h"
1010

11+
#include <stddef.h>
1112
#include <string.h>
1213

1314
#include "usb_lib_debug.h"
@@ -416,7 +417,7 @@ usbStatus USBD_SetSerialNumber (uint8_t device, const char *string) {
416417
str_len = ptr_dev_cfg->ser_num_str_len;
417418
}
418419

419-
ptr_str_desc_str = ((uint8_t *)(&((USB_STRING_DESCRIPTOR *)ptr_str_desc)->bString));
420+
ptr_str_desc_str = (uint8_t *)ptr_str_desc + offsetof(USB_STRING_DESCRIPTOR, bString);
420421

421422
ptr_str_desc->bLength = (uint8_t)((str_len * 2U) + 2U);
422423
ptr_str_desc->bDescriptorType = USB_STRING_DESCRIPTOR_TYPE;

0 commit comments

Comments
 (0)