Const correctness and cppcheck warnings

This commit is contained in:
shahramn 2024-03-06 20:37:10 +00:00
parent 5cd1f39afc
commit 4b08450a0d
5 changed files with 11 additions and 11 deletions

View File

@ -199,8 +199,9 @@ static void destroy(grib_context* context, grib_action* act)
{
grib_action_hash_array* self = (grib_action_hash_array*)act;
grib_hash_array_value* v = self->hash_array;
Assert(!v); // not implemented
// This is currently unset. So assert that it is NULL
const grib_hash_array_value* v = self->hash_array;
Assert(v == NULL);
// if (v)
// grib_trie_delete(v->index);
// while (v) {
@ -335,6 +336,6 @@ grib_hash_array_value* get_hash_array(grib_handle* h, grib_action* a)
const char* get_hash_array_full_path(grib_action* a)
{
grib_action_hash_array* self = (grib_action_hash_array*)a;
const grib_action_hash_array* self = (grib_action_hash_array*)a;
return self->full_path;
}

View File

@ -73,16 +73,15 @@ grib_action* grib_action_create_noop(grib_context* context, const char* fname)
{
char buf[1024];
grib_action_noop* a;
grib_action_class* c = grib_action_class_noop;
grib_action* act = (grib_action*)grib_context_malloc_clear_persistent(context, c->size);
act->op = grib_context_strdup_persistent(context, "section");
act->cclass = c;
a = (grib_action_noop*)act;
grib_action_noop* a = (grib_action_noop*)act;
act->context = context;
snprintf(buf, 1024, "_noop%p", (void*)a);
snprintf(buf, sizeof(buf), "_noop%p", (void*)a);
act->name = grib_context_strdup_persistent(context, buf);

View File

@ -114,8 +114,8 @@ static int execute(grib_action* a, grib_handle* h)
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_set* self = (grib_action_set*)act;
int i = 0;
const grib_action_set* self = (grib_action_set*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);

View File

@ -117,7 +117,7 @@ static void dump(grib_action* act, FILE* f, int lvl)
static grib_action* get_empty_template(grib_context* c, int* err)
{
char fname[] = "empty_template.def";
char* path = grib_context_full_defs_path(c, fname);
const char* path = grib_context_full_defs_path(c, fname);
if (path) {
*err = GRIB_SUCCESS;
return grib_parse_file(c, path);

View File

@ -122,8 +122,8 @@ static int execute(grib_action* act, grib_handle* h)
static void dump(grib_action* act, FILE* f, int lvl)
{
int i = 0;
grib_action_transient_darray* self = (grib_action_transient_darray*)act;
int i = 0;
const grib_action_transient_darray* self = (grib_action_transient_darray*)act;
for (i = 0; i < lvl; i++)
grib_context_print(act->context, f, " ");
grib_context_print(act->context, f, self->name);