Const correctness

This commit is contained in:
shahramn 2024-09-06 14:59:39 +01:00
parent fc73927c42
commit 6924dc014a
5 changed files with 13 additions and 15 deletions

View File

@ -199,17 +199,16 @@ long grib_accessor_class_signed_t::next_offset(grib_accessor* a)
int grib_accessor_class_signed_t::is_missing(grib_accessor* a) int grib_accessor_class_signed_t::is_missing(grib_accessor* a)
{ {
int i = 0; unsigned char ff = 0xff;
unsigned char ff = 0xff;
unsigned long offset = a->offset; unsigned long offset = a->offset;
grib_handle* hand = grib_handle_of_accessor(a); const grib_handle* hand = grib_handle_of_accessor(a);
if (a->length == 0) { if (a->length == 0) {
Assert(a->vvalue != NULL); Assert(a->vvalue != NULL);
return a->vvalue->missing; return a->vvalue->missing;
} }
for (i = 0; i < a->length; i++) { for (long i = 0; i < a->length; i++) {
if (hand->buffer->data[offset] != ff) if (hand->buffer->data[offset] != ff)
return 0; return 0;
offset++; offset++;

View File

@ -16,9 +16,9 @@ grib_accessor_class* grib_accessor_class_uint64 = &_grib_accessor_class_uint64;
int grib_accessor_class_uint64_t::unpack_long(grib_accessor* a, long* val, size_t* len) int grib_accessor_class_uint64_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{ {
long value = 0; long value = 0;
long pos = a->offset; long pos = a->offset;
unsigned char* data = grib_handle_of_accessor(a)->buffer->data; const unsigned char* data = grib_handle_of_accessor(a)->buffer->data;
unsigned long long result = 0, tmp; unsigned long long result = 0, tmp;
int i; int i;

View File

@ -16,17 +16,16 @@ grib_accessor_class* grib_accessor_class_uint64_little_endian = &_grib_accessor_
int grib_accessor_class_uint64_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len) int grib_accessor_class_uint64_little_endian_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{ {
long value = 0; long value = 0;
long pos = a->offset; long pos = a->offset;
unsigned char* data = grib_handle_of_accessor(a)->buffer->data; const unsigned char* data = grib_handle_of_accessor(a)->buffer->data;
unsigned long long result = 0, tmp; unsigned long long result = 0, tmp;
int i;
if (*len < 1) { if (*len < 1) {
return GRIB_ARRAY_TOO_SMALL; return GRIB_ARRAY_TOO_SMALL;
} }
for (i = 7; i >= 0; i--) { for (int i = 7; i >= 0; i--) {
result <<= 8; result <<= 8;
result |= data[pos + i]; result |= data[pos + i];
} }

View File

@ -18,7 +18,7 @@ int grib_accessor_class_uint8_t::unpack_long(grib_accessor* a, long* val, size_t
{ {
long value = 0; long value = 0;
long pos = a->offset; long pos = a->offset;
unsigned char* data = grib_handle_of_accessor(a)->buffer->data; const unsigned char* data = grib_handle_of_accessor(a)->buffer->data;
if (*len < 1) { if (*len < 1) {
return GRIB_ARRAY_TOO_SMALL; return GRIB_ARRAY_TOO_SMALL;

View File

@ -162,7 +162,7 @@ int pack_long_unsigned_helper(grib_accessor* a, const long* val, size_t* len, in
int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len) int grib_accessor_class_unsigned_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{ {
grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a; const grib_accessor_unsigned_t* self = (grib_accessor_unsigned_t*)a;
long rlen = 0; long rlen = 0;
unsigned long i = 0; unsigned long i = 0;
@ -245,7 +245,7 @@ int grib_accessor_class_unsigned_t::is_missing(grib_accessor* a)
{ {
const unsigned char ff = 0xff; const unsigned char ff = 0xff;
unsigned long offset = a->offset; unsigned long offset = a->offset;
grib_handle* hand = grib_handle_of_accessor(a); const grib_handle* hand = grib_handle_of_accessor(a);
if (a->length == 0) { if (a->length == 0) {
Assert(a->vvalue != NULL); Assert(a->vvalue != NULL);