mirror of https://github.com/ecmwf/eccodes.git
Const correctness and cppcheck warnings
This commit is contained in:
parent
9c71ac509c
commit
e87675b1ae
|
@ -1523,10 +1523,10 @@ static int build_bitmap(grib_accessor_bufr_data_array* self, unsigned char* data
|
||||||
int bitmapSize = 0, iDelayedReplication = 0;
|
int bitmapSize = 0, iDelayedReplication = 0;
|
||||||
int i, localReference, width, bitmapEndElementsDescriptorsIndex;
|
int i, localReference, width, bitmapEndElementsDescriptorsIndex;
|
||||||
long ppos, n;
|
long ppos, n;
|
||||||
grib_accessor* a = (grib_accessor*)self;
|
grib_accessor* a = (grib_accessor*)self;
|
||||||
grib_context* c = a->context;
|
const grib_context* c = a->context;
|
||||||
bufr_descriptor** descriptors = self->expanded->v;
|
bufr_descriptor** descriptors = self->expanded->v;
|
||||||
long* edi = elementsDescriptorsIndex->v;
|
const long* edi = elementsDescriptorsIndex->v;
|
||||||
/* int iel=grib_iarray_used_size(elementsDescriptorsIndex)-1; */
|
/* int iel=grib_iarray_used_size(elementsDescriptorsIndex)-1; */
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
@ -1652,10 +1652,10 @@ static int build_bitmap_new_data(grib_accessor_bufr_data_array* self, unsigned c
|
||||||
int bitmapSize = 0, iDelayedReplication = 0;
|
int bitmapSize = 0, iDelayedReplication = 0;
|
||||||
int i, bitmapEndElementsDescriptorsIndex;
|
int i, bitmapEndElementsDescriptorsIndex;
|
||||||
long n;
|
long n;
|
||||||
grib_accessor* a = (grib_accessor*)self;
|
grib_accessor* a = (grib_accessor*)self;
|
||||||
grib_context* c = a->context;
|
const grib_context* c = a->context;
|
||||||
bufr_descriptor** descriptors = self->expanded->v;
|
bufr_descriptor** descriptors = self->expanded->v;
|
||||||
long* edi = elementsDescriptorsIndex->v;
|
const long* edi = elementsDescriptorsIndex->v;
|
||||||
|
|
||||||
switch (descriptors[iBitmapOperator]->code) {
|
switch (descriptors[iBitmapOperator]->code) {
|
||||||
case 222000:
|
case 222000:
|
||||||
|
|
|
@ -108,7 +108,7 @@ grib_accessor_class* grib_accessor_class_bufr_extract_subsets = &_grib_accessor_
|
||||||
static void get_accessors(grib_accessor* a)
|
static void get_accessors(grib_accessor* a)
|
||||||
{
|
{
|
||||||
grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a;
|
grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a;
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
const grib_handle* h = grib_handle_of_accessor(a);
|
||||||
|
|
||||||
if (self->packAccessor)
|
if (self->packAccessor)
|
||||||
return;
|
return;
|
||||||
|
@ -118,7 +118,7 @@ static void get_accessors(grib_accessor* a)
|
||||||
|
|
||||||
static void init(grib_accessor* a, const long len, grib_arguments* arg)
|
static void init(grib_accessor* a, const long len, grib_arguments* arg)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a;
|
grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a;
|
||||||
|
|
||||||
a->length = 0;
|
a->length = 0;
|
||||||
|
@ -134,15 +134,14 @@ static int get_native_type(grib_accessor* a)
|
||||||
|
|
||||||
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
||||||
{
|
{
|
||||||
int err = 0;
|
|
||||||
grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a;
|
grib_accessor_bufr_extract_subsets* self = (grib_accessor_bufr_extract_subsets*)a;
|
||||||
size_t l = 1;
|
size_t l = 1;
|
||||||
long v[1];
|
long v[1];
|
||||||
|
|
||||||
get_accessors(a);
|
get_accessors(a);
|
||||||
|
|
||||||
v[0] = 1;
|
v[0] = 1;
|
||||||
err = grib_pack_long(self->packAccessor, v, &l);
|
int err = grib_pack_long(self->packAccessor, v, &l);
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err == GRIB_ENCODING_ERROR)
|
if (err == GRIB_ENCODING_ERROR)
|
||||||
grib_context_log(a->context, GRIB_LOG_ERROR, "Could not extract subset(s).\n\tHint: Did you forget to set unpack=1?");
|
grib_context_log(a->context, GRIB_LOG_ERROR, "Could not extract subset(s).\n\tHint: Did you forget to set unpack=1?");
|
||||||
|
|
|
@ -133,18 +133,17 @@ static int get_native_type(grib_accessor* a)
|
||||||
|
|
||||||
static int apply_thinning(grib_accessor* a)
|
static int apply_thinning(grib_accessor* a)
|
||||||
{
|
{
|
||||||
grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a;
|
const grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a;
|
||||||
int ret = 0;
|
|
||||||
long skip;
|
long skip;
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
grib_handle* h = grib_handle_of_accessor(a);
|
||||||
grib_context* c = h->context;
|
grib_context* c = h->context;
|
||||||
long compressed = 0, nsubsets;
|
long compressed = 0, nsubsets;
|
||||||
long i;
|
|
||||||
grib_iarray* subsets;
|
grib_iarray* subsets;
|
||||||
long* subsets_ar = 0;
|
long* subsets_ar = 0;
|
||||||
long start = 0, radius = 0;
|
long start = 0, radius = 0;
|
||||||
|
|
||||||
ret = grib_get_long(h, "compressedData", &compressed);
|
int ret = grib_get_long(h, "compressedData", &compressed);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
if (compressed) {
|
if (compressed) {
|
||||||
|
@ -168,7 +167,7 @@ static int apply_thinning(grib_accessor* a)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
subsets = grib_iarray_new(c, numberOfSubsets / skip + 1, 10);
|
subsets = grib_iarray_new(c, numberOfSubsets / skip + 1, 10);
|
||||||
for (i = 0; i < numberOfSubsets; i += skip + 1) {
|
for (long i = 0; i < numberOfSubsets; i += skip + 1) {
|
||||||
grib_iarray_push(subsets, i + 1);
|
grib_iarray_push(subsets, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,12 +199,11 @@ static int apply_thinning(grib_accessor* a)
|
||||||
|
|
||||||
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
||||||
{
|
{
|
||||||
int err = 0;
|
const grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a;
|
||||||
grib_accessor_bufr_simple_thinning* self = (grib_accessor_bufr_simple_thinning*)a;
|
|
||||||
|
|
||||||
if (*len == 0)
|
if (*len == 0)
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
err = apply_thinning(a);
|
int err = apply_thinning(a);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
grib_accessor_change_alternative_row_scanning* self = (grib_accessor_change_alternative_row_scanning*)a;
|
grib_accessor_change_alternative_row_scanning* self = (grib_accessor_change_alternative_row_scanning*)a;
|
||||||
grib_context* c = a->context;
|
const grib_context* c = a->context;
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
grib_handle* h = grib_handle_of_accessor(a);
|
||||||
long i, j, jr, theEnd, Ni, Nj, k, kp, alternativeRowScanning;
|
long i, j, jr, theEnd, Ni, Nj, k, kp, alternativeRowScanning;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
|
@ -146,7 +146,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
double* values = NULL;
|
double* values = NULL;
|
||||||
grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a;
|
grib_accessor_change_scanning_direction* self = (grib_accessor_change_scanning_direction*)a;
|
||||||
grib_context* c = a->context;
|
const grib_context* c = a->context;
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
grib_handle* h = grib_handle_of_accessor(a);
|
||||||
const char* cclass_name = a->cclass->name;
|
const char* cclass_name = a->cclass->name;
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,8 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||||
/* Sets val to the 'index' of the closes date */
|
/* Sets val to the 'index' of the closes date */
|
||||||
static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
||||||
{
|
{
|
||||||
|
const grib_accessor_closest_date* self = (grib_accessor_closest_date*)a;
|
||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
long num_forecasts = 0; /* numberOfForecastsUsedInLocalTime */
|
long num_forecasts = 0; /* numberOfForecastsUsedInLocalTime */
|
||||||
/* These relate to the date and time in Section 1 */
|
/* These relate to the date and time in Section 1 */
|
||||||
|
@ -171,9 +173,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
||||||
/* These relate to the forecast dates and times in Section 4 */
|
/* These relate to the forecast dates and times in Section 4 */
|
||||||
long *yearArray, *monthArray, *dayArray, *hourArray, *minuteArray, *secondArray;
|
long *yearArray, *monthArray, *dayArray, *hourArray, *minuteArray, *secondArray;
|
||||||
|
|
||||||
grib_accessor_closest_date* self = (grib_accessor_closest_date*)a;
|
|
||||||
grib_handle* h = grib_handle_of_accessor(a);
|
grib_handle* h = grib_handle_of_accessor(a);
|
||||||
grib_context* c = a->context;
|
const grib_context* c = a->context;
|
||||||
*val = -1; /* initialise to an invalid index */
|
*val = -1; /* initialise to an invalid index */
|
||||||
|
|
||||||
if ((err = grib_get_long_internal(h, self->numForecasts, &num_forecasts)) != GRIB_SUCCESS) return err;
|
if ((err = grib_get_long_internal(h, self->numForecasts, &num_forecasts)) != GRIB_SUCCESS) return err;
|
||||||
|
|
|
@ -110,8 +110,8 @@ grib_accessor_class* grib_accessor_class_codeflag = &_grib_accessor_class_codefl
|
||||||
static void init(grib_accessor* a, const long len, grib_arguments* param)
|
static void init(grib_accessor* a, const long len, grib_arguments* param)
|
||||||
{
|
{
|
||||||
grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
|
grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
|
||||||
a->length = len;
|
a->length = len;
|
||||||
self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0);
|
self->tablename = grib_arguments_get_string(grib_handle_of_accessor(a), param, 0);
|
||||||
Assert(a->length >= 0);
|
Assert(a->length >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +123,8 @@ static int test_bit(long a, long b)
|
||||||
|
|
||||||
static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
|
static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
|
||||||
{
|
{
|
||||||
grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
|
const grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
|
||||||
FILE* f = NULL;
|
FILE* f = NULL;
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
char bval[50];
|
char bval[50];
|
||||||
char num[50];
|
char num[50];
|
||||||
|
@ -200,10 +200,10 @@ static int value_count(grib_accessor* a, long* count)
|
||||||
|
|
||||||
static void dump(grib_accessor* a, grib_dumper* dumper)
|
static void dump(grib_accessor* a, grib_dumper* dumper)
|
||||||
{
|
{
|
||||||
grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
|
const grib_accessor_codeflag* self = (grib_accessor_codeflag*)a;
|
||||||
long v;
|
long v = 0;
|
||||||
char flagname[1024];
|
char flagname[1024] = {0,};
|
||||||
char fname[1024];
|
char fname[1024] = {0,};
|
||||||
|
|
||||||
size_t llen = 1;
|
size_t llen = 1;
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,7 @@ static int unpack_float(grib_accessor* a, float* val, size_t* len)
|
||||||
static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
||||||
{
|
{
|
||||||
// The index idx relates to codedValues NOT values!
|
// The index idx relates to codedValues NOT values!
|
||||||
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
const grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
||||||
grib_handle* hand = grib_handle_of_accessor(a);
|
grib_handle* hand = grib_handle_of_accessor(a);
|
||||||
int err = 0;
|
int err = 0;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
@ -686,7 +686,7 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
||||||
|
|
||||||
static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array)
|
static int unpack_double_element_set(grib_accessor* a, const size_t* index_array, size_t len, double* val_array)
|
||||||
{
|
{
|
||||||
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
const grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
||||||
grib_handle* hand = grib_handle_of_accessor(a);
|
grib_handle* hand = grib_handle_of_accessor(a);
|
||||||
size_t size = 0, i = 0;
|
size_t size = 0, i = 0;
|
||||||
double* values = NULL;
|
double* values = NULL;
|
||||||
|
|
|
@ -161,11 +161,11 @@ typedef struct change_coding_params
|
||||||
static void init(grib_accessor* a, const long len, grib_arguments* args)
|
static void init(grib_accessor* a, const long len, grib_arguments* args)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
grib_handle* hand = grib_handle_of_accessor(a);
|
grib_handle* hand = grib_handle_of_accessor(a);
|
||||||
self->tablesAccessorName = grib_arguments_get_name(hand, args, n++);
|
self->tablesAccessorName = grib_arguments_get_name(hand, args, n++);
|
||||||
self->expandedName = grib_arguments_get_name(hand, args, n++);
|
self->expandedName = grib_arguments_get_name(hand, args, n++);
|
||||||
self->rank = grib_arguments_get_long(hand, args, n++);
|
self->rank = grib_arguments_get_long(hand, args, n++);
|
||||||
if (self->rank != 0) {
|
if (self->rank != 0) {
|
||||||
self->expandedAccessor = grib_find_accessor(hand, self->expandedName);
|
self->expandedAccessor = grib_find_accessor(hand, self->expandedName);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
|
||||||
if (BUFR_DESCRIPTORS_ARRAY_USED_SIZE(unexpanded) == 0)
|
if (BUFR_DESCRIPTORS_ARRAY_USED_SIZE(unexpanded) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
us = grib_bufr_descriptor_clone(grib_bufr_descriptors_array_get(unexpanded, 0));
|
us = grib_bufr_descriptor_clone(grib_bufr_descriptors_array_get(unexpanded, 0));
|
||||||
us->context = c;
|
us->context = c;
|
||||||
|
|
||||||
*err = 0;
|
*err = 0;
|
||||||
|
@ -262,7 +262,7 @@ static void __expand(grib_accessor* a, bufr_descriptors_array* unexpanded, bufr_
|
||||||
|
|
||||||
inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR);
|
inner_unexpanded = grib_bufr_descriptors_array_new(c, DESC_SIZE_INIT, DESC_SIZE_INCR);
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
vv = grib_bufr_descriptor_new(self->tablesAccessor, v_array[i], !SILENT, err);
|
vv = grib_bufr_descriptor_new(self->tablesAccessor, v_array[i], !SILENT, err);
|
||||||
inner_unexpanded = grib_bufr_descriptors_array_push(inner_unexpanded, vv);
|
inner_unexpanded = grib_bufr_descriptors_array_push(inner_unexpanded, vv);
|
||||||
}
|
}
|
||||||
grib_context_free(c, v_array);
|
grib_context_free(c, v_array);
|
||||||
|
@ -707,27 +707,27 @@ static int expand(grib_accessor* a)
|
||||||
int grib_accessor_class_expanded_descriptors_set_do_expand(grib_accessor* a, long do_expand)
|
int grib_accessor_class_expanded_descriptors_set_do_expand(grib_accessor* a, long do_expand)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
self->do_expand = do_expand;
|
self->do_expand = do_expand;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor* a, int* err)
|
bufr_descriptors_array* grib_accessor_class_expanded_descriptors_get_expanded(grib_accessor* a, int* err)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
const grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
*err = expand(a);
|
*err = expand(a);
|
||||||
return self->expanded;
|
return self->expanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i;
|
size_t i = 0;
|
||||||
size_t expandedSize;
|
size_t expandedSize;
|
||||||
|
|
||||||
if (self->rank != 2) {
|
if (self->rank != 2) {
|
||||||
long* lval = (long*)grib_context_malloc_clear(a->context, *len * sizeof(long));
|
long* lval = (long*)grib_context_malloc_clear(a->context, *len * sizeof(long));
|
||||||
ret = unpack_long(a, lval, len);
|
ret = unpack_long(a, lval, len);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
for (i = 0; i < *len; i++)
|
for (i = 0; i < *len; i++)
|
||||||
|
@ -756,9 +756,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
||||||
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
size_t rlen = 0;
|
size_t rlen = 0;
|
||||||
size_t i;
|
size_t i = 0;
|
||||||
|
|
||||||
ret = expand(a);
|
ret = expand(a);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -830,15 +830,15 @@ static int unpack_string_array(grib_accessor* a, char** buffer, size_t* len)
|
||||||
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
self->do_expand = 1;
|
self->do_expand = 1;
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int value_count(grib_accessor* a, long* rlen)
|
static int value_count(grib_accessor* a, long* rlen)
|
||||||
{
|
{
|
||||||
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
grib_accessor_expanded_descriptors* self = (grib_accessor_expanded_descriptors*)a;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
*rlen = 0;
|
*rlen = 0;
|
||||||
|
|
||||||
err = expand(a);
|
err = expand(a);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in New Issue