Fix key comparisons

This commit is contained in:
Shahram Najm 2023-12-17 17:08:32 +00:00
parent 8e5132f0be
commit dc58a160c0
4 changed files with 10 additions and 17 deletions

View File

@ -446,7 +446,7 @@ static int get_native_type(grib_accessor* a)
static int compare(grib_accessor* a, grib_accessor* b)
{
int retval = 0;
int retval = GRIB_SUCCESS;
double* aval = 0;
double* bval = 0;
@ -475,10 +475,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_double(b, bval, &blen);
retval = GRIB_SUCCESS;
while (alen != 0) {
if (*bval != *aval)
retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
}
grib_context_free(a->context, aval);

View File

@ -241,10 +241,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_long(b, bval, &blen);
retval = GRIB_SUCCESS;
while (alen != 0) {
if (*bval != *aval)
retval = GRIB_LONG_VALUE_MISMATCH;
alen--;
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_LONG_VALUE_MISMATCH;
}
grib_context_free(a->context, aval);

View File

@ -313,10 +313,9 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_double(a, aval, &alen);
grib_unpack_double(b, bval, &blen);
while (alen != 0) {
if (*bval != *aval)
retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
retval = GRIB_SUCCESS;
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
}
grib_context_free(a->context, aval);

View File

@ -266,10 +266,8 @@ static int compare(grib_accessor* a, grib_accessor* b)
grib_unpack_double(b, bval, &blen);
retval = GRIB_SUCCESS;
while (alen != 0) {
if (*bval != *aval)
retval = GRIB_DOUBLE_VALUE_MISMATCH;
alen--;
for (size_t i=0; i<alen && retval == GRIB_SUCCESS; ++i) {
if (aval[i] != bval[i]) retval = GRIB_DOUBLE_VALUE_MISMATCH;
}
grib_context_free(a->context, aval);