Skip to content

Commit 669797f

Browse files
committed
Coverity: Fix 1574354 Uninitialized scalar field
Always zero initialize the `ArrayDesc` data member of `SurfaceMem` in the CUDA adapter. Simplify other construction logic.
1 parent d2ffcce commit 669797f

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

source/adapters/cuda/memory.hpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,15 @@ struct SurfaceMem {
197197
void *HostPtr)
198198
: Arrays(Context->Devices.size(), CUarray{0}),
199199
SurfObjs(Context->Devices.size(), CUsurfObject{0}),
200-
OuterMemStruct{OuterMemStruct},
201-
ImageFormat{ImageFormat}, ImageDesc{ImageDesc}, HostPtr{HostPtr} {
200+
OuterMemStruct{OuterMemStruct}, ImageDesc{ImageDesc}, ArrayDesc{},
201+
HostPtr{HostPtr} {
202202
// We have to use hipArray3DCreate, which has some caveats. The height and
203203
// depth parameters must be set to 0 produce 1D or 2D arrays. image_desc
204204
// gives a minimum value of 1, so we need to convert the answer.
205205
ArrayDesc.NumChannels = 4; // Only support 4 channel image
206-
ArrayDesc.Flags = 0; // No flags required
207206
ArrayDesc.Width = ImageDesc.width;
208-
if (ImageDesc.type == UR_MEM_TYPE_IMAGE1D) {
209-
ArrayDesc.Height = 0;
210-
ArrayDesc.Depth = 0;
211-
} else if (ImageDesc.type == UR_MEM_TYPE_IMAGE2D) {
207+
if (ImageDesc.type == UR_MEM_TYPE_IMAGE2D) {
212208
ArrayDesc.Height = ImageDesc.height;
213-
ArrayDesc.Depth = 0;
214209
} else if (ImageDesc.type == UR_MEM_TYPE_IMAGE3D) {
215210
ArrayDesc.Height = ImageDesc.height;
216211
ArrayDesc.Depth = ImageDesc.depth;

0 commit comments

Comments
 (0)