mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
Fixes #33: Remove invalid use of strncpy().
This was causing a stringop-truncation compiler warning in gcc 8 when the #defined values being copied from were string literals. `error: 'strncpy' output truncated before terminating nul copying 8 bytes from a string of the same length [-Werror=stringop-truncation]` These fields aren't NUL terminated C strings, they are a fixed width buffer that is supposed to be space (0x20) padded.
This commit is contained in:
parent
55874813f8
commit
fa8141f31f
@ -265,14 +265,20 @@ int32_t proc_builtin_scsi(msc_cbw_t const * p_cbw, uint8_t* buffer, uint32_t buf
|
||||
.is_removable = 1,
|
||||
.version = 2,
|
||||
.response_data_format = 2,
|
||||
.vendor_id = "Adafruit",
|
||||
.product_id = "Feather52840",
|
||||
.product_rev = "1.0"
|
||||
.vendor_id = " ",
|
||||
.product_id = " ",
|
||||
.product_rev = " ",
|
||||
};
|
||||
size_t len;
|
||||
|
||||
strncpy((char*) inquiry_rsp.vendor_id , CFG_TUD_MSC_VENDOR , sizeof(inquiry_rsp.vendor_id));
|
||||
strncpy((char*) inquiry_rsp.product_id , CFG_TUD_MSC_PRODUCT , sizeof(inquiry_rsp.product_id));
|
||||
strncpy((char*) inquiry_rsp.product_rev, CFG_TUD_MSC_PRODUCT_REV, sizeof(inquiry_rsp.product_rev));
|
||||
#define _min(a,b) ((a) < (b) ? (a) : (b))
|
||||
len = strlen(CFG_TUD_MSC_VENDOR);
|
||||
memcpy(inquiry_rsp.vendor_id , CFG_TUD_MSC_VENDOR , _min(len, sizeof(inquiry_rsp.vendor_id)));
|
||||
len = strlen(CFG_TUD_MSC_PRODUCT);
|
||||
memcpy(inquiry_rsp.product_id , CFG_TUD_MSC_PRODUCT , _min(len, sizeof(inquiry_rsp.product_id)));
|
||||
len = strlen(CFG_TUD_MSC_PRODUCT_REV);
|
||||
memcpy(inquiry_rsp.product_rev, CFG_TUD_MSC_PRODUCT_REV, _min(len, sizeof(inquiry_rsp.product_rev)));
|
||||
#undef _min
|
||||
|
||||
ret = sizeof(inquiry_rsp);
|
||||
memcpy(buffer, &inquiry_rsp, ret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user