From 9f565bed858bbf62f3095ecc946065ec05c04042 Mon Sep 17 00:00:00 2001 From: Shahram Najm Date: Tue, 9 Jan 2024 15:42:16 +0000 Subject: [PATCH] Const correctness --- src/action_class_if.cc | 2 +- src/action_class_write.cc | 2 +- src/bufr_keys_iterator.cc | 4 ++-- src/bufr_util.cc | 6 +++--- src/codes_util.cc | 4 ++-- src/eccodes_prototypes.h | 2 +- src/grib_accessor_class_bitmap.cc | 2 +- src/grib_accessor_class_bufr_data_array.cc | 2 +- src/grib_accessor_class_scale_values.cc | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/action_class_if.cc b/src/action_class_if.cc index a5d28725a..0302e0625 100644 --- a/src/action_class_if.cc +++ b/src/action_class_if.cc @@ -92,7 +92,7 @@ static void init_class(grib_action_class* c) grib_action* grib_action_create_if(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false, int transient, - int lineno, char* file_being_parsed) + int lineno, const char* file_being_parsed) { char name[1024]; const size_t nameLen = sizeof(name); diff --git a/src/action_class_write.cc b/src/action_class_write.cc index 6b18a90d6..dc29ad050 100644 --- a/src/action_class_write.cc +++ b/src/action_class_write.cc @@ -174,7 +174,7 @@ static int execute(grib_action* act, grib_handle* h) } if (h->gts_header) { - char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; + const char gts_trailer[4] = { '\x0D', '\x0D', '\x0A', '\x03' }; if (fwrite(gts_trailer, 1, 4, of->handle) != 4) { grib_context_log(act->context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), "Error writing GTS trailer to %s", filename); diff --git a/src/bufr_keys_iterator.cc b/src/bufr_keys_iterator.cc index cc8b1b3ca..e1ab89697 100644 --- a/src/bufr_keys_iterator.cc +++ b/src/bufr_keys_iterator.cc @@ -199,7 +199,7 @@ char* codes_bufr_keys_iterator_get_name(const bufr_keys_iterator* ckiter) bufr_keys_iterator* kiter = (bufr_keys_iterator*)ckiter; int* r = 0; char* ret = 0; - grib_context* c = kiter->handle->context; + const grib_context* c = kiter->handle->context; DEBUG_ASSERT(kiter->current); if (kiter->prefix) { @@ -236,7 +236,7 @@ grib_accessor* codes_bufr_keys_iterator_get_accessor(bufr_keys_iterator* kiter) int codes_bufr_keys_iterator_delete(bufr_keys_iterator* kiter) { if (kiter) { - grib_context* c = kiter->handle->context; + const grib_context* c = kiter->handle->context; kiter->key_name = NULL; if (kiter->seen) grib_trie_delete(kiter->seen); diff --git a/src/bufr_util.cc b/src/bufr_util.cc index 7691c1fe0..0b4ffb0e7 100644 --- a/src/bufr_util.cc +++ b/src/bufr_util.cc @@ -18,7 +18,7 @@ int compute_bufr_key_rank(grib_handle* h, grib_string_list* keys, const char* ke grib_string_list* prev = keys; int theRank = 0; size_t size = 0; - grib_context* c = h->context; + const grib_context* c = h->context; DEBUG_ASSERT(h->product_kind == PRODUCT_BUFR); while (next && next->value && strcmp(next->value, key)) { @@ -1114,7 +1114,7 @@ int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* v // Returns 1 if the BUFR key is in the header and 0 if it is in the data section int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err) { - grib_accessor* acc = grib_find_accessor(h, key); + const grib_accessor* acc = grib_find_accessor(h, key); if (!acc) { *err = GRIB_NOT_FOUND; return 0; @@ -1126,7 +1126,7 @@ int codes_bufr_key_is_header(const grib_handle* h, const char* key, int* err) // Returns 1 if the BUFR key is a coordinate descriptor int codes_bufr_key_is_coordinate(const grib_handle* h, const char* key, int* err) { - grib_accessor* acc = grib_find_accessor(h, key); + const grib_accessor* acc = grib_find_accessor(h, key); if (!acc) { *err = GRIB_NOT_FOUND; return 0; diff --git a/src/codes_util.cc b/src/codes_util.cc index 61174f2f9..1b73432f8 100644 --- a/src/codes_util.cc +++ b/src/codes_util.cc @@ -133,7 +133,7 @@ char* codes_getenv(const char* name) int codes_check_grib_ieee_packing_value(int value) { - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); if (value != 32 && value != 64) { grib_context_log(c, GRIB_LOG_ERROR, "Invalid value for ECCODES_GRIB_IEEE_PACKING: should be 32 or 64"); return GRIB_INVALID_ARGUMENT; @@ -146,7 +146,7 @@ int codes_flush_sync_close_file(FILE* f) { int err = 0; int fd = 0; - grib_context* c = grib_context_get_default(); + const grib_context* c = grib_context_get_default(); Assert(f); fd = fileno(f); diff --git a/src/eccodes_prototypes.h b/src/eccodes_prototypes.h index aba20c9b4..f9e208e88 100644 --- a/src/eccodes_prototypes.h +++ b/src/eccodes_prototypes.h @@ -20,7 +20,7 @@ grib_action* grib_action_create_alias(grib_context* context, const char* name, c grib_action* grib_action_create_gen(grib_context* context, const char* name, const char* op, const long len, grib_arguments* params, grib_arguments* default_value, int flags, const char* name_space, const char* set); /* action_class_if.cc */ -grib_action* grib_action_create_if(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false, int transient, int lineno, char* file_being_parsed); +grib_action* grib_action_create_if(grib_context* context, grib_expression* expression, grib_action* block_true, grib_action* block_false, int transient, int lineno, const char* file_being_parsed); /* action_class_switch.cc */ grib_action* grib_action_create_switch(grib_context* context, grib_arguments* args, grib_case* Case, grib_action* Default); diff --git a/src/grib_accessor_class_bitmap.cc b/src/grib_accessor_class_bitmap.cc index a25d79a49..e5825a3c3 100644 --- a/src/grib_accessor_class_bitmap.cc +++ b/src/grib_accessor_class_bitmap.cc @@ -193,7 +193,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len) long tlen = 0; long i = 0; int err = 0; - grib_handle* hand = grib_handle_of_accessor(a); + const grib_handle* hand = grib_handle_of_accessor(a); err = grib_value_count(a, &tlen); if (err) diff --git a/src/grib_accessor_class_bufr_data_array.cc b/src/grib_accessor_class_bufr_data_array.cc index ec0baa494..9f745ba56 100644 --- a/src/grib_accessor_class_bufr_data_array.cc +++ b/src/grib_accessor_class_bufr_data_array.cc @@ -254,7 +254,7 @@ static size_t get_length(grib_accessor* a) grib_accessor_bufr_data_array* self = (grib_accessor_bufr_data_array*)a; size_t len = 0; - grib_handle* h = grib_handle_of_accessor(a); + const grib_handle* h = grib_handle_of_accessor(a); grib_get_size(h, self->bufrDataEncodedName, &len); diff --git a/src/grib_accessor_class_scale_values.cc b/src/grib_accessor_class_scale_values.cc index bae505f23..8c4b33fcb 100644 --- a/src/grib_accessor_class_scale_values.cc +++ b/src/grib_accessor_class_scale_values.cc @@ -131,7 +131,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len) size_t size = 0; int ret = 0, i = 0; grib_accessor_scale_values* self = (grib_accessor_scale_values*)a; - grib_context* c = a->context; + const grib_context* c = a->context; grib_handle* h = grib_handle_of_accessor(a); if (*val == 1)