Skip to content

Commit

Permalink
refactor: remove excess cast to C-string and add const reference
Browse files Browse the repository at this point in the history
Signed-off-by: Semenov Herman (Семенов Герман) <[email protected]>
  • Loading branch information
GermanAizek committed Jan 4, 2025
1 parent c5d541d commit 90005f5
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions shared/offline_compiler/source/offline_compiler.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -936,7 +936,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
}
}

retVal = deviceName.empty() ? OCLOC_SUCCESS : initHardwareInfo(deviceName.c_str());
retVal = deviceName.empty() ? OCLOC_SUCCESS : initHardwareInfo(deviceName);
if (retVal != OCLOC_SUCCESS) {
argHelper->printf("Error: Cannot get HW Info for device %s.\n", deviceName.c_str());
return retVal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -63,7 +63,7 @@ bool CompilerCache::evictCache(uint64_t &bytesEvicted) {
for (int i = 0; i < filesCount; ++i) {
ElementsStruct fileElement = {};
fileElement.path = joinPath(config.cacheDir, files[i]->d_name);
if (NEO::SysCalls::stat(fileElement.path.c_str(), &fileElement.statEl) == 0) {
if (NEO::SysCalls::stat(fileElement.path, &fileElement.statEl) == 0) {
cacheFiles.push_back(std::move(fileElement));
}
free(files[i]);
Expand Down Expand Up @@ -177,7 +177,7 @@ void CompilerCache::lockConfigFileAndReadSize(const std::string &configFilePath,
if (fileName.find(config.cacheFileExtension) != fileName.npos) {
ElementsStruct fileElement = {};
fileElement.path = joinPath(config.cacheDir, files[i]->d_name);
if (NEO::SysCalls::stat(fileElement.path.c_str(), &fileElement.statEl) == 0) {
if (NEO::SysCalls::stat(fileElement.path, &fileElement.statEl) == 0) {
cacheFiles.push_back(std::move(fileElement));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Intel Corporation
* Copyright (C) 2022-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -42,16 +42,16 @@ void ExecutionEnvironment::configureCcsMode() {
return;
}

const std::string drmPath = "/sys/class/drm";
const std::string &drmPath = "/sys/class/drm";
std::string expectedFilePrefix = drmPath + "/card";
auto files = Directory::getFiles(drmPath.c_str());
const auto &files = Directory::getFiles(drmPath);
for (const auto &file : files) {
if (file.find(expectedFilePrefix.c_str()) == std::string::npos) {
continue;
}

std::string gtPath = file + "/gt";
auto gtFiles = Directory::getFiles(gtPath.c_str());
const auto &gtFiles = Directory::getFiles(gtPath);
expectedFilePrefix = gtPath + "/gt";
for (const auto &gtFile : gtFiles) {
if (gtFile.find(expectedFilePrefix.c_str()) == std::string::npos) {
Expand Down
4 changes: 2 additions & 2 deletions shared/source/helpers/linux/path.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 Intel Corporation
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -15,7 +15,7 @@ namespace NEO {
bool pathExists(const std::string &path) {
struct stat statbuf = {};

if (NEO::SysCalls::stat(path.c_str(), &statbuf) == -1) {
if (NEO::SysCalls::stat(path, &statbuf) == -1) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions shared/source/kernel/kernel_descriptor_from_patchtokens.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -113,7 +113,7 @@ void populateKernelDescriptor(KernelDescriptor &dst, const SPatchDataParameterSt

void populateKernelDescriptor(KernelDescriptor &dst, const SPatchKernelAttributesInfo &token) {
constexpr ConstStringRef attributeReqdSubGroupSizeBeg = "intel_reqd_sub_group_size(";
std::string attributes = std::string(reinterpret_cast<const char *>(&token + 1), token.AttributesSize).c_str();
const auto &attributes = std::string(reinterpret_cast<const char *>(&token + 1), token.AttributesSize);
dst.kernelMetadata.kernelLanguageAttributes = attributes;
auto it = attributes.find(attributeReqdSubGroupSizeBeg.begin());
if (it != std::string::npos) {
Expand Down Expand Up @@ -460,7 +460,7 @@ void populateArgDescriptor(KernelDescriptor &dst, size_t argNum, const PatchToke

void populateKernelDescriptor(KernelDescriptor &dst, const PatchTokenBinary::KernelFromPatchtokens &src, uint32_t gpuPointerSizeInBytes) {
UNRECOVERABLE_IF(nullptr == src.header);
dst.kernelMetadata.kernelName = std::string(src.name.begin(), src.name.end()).c_str();
dst.kernelMetadata.kernelName = std::string(src.name.begin(), src.name.end());
populateKernelDescriptorIfNotNull(dst, src.tokens.executionEnvironment);
populateKernelDescriptorIfNotNull(dst, src.tokens.samplerStateArray);
populateKernelDescriptorIfNotNull(dst, src.tokens.bindingTableState);
Expand Down
4 changes: 2 additions & 2 deletions shared/source/os_interface/linux/drm_neo.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -189,7 +189,7 @@ bool Drm::readSysFsAsString(const std::string &relativeFilePath, std::string &re
return false;
}

const std::string fileName = devicePath + relativeFilePath;
const std::string &fileName = devicePath + relativeFilePath;
int fd = SysCalls::open(fileName.c_str(), O_RDONLY);
if (fd < 0) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions shared/source/os_interface/windows/wddm/wddm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2024 Intel Corporation
* Copyright (C) 2018-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -302,7 +302,7 @@ bool Wddm::queryAdapterInfo() {
memcpy_s(&gfxPartition, sizeof(gfxPartition), &adapterInfo.GfxPartition, sizeof(GMM_GFX_PARTITIONING));
memcpy_s(&adapterBDF, sizeof(adapterBDF), &adapterInfo.stAdapterBDF, sizeof(ADAPTER_BDF));

deviceRegistryPath = std::string(adapterInfo.DeviceRegistryPath, sizeof(adapterInfo.DeviceRegistryPath)).c_str();
deviceRegistryPath = std::string(adapterInfo.DeviceRegistryPath, sizeof(adapterInfo.DeviceRegistryPath));

systemSharedMemory = adapterInfo.SystemSharedMemory;
dedicatedVideoMemory = adapterInfo.DedicatedVideoMemory;
Expand Down

0 comments on commit 90005f5

Please sign in to comment.