Skip to content

Commit cec7551

Browse files
committed
Add default member initializers to fix cppcheck 2.21 warnings
* Add default member initializers to fix cppcheck 2.21 warnings cppcheck 2.21.0 began reporting uninitMemberVarNoCtor for struct members without default initializers under --enable=warning, failing CI. Add {} or explicit zero defaults to the affected members in AllocRecord, ScopeKey, APICBranchBody, CuBQLNode, CudaTimingRange, HashGrid_t, noise_level_t, SolidAngleProps, and tile_coord_iter_t. Signed-off-by: Nicolas Capens <ncapens@nvidia.com> Approved-by: Eric Shi <ershi@nvidia.com> See merge request omniverse/warp!2486
1 parent 410b62f commit cec7551

8 files changed

Lines changed: 44 additions & 44 deletions

File tree

warp/native/alloc_tracker.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ enum AllocKind {
1717
};
1818

1919
struct AllocRecord {
20-
size_t size;
21-
size_t seq; // allocation sequence number (monotonically increasing)
22-
AllocKind kind;
23-
int device_ordinal; // -1 for host/pinned
20+
size_t size = 0;
21+
size_t seq = 0; // allocation sequence number (monotonically increasing)
22+
AllocKind kind = {};
23+
int device_ordinal = 0; // -1 for host/pinned
2424
std::string tag; // Python call-site info or "(native)"
2525
std::string scope; // e.g. "simulation/collision"
2626
};
@@ -78,8 +78,8 @@ class AllocTracker {
7878

7979
struct ScopeKey {
8080
std::string scope;
81-
AllocKind kind;
82-
int ordinal; // only meaningful for ALLOC_KIND_DEVICE
81+
AllocKind kind = {};
82+
int ordinal = 0; // only meaningful for ALLOC_KIND_DEVICE
8383

8484
bool operator==(const ScopeKey& o) const { return scope == o.scope && kind == o.kind && ordinal == o.ordinal; }
8585
};

warp/native/apic.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ struct APICBranchStart {
360360

361361
struct APICBranchBody {
362362
std::vector<uint8_t> data;
363-
uint32_t op_count;
363+
uint32_t op_count = 0;
364364
};
365365

366366
APICBranchStart* wp_apic_begin_branch(APICState* state)

warp/native/bvh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ struct BVH {
213213
struct CuBQLNode {
214214
vec3 lower;
215215
vec3 upper;
216-
uint64_t admin;
216+
uint64_t admin = 0;
217217
};
218218

219219
struct CuBQLBVH {

warp/native/cuda_util.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ class ContextGuard {
299299

300300
// CUDA timing range used during event-based timing
301301
struct CudaTimingRange {
302-
void* context;
303-
const char* name;
304-
int flag;
305-
CUevent start;
306-
CUevent end;
302+
void* context = nullptr;
303+
const char* name = nullptr;
304+
int flag = 0;
305+
CUevent start = {};
306+
CUevent end = {};
307307
};
308308

309309
// Timing result used to pass timings to Python

warp/native/hashgrid.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ namespace wp {
99
// point_ids is at a consistent offset regardless of Type. This allows
1010
// hash_grid_point_id to work without knowing the grid's scalar type.
1111
template <typename Type> struct HashGrid_t {
12-
int* point_cells { nullptr }; // cell id of a point
13-
int* point_ids { nullptr }; // index to original point
12+
int* point_cells = nullptr; // cell id of a point
13+
int* point_ids = nullptr; // index to original point
1414

15-
int* cell_starts { nullptr }; // start index of a range of indices belonging to a cell, dim_x*dim_y*dim_z in length
16-
int* cell_ends { nullptr }; // end index of a range of indices belonging to a cell, dim_x*dim_y*dim_z in length
15+
int* cell_starts = nullptr; // start index of a range of indices belonging to a cell, dim_x*dim_y*dim_z in length
16+
int* cell_ends = nullptr; // end index of a range of indices belonging to a cell, dim_x*dim_y*dim_z in length
1717

18-
int dim_x;
19-
int dim_y;
20-
int dim_z;
18+
int dim_x = 0;
19+
int dim_y = 0;
20+
int dim_z = 0;
2121

22-
int num_points;
23-
int max_points;
22+
int num_points = 0;
23+
int max_points = 0;
2424

25-
void* context { nullptr };
25+
void* context = nullptr;
2626

2727
// Type-dependent fields at end (different sizes for half/float/double)
28-
Type cell_width;
29-
Type cell_width_inv;
28+
Type cell_width = {};
29+
Type cell_width_inv = {};
3030
};
3131

3232
// Type aliases for backward compatibility and convenience

warp/native/noise.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ inline CUDA_CALLABLE vec4 noise_4d_gradient(
457457
// (wrt all input axes), and Hessian (symmetric). Kept as a templated
458458
// struct so the composition rule is shared across 2D / 3D / 4D.
459459
template <unsigned N> struct noise_level_t {
460-
float val;
460+
float val = 0.0f;
461461
vec_t<N, float> grad;
462462
mat_t<N, N, float> hess;
463463
};

warp/native/solid_angle.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,25 @@ class SolidAngleProps {
3636
vec3 n_ij_diag;
3737
vec3 n_ijk_diag;
3838

39-
float sum_permute_n_xyz;
40-
float two_n_xxy_n_yxx;
41-
float two_n_xxz_n_zxx;
42-
float two_n_yyz_n_zyy;
43-
float two_n_yyx_n_xyy;
44-
float two_n_zzx_n_xzz;
45-
float two_n_zzy_n_yzz;
46-
47-
float n_xy;
48-
float n_yx;
49-
float n_yz;
50-
float n_zy;
51-
float n_zx;
52-
float n_xz;
39+
float sum_permute_n_xyz = 0.0f;
40+
float two_n_xxy_n_yxx = 0.0f;
41+
float two_n_xxz_n_zxx = 0.0f;
42+
float two_n_yyz_n_zyy = 0.0f;
43+
float two_n_yyx_n_xyy = 0.0f;
44+
float two_n_zzx_n_xzz = 0.0f;
45+
float two_n_zzy_n_yzz = 0.0f;
46+
47+
float n_xy = 0.0f;
48+
float n_yx = 0.0f;
49+
float n_yz = 0.0f;
50+
float n_zy = 0.0f;
51+
float n_zx = 0.0f;
52+
float n_xz = 0.0f;
5353

5454
bounds3 box;
5555
vec3 area_P;
56-
float area;
57-
float max_p_dist_sq;
56+
float area = 0.0f;
57+
float max_p_dist_sq = 0.0f;
5858
};
5959

6060
CUDA_CALLABLE inline void compute_integrals(

warp/native/tile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ template <typename Shape> struct tile_coord_iter_t {
624624
static constexpr int lastdim = N - 1;
625625

626626
tile_coord_t<N> coord;
627-
int strides[N]; // byte strides; bounded by array_t::strides[] int32 ABI
628-
int64_t byte_offset; // cumulative bytes; can exceed 2 GiB for large arrays
627+
int strides[N] = {}; // byte strides; bounded by array_t::strides[] int32 ABI
628+
int64_t byte_offset = 0; // cumulative bytes; can exceed 2 GiB for large arrays
629629

630630
// initialize from a starting coordinate and the global array byte strides/offsets
631631
inline CUDA_CALLABLE void init(const tile_coord_t<N>& c, const int* byte_strides, const int* tile_offset)

0 commit comments

Comments
 (0)