fix: add unrecoverable to avoid undefined behavior

Related-To: NEO-9038
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-10-10 14:49:54 +00:00
committed by Compute-Runtime-Automation
parent dcbf147a52
commit bede264d0d
5 changed files with 18 additions and 8 deletions

View File

@@ -42,7 +42,9 @@ IoctlHelperPrelim20::IoctlHelperPrelim20(Drm &drmArg) : IoctlHelper(drmArg) {
}
if (handleExecBufferInNonBlockMode) {
auto fileDescriptor = this->drm.getFileDescriptor();
SysCalls::fcntl(fileDescriptor, F_SETFL, SysCalls::fcntl(fileDescriptor, F_GETFL) | O_NONBLOCK);
auto flags = SysCalls::fcntl(fileDescriptor, F_GETFL);
[[maybe_unused]] auto status = SysCalls::fcntl(fileDescriptor, F_SETFL, flags | O_NONBLOCK);
DEBUG_BREAK_IF(status != 0);
}
};

View File

@@ -47,8 +47,10 @@ unsigned int getProcessId() {
unsigned long getNumThreads() {
struct stat taskStat;
stat("/proc/self/task", &taskStat);
return taskStat.st_nlink - 2;
if (stat("/proc/self/task", &taskStat) == 0) {
return taskStat.st_nlink - 2;
}
return 0;
}
int mkdir(const std::string &path) {

View File

@@ -1048,7 +1048,8 @@ Wddm &WddmMemoryManager::getWddm(uint32_t rootDeviceIndex) const {
void *WddmMemoryManager::reserveCpuAddressRange(size_t size, uint32_t rootDeviceIndex) {
void *reservePtr = nullptr;
getWddm(rootDeviceIndex).reserveValidAddressRange(size, reservePtr);
auto ret = getWddm(rootDeviceIndex).reserveValidAddressRange(size, reservePtr);
UNRECOVERABLE_IF(!ret && reservePtr);
return reservePtr;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,8 @@
#include "shared/source/utilities/directory.h"
#include "shared/source/helpers/debug_helpers.h"
#include <cstdio>
#include <dirent.h>
#include <sys/stat.h>
@@ -42,6 +44,7 @@ std::vector<std::string> getFiles(const std::string &path) {
void createDirectory(const std::string &path) {
const mode_t mode = 0777; // 777 in base 8
mkdir(path.c_str(), mode);
[[maybe_unused]] auto status = mkdir(path.c_str(), mode);
DEBUG_BREAK_IF(status != 0);
}
}; // namespace NEO::Directory

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2022 Intel Corporation
* Copyright (C) 2018-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,6 +7,7 @@
#include "shared/source/utilities/directory.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <direct.h>
@@ -41,6 +42,7 @@ std::vector<std::string> getFiles(const std::string &path) {
}
void createDirectory(const std::string &path) {
_mkdir(path.c_str());
[[maybe_unused]] auto status = _mkdir(path.c_str());
DEBUG_BREAK_IF(status != 0);
}
}; // namespace NEO::Directory