mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Fix stringop truncation warning from GCC 8.2 (#1393)
The next line adds a null terminator, but it's cleaner to just do a std::memcpy() since the code already assumes a null terminator exists in the source string.
This commit is contained in:
committed by
Peter Johnson
parent
2501e11886
commit
e89d5eb692
@@ -149,8 +149,7 @@ char* HAL_GetJoystickName(int32_t joystickNum) {
|
||||
SimDriverStationData->GetJoystickDescriptor(joystickNum, &desc);
|
||||
size_t len = std::strlen(desc.name);
|
||||
char* name = static_cast<char*>(std::malloc(len + 1));
|
||||
std::strncpy(name, desc.name, len);
|
||||
name[len] = '\0';
|
||||
std::memcpy(name, desc.name, len + 1);
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user