Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
shahramn committed Apr 27, 2024
1 parent 5dd62ff commit 17e250b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
11 changes: 4 additions & 7 deletions src/accessor/grib_accessor_class_data_apply_boustrophedonic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ void grib_accessor_class_data_apply_boustrophedonic_t::dump(grib_accessor* a, gr

int grib_accessor_class_data_apply_boustrophedonic_t::value_count(grib_accessor* a, long* numberOfPoints){
grib_accessor_data_apply_boustrophedonic_t* self = (grib_accessor_data_apply_boustrophedonic_t*)a;
int ret = 0;

*numberOfPoints = 0;
ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints);
int ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, numberOfPoints);

return ret;
}
Expand All @@ -54,17 +53,16 @@ int grib_accessor_class_data_apply_boustrophedonic_t::unpack_float(grib_accessor
int grib_accessor_class_data_apply_boustrophedonic_t::unpack_double_element(grib_accessor* a, size_t idx, double* val){
size_t size;
double* values;
int err = 0;

/* GRIB-564: The index idx relates to codedValues NOT values! */
err = grib_get_size(a->parent->h, "codedValues", &size);
int err = grib_get_size(a->parent->h, "codedValues", &size);
if (err)
return err;
if (idx > size)
return GRIB_INVALID_NEAREST;

values = (double*)grib_context_malloc_clear(a->parent->h->context, size * sizeof(double));
err = grib_get_double_array(a->parent->h, "codedValues", values, &size);
err = grib_get_double_array(a->parent->h, "codedValues", values, &size);
if (err) {
grib_context_free(a->parent->h->context, values);
return err;
Expand Down Expand Up @@ -111,10 +109,9 @@ int grib_accessor_class_data_apply_boustrophedonic_t::pack_double(grib_accessor*
double* pval = 0;
size_t valuesSize = 0;
long i, j;
int ret;
long numberOfPoints, numberOfRows, numberOfColumns;

ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints);
int ret = grib_get_long_internal(grib_handle_of_accessor(a), self->numberOfPoints, &numberOfPoints);
if (ret)
return ret;

Expand Down
3 changes: 1 addition & 2 deletions src/accessor/grib_accessor_class_longitudes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ static int get_distinct(grib_accessor* a, double** val, long* len){
double* v1 = NULL;
double dummyLat = 0;
int ret = 0;
int i;
size_t size = *len;
grib_context* c = a->context;

Expand Down Expand Up @@ -157,7 +156,7 @@ static int get_distinct(grib_accessor* a, double** val, long* len){
prev = v[0];
v1[0] = prev;
count = 1;
for (i = 1; i < *len; i++) {
for (long i = 1; i < *len; i++) {
if (v[i] != prev) {
prev = v[i];
v1[count] = prev;
Expand Down
13 changes: 5 additions & 8 deletions src/accessor/grib_accessor_class_spd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ long grib_accessor_class_spd_t::byte_count(grib_accessor* a){

static long compute_byte_count(grib_accessor* a){
grib_accessor_spd_t* self = (grib_accessor_spd_t*)a;
long numberOfBits;
long numberOfElements;
int ret = 0;
long numberOfBits = 0;
long numberOfElements = 0;

ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits);
int ret = grib_get_long(grib_handle_of_accessor(a), self->numberOfBits, &numberOfBits);
if (ret) {
grib_context_log(a->context, GRIB_LOG_ERROR,
"%s unable to get %s to compute size", a->name, self->numberOfBits);
Expand Down Expand Up @@ -55,13 +54,11 @@ void grib_accessor_class_spd_t::init(grib_accessor* a, const long len, grib_argu

int grib_accessor_class_spd_t::unpack_long(grib_accessor* a, long* val, size_t* len){
grib_accessor_spd_t* self = (grib_accessor_spd_t*)a;
int i;
int ret = 0;
long pos = a->offset * 8;
long rlen = 0;
long numberOfBits = 0;

ret = value_count(a, &rlen);
int ret = value_count(a, &rlen);
if (ret)
return ret;

Expand All @@ -80,7 +77,7 @@ int grib_accessor_class_spd_t::unpack_long(grib_accessor* a, long* val, size_t*
return GRIB_DECODING_ERROR;
}

for (i = 0; i < rlen - 1; i++)
for (long i = 0; i < rlen - 1; i++)
val[i] = grib_decode_unsigned_long(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits);

val[rlen - 1] = grib_decode_signed_longb(grib_handle_of_accessor(a)->buffer->data, &pos, numberOfBits);
Expand Down

0 comments on commit 17e250b

Please sign in to comment.