Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use string literals for SERIAL_NUMBER #13403

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tmk_core/protocol/usb_descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,10 @@ const USB_Descriptor_String_t PROGMEM ProductString = {
#if defined(SERIAL_NUMBER)
const USB_Descriptor_String_t PROGMEM SerialNumberString = {
.Header = {
.Size = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1), // Subtract 1 for null terminator
.Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator
.Type = DTYPE_String
},
.UnicodeString = LSTR(SERIAL_NUMBER)
.UnicodeString = USBSTR(SERIAL_NUMBER)
};
#endif

Expand Down
4 changes: 4 additions & 0 deletions tmk_core/protocol/usb_descriptor_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#pragma once

// Prefix string literal with L for descriptors
#define USBCONCAT(a, b) a##b
#define USBSTR(s) USBCONCAT(L, s)

/////////////////////
// RAW Usage page and ID configuration

Expand Down
4 changes: 2 additions & 2 deletions tmk_core/protocol/vusb/vusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,10 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = {
#if defined(SERIAL_NUMBER)
const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
.header = {
.bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1),
.bLength = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1),
.bDescriptorType = USBDESCR_STRING
},
.bString = LSTR(SERIAL_NUMBER)
.bString = USBSTR(SERIAL_NUMBER)
};
#endif

Expand Down