SWDEV-342014 - Handle partial fills in hipDeviceGetName

Change-Id: Ic9f1743c6a8439d88acc6dd1ed496013d551f6ec
Tento commit je obsažen v:
Maneesh Gupta
2022-11-11 11:55:31 +00:00
odevzdal Rahul Garg
rodič cc9427e969
revize 8f4e94d532
+4 -6
Zobrazit soubor
@@ -216,13 +216,11 @@ hipError_t hipDeviceGetName(char *name, int len, hipDevice_t device) {
const auto& info = deviceHandle->info();
const auto nameLen = ::strlen(info.boardName_);
// Make sure that the size of `dest` is big enough to hold `src` including
// Only copy partial name if size of `dest` is smaller than size of `src` including
// trailing zero byte
if (nameLen <= 0) {
HIP_RETURN(hipErrorInvalidValue);
}
::memcpy(name, info.boardName_, (nameLen + 1));
auto memcpySize = (len <= (nameLen + 1) ? (len - 1) : nameLen);
::memcpy(name, info.boardName_, memcpySize);
name[memcpySize] = '\0';
HIP_RETURN(hipSuccess);
}