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:
Tyler Veness
2018-10-29 00:09:53 -07:00
committed by Peter Johnson
parent 2501e11886
commit e89d5eb692

View File

@@ -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;
}