Skip to content

Commit 1c1b2db

Browse files
fix: allowing neo ULT build with optimization enabled 5/n
- fix mismatched-new-delete warnings - fix initialization warnings - fix attempt to free a non-heap object warnings Related-To: NEO-8116 Signed-off-by: Oskar Hubert Weber <[email protected]>
1 parent dec695f commit 1c1b2db

File tree

8 files changed

+39
-21
lines changed

8 files changed

+39
-21
lines changed

level_zero/core/test/unit_tests/sources/rtas/test_rtas.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,10 @@ TEST_F(RTASTest, GivenUnderlyingBuilderDestroySucceedsThenSuccessIsReturned) {
349349
}
350350

351351
TEST_F(RTASTest, GivenUnderlyingBuilderDestroyFailsThenErrorIsReturned) {
352-
RTASBuilder pRTASBuilder;
352+
auto pRTASBuilder = std::make_unique<RTASBuilder>();
353353
builderDestroyExpImpl = &builderDestroyFail;
354-
driverHandle->rtasLibraryHandle = std::make_unique<MockRTASOsLibrary>();
355354

356-
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, L0::zeRTASBuilderDestroyExp(pRTASBuilder.toHandle()));
355+
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, L0::zeRTASBuilderDestroyExp(pRTASBuilder.get()));
357356
EXPECT_EQ(1u, builderDestroyFailCalled);
358357
}
359358

@@ -454,10 +453,10 @@ TEST_F(RTASTest, GivenUnderlyingParallelOperationDestroySucceedsThenSuccessIsRet
454453
}
455454

456455
TEST_F(RTASTest, GivenUnderlyingParallelOperationDestroyFailsThenErrorIsReturned) {
457-
RTASParallelOperation pParallelOperation;
456+
auto pParallelOperation = std::make_unique<RTASParallelOperation>();
458457
parallelOperationDestroyExpImpl = &parallelOperationDestroyFail;
459458

460-
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, L0::zeRTASParallelOperationDestroyExp(pParallelOperation.toHandle()));
459+
EXPECT_EQ(ZE_RESULT_ERROR_UNKNOWN, L0::zeRTASParallelOperationDestroyExp(pParallelOperation.get()));
461460
EXPECT_EQ(1u, parallelOperationDestroyFailCalled);
462461
}
463462

opencl/test/black_box_test/hello_world_opencl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main(int argc, char **argv) {
1919
int retVal = 0;
2020
const char *fileName = "kernelOutput.txt";
2121
cl_int err = 0;
22-
unique_ptr<cl_platform_id> platforms;
22+
unique_ptr<cl_platform_id[]> platforms;
2323
cl_device_id device_id = 0;
2424
cl_uint platformsCount = 0;
2525
cl_context context = NULL;

opencl/test/black_box_test/hello_world_opencl_tracing.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 Intel Corporation
2+
* Copyright (C) 2023-2024 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -65,7 +65,7 @@ bool validateOutput(const std::stringstream &out) {
6565
}
6666

6767
int main(int argc, char **argv) {
68-
std::unique_ptr<cl_platform_id> platforms;
68+
std::unique_ptr<cl_platform_id[]> platforms;
6969
cl_device_id deviceId = 0;
7070
cl_uint platformsCount = 0;
7171
cl_context context = nullptr;

opencl/test/unit_test/memory_manager/cl_memory_manager_tests.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2023 Intel Corporation
2+
* Copyright (C) 2018-2024 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -207,7 +207,7 @@ TEST(ClMemoryManagerTest, givenAllowedTilingWhenIsCopyRequiredIsCalledThenTrueIs
207207
imgInfo.slicePitch = imgInfo.rowPitch * imageDesc.image_height;
208208
imgInfo.size = imgInfo.slicePitch;
209209

210-
char memory;
210+
char memory{};
211211

212212
EXPECT_TRUE(MockMemoryManager::isCopyRequired(imgInfo, &memory));
213213
}
@@ -233,7 +233,7 @@ TEST(ClMemoryManagerTest, givenDifferentRowPitchWhenIsCopyRequiredIsCalledThenTr
233233
imgInfo.slicePitch = imgInfo.rowPitch * imageDesc.image_height;
234234
imgInfo.size = imgInfo.slicePitch;
235235

236-
char memory[10];
236+
char memory[10] = {};
237237

238238
EXPECT_TRUE(MockMemoryManager::isCopyRequired(imgInfo, memory));
239239
}
@@ -259,7 +259,7 @@ TEST(ClMemoryManagerTest, givenDifferentSlicePitchAndTilingNotAllowedWhenIsCopyR
259259
imgInfo.rowPitch = imageDesc.image_width * surfaceFormat->surfaceFormat.imageElementSizeInBytes;
260260
imgInfo.slicePitch = imgInfo.rowPitch * imageDesc.image_height;
261261
imgInfo.size = imgInfo.slicePitch;
262-
char memory[8];
262+
char memory[8] = {};
263263

264264
EXPECT_TRUE(MockMemoryManager::isCopyRequired(imgInfo, memory));
265265
}
@@ -284,7 +284,7 @@ TEST(ClMemoryManagerTest, givenNotCachelinAlignedPointerWhenIsCopyRequiredIsCall
284284
imgInfo.rowPitch = imageDesc.image_width * surfaceFormat->surfaceFormat.imageElementSizeInBytes;
285285
imgInfo.slicePitch = imgInfo.rowPitch * imageDesc.image_height;
286286
imgInfo.size = imgInfo.slicePitch;
287-
char memory[8];
287+
char memory[8] = {};
288288

289289
EXPECT_TRUE(MockMemoryManager::isCopyRequired(imgInfo, &memory[1]));
290290
}

shared/source/compiler_interface/linux/os_compiler_cache_helper.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,19 @@ bool checkDefaultCacheDirSettings(std::string &cacheDir, NEO::EnvironmentVariabl
6767
}
6868

6969
time_t getFileModificationTime(const std::string &path) {
70-
struct stat st;
70+
struct stat st {
71+
0, 0
72+
};
7173
if (NEO::SysCalls::stat(path, &st) == 0) {
7274
return st.st_mtime;
7375
}
7476
return 0;
7577
}
7678

7779
size_t getFileSize(const std::string &path) {
78-
struct stat st;
80+
struct stat st {
81+
0, 0
82+
};
7983
if (NEO::SysCalls::stat(path, &st) == 0) {
8084
return static_cast<size_t>(st.st_size);
8185
}

shared/source/os_interface/linux/os_time_linux.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ OSTimeLinux::OSTimeLinux(OSInterface &osInterface, std::unique_ptr<DeviceTime> d
2929
}
3030

3131
bool OSTimeLinux::getCpuTime(uint64_t *timestamp) {
32-
struct timespec ts;
32+
struct timespec ts {
33+
0, 0
34+
};
3335

3436
if (getTimeFunc(CLOCK_MONOTONIC_RAW, &ts)) {
3537
return false;
@@ -41,7 +43,9 @@ bool OSTimeLinux::getCpuTime(uint64_t *timestamp) {
4143
}
4244

4345
bool OSTime::getCpuTimeHost(uint64_t *timestamp) {
44-
struct timespec ts;
46+
struct timespec ts {
47+
0, 0
48+
};
4549

4650
auto ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
4751

@@ -51,7 +55,9 @@ bool OSTime::getCpuTimeHost(uint64_t *timestamp) {
5155
}
5256

5357
double OSTimeLinux::getHostTimerResolution() const {
54-
struct timespec ts;
58+
struct timespec ts {
59+
0, 0
60+
};
5561
if (resolutionFunc(CLOCK_MONOTONIC_RAW, &ts)) {
5662
return 0;
5763
}

shared/test/unit_test/helpers/bindless_heaps_helper_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ TEST_F(BindlessHeapsHelperTests, givenLocalMemorySupportWhenReservingMemoryForSp
634634
size_t reservationSize = MemoryConstants::pageSize64k;
635635
size_t alignment = MemoryConstants::pageSize64k;
636636

637-
memManager->localMemorySupported = {localMemSupported};
637+
memManager->localMemorySupported = std::vector<bool>{localMemSupported};
638638

639639
auto specialSshReservationSuccessful = bindlessHeapHelper->tryReservingMemoryForSpecialSsh(reservationSize, alignment);
640640
EXPECT_TRUE(specialSshReservationSuccessful);

shared/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5243,8 +5243,17 @@ TEST_F(DrmMemoryManagerTest, whenDebugFlagToNotFreeResourcesIsSpecifiedThenFreeI
52435243
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
52445244
size_t sizeIn = 1024llu;
52455245
uint64_t gpuAddress = 0x1337llu;
5246-
DrmAllocation stackDrmAllocation(0u, 1u /*num gmms*/, AllocationType::buffer, nullptr, nullptr, gpuAddress, sizeIn, MemoryPool::system64KBPages);
5247-
memoryManager.freeGraphicsMemoryImpl(&stackDrmAllocation);
5246+
auto drmAllocation = std::make_unique<DrmAllocation>(0u, 1u /*num gmms*/, AllocationType::buffer, nullptr, nullptr, gpuAddress, sizeIn, MemoryPool::system64KBPages);
5247+
memoryManager.freeGraphicsMemoryImpl(drmAllocation.get());
5248+
5249+
EXPECT_EQ(drmAllocation->getNumGmms(), 1u);
5250+
EXPECT_EQ(drmAllocation->getRootDeviceIndex(), 0u);
5251+
EXPECT_EQ(drmAllocation->getBOs().size(), EngineLimits::maxHandleCount);
5252+
EXPECT_EQ(drmAllocation->getAllocationType(), AllocationType::buffer);
5253+
EXPECT_EQ(drmAllocation->getGpuAddress(), gpuAddress);
5254+
EXPECT_EQ(drmAllocation->getUnderlyingBufferSize(), sizeIn);
5255+
EXPECT_EQ(drmAllocation->getMemoryPool(), MemoryPool::system64KBPages);
5256+
EXPECT_EQ(drmAllocation->getUnderlyingBuffer(), nullptr);
52485257
}
52495258

52505259
TEST_F(DrmMemoryManagerTest, given2MbPagesDisabledWhenWddmMemoryManagerIsCreatedThenAlignmentSelectorHasExpectedAlignments) {

0 commit comments

Comments
 (0)