Fix compiler warning

This change fixes compiler warning
"Inner pointer of container used after re/deallocation".

Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
Jitendra Sharma
2023-03-01 11:44:35 +00:00
committed by Compute-Runtime-Automation
parent 42b8a536db
commit e0a2fe057b
2 changed files with 11 additions and 10 deletions

View File

@@ -45,8 +45,8 @@ class SysmanDeviceFixture : public ::testing::Test {
public:
void SetUp() override {
VariableBackup<decltype(NEO::SysCalls::sysCallsRealpath)> mockRealPath(&NEO::SysCalls::sysCallsRealpath, [](const char *path, char *buf) -> char * {
std::string str = "/sys/devices/pci0000:00/0000:00:02.0";
buf = const_cast<char *>(str.c_str());
constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:02.0");
strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:02.0");
return buf;
});
@@ -90,8 +90,8 @@ class SysmanMultiDeviceFixture : public ::testing::Test {
public:
void SetUp() override {
VariableBackup<decltype(NEO::SysCalls::sysCallsRealpath)> mockRealPath(&NEO::SysCalls::sysCallsRealpath, [](const char *path, char *buf) -> char * {
std::string str = "/sys/devices/pci0000:00/0000:00:02.0";
buf = const_cast<char *>(str.c_str());
constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:02.0");
strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:02.0");
return buf;
});

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
@@ -74,8 +75,8 @@ struct SysmanDriverTestMultipleFamilySupport : public ::testing::Test {
TEST_F(SysmanDriverTestMultipleFamilySupport, whenInitializingSysmanDriverWithArrayOfDevicesThenDriverIsInitializedOnlyWithThoseSupported) {
VariableBackup<decltype(NEO::SysCalls::sysCallsRealpath)> mockRealPath(&NEO::SysCalls::sysCallsRealpath, [](const char *path, char *buf) -> char * {
std::string str = "/sys/devices/pci0000:00/0000:00:02.0";
buf = const_cast<char *>(str.c_str());
constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:02.0");
strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:02.0");
return buf;
});
@@ -142,8 +143,8 @@ struct SysmanDriverTestNoDeviceCreate : public ::testing::Test {
TEST_F(SysmanDriverTestNoDeviceCreate, GivenReadLinkSysCallFailWhenInitializingSysmanDriverWithArrayOfDevicesThenSysmanDeviceCreateFailAndDriverIsNull) {
VariableBackup<decltype(NEO::SysCalls::sysCallsRealpath)> mockRealPath(&NEO::SysCalls::sysCallsRealpath, [](const char *path, char *buf) -> char * {
std::string str = "/sys/devices/pci0000:00/0000:00:02.0";
buf = const_cast<char *>(str.c_str());
constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:02.0");
strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:02.0");
return buf;
});
@@ -173,8 +174,8 @@ TEST_F(SysmanDriverTestNoDeviceCreate, GivenRealpathSysCallFailWhenInitializingS
struct SysmanDriverHandleTest : public ::testing::Test {
void SetUp() override {
VariableBackup<decltype(NEO::SysCalls::sysCallsRealpath)> mockRealPath(&NEO::SysCalls::sysCallsRealpath, [](const char *path, char *buf) -> char * {
std::string str = "/sys/devices/pci0000:00/0000:00:02.0";
buf = const_cast<char *>(str.c_str());
constexpr size_t sizeofPath = sizeof("/sys/devices/pci0000:00/0000:00:02.0");
strcpy_s(buf, sizeofPath, "/sys/devices/pci0000:00/0000:00:02.0");
return buf;
});