Skip to content

Commit 4b08450

Browse files
committed
Const correctness and cppcheck warnings
1 parent 5cd1f39 commit 4b08450

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/action_class_hash_array.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,9 @@ static void destroy(grib_context* context, grib_action* act)
199199
{
200200
grib_action_hash_array* self = (grib_action_hash_array*)act;
201201

202-
grib_hash_array_value* v = self->hash_array;
203-
Assert(!v); // not implemented
202+
// This is currently unset. So assert that it is NULL
203+
const grib_hash_array_value* v = self->hash_array;
204+
Assert(v == NULL);
204205
// if (v)
205206
// grib_trie_delete(v->index);
206207
// while (v) {
@@ -335,6 +336,6 @@ grib_hash_array_value* get_hash_array(grib_handle* h, grib_action* a)
335336

336337
const char* get_hash_array_full_path(grib_action* a)
337338
{
338-
grib_action_hash_array* self = (grib_action_hash_array*)a;
339+
const grib_action_hash_array* self = (grib_action_hash_array*)a;
339340
return self->full_path;
340341
}

src/action_class_noop.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,15 @@ grib_action* grib_action_create_noop(grib_context* context, const char* fname)
7373
{
7474
char buf[1024];
7575

76-
grib_action_noop* a;
7776
grib_action_class* c = grib_action_class_noop;
7877
grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size);
7978
act->op = grib_context_strdup_persistent(context, "section");
8079

8180
act->cclass = c;
82-
a = (grib_action_noop*)act;
81+
grib_action_noop* a = (grib_action_noop*)act;
8382
act->context = context;
8483

85-
snprintf(buf, 1024, "_noop%p", (void*)a);
84+
snprintf(buf, sizeof(buf), "_noop%p", (void*)a);
8685

8786
act->name = grib_context_strdup_persistent(context, buf);
8887

src/action_class_set.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ static int execute(grib_action* a, grib_handle* h)
114114

115115
static void dump(grib_action* act, FILE* f, int lvl)
116116
{
117-
int i = 0;
118-
grib_action_set* self = (grib_action_set*)act;
117+
int i = 0;
118+
const grib_action_set* self = (grib_action_set*)act;
119119
for (i = 0; i < lvl; i++)
120120
grib_context_print(act->context, f, " ");
121121
grib_context_print(act->context, f, self->name);

src/action_class_template.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void dump(grib_action* act, FILE* f, int lvl)
117117
static grib_action* get_empty_template(grib_context* c, int* err)
118118
{
119119
char fname[] = "empty_template.def";
120-
char* path = grib_context_full_defs_path(c, fname);
120+
const char* path = grib_context_full_defs_path(c, fname);
121121
if (path) {
122122
*err = GRIB_SUCCESS;
123123
return grib_parse_file(c, path);

src/action_class_transient_darray.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ static int execute(grib_action* act, grib_handle* h)
122122

123123
static void dump(grib_action* act, FILE* f, int lvl)
124124
{
125-
int i = 0;
126-
grib_action_transient_darray* self = (grib_action_transient_darray*)act;
125+
int i = 0;
126+
const grib_action_transient_darray* self = (grib_action_transient_darray*)act;
127127
for (i = 0; i < lvl; i++)
128128
grib_context_print(act->context, f, " ");
129129
grib_context_print(act->context, f, self->name);

0 commit comments

Comments
 (0)