cppcheck warning: identicalConditionAfterEarlyExit

This commit is contained in:
Shahram Najm 2021-01-17 00:13:30 +00:00
parent d7a7c79fbe
commit 9cd5b141ef
18 changed files with 44 additions and 47 deletions

View File

@ -332,14 +332,9 @@ static int select_area(grib_accessor* a)
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
int err = 0;
/*grib_accessor_bufr_extract_area_subsets *self =(grib_accessor_bufr_extract_area_subsets*)a;*/
if (*len == 0)
return GRIB_SUCCESS;
err = select_area(a);
if (err)
return err;
return err;
return select_area(a);
}

View File

@ -473,14 +473,9 @@ static int select_datetime(grib_accessor* a)
static int pack_long(grib_accessor* a, const long* val, size_t* len)
{
int err = 0;
/*grib_accessor_bufr_extract_datetime_subsets *self =(grib_accessor_bufr_extract_datetime_subsets*)a;*/
if (*len == 0)
return GRIB_SUCCESS;
err = select_datetime(a);
if (err)
return err;
return err;
return select_datetime(a);
}

View File

@ -239,9 +239,5 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
if (err)
return err;
err = grib_set_long(a->parent->h, self->doExtractSubsets, 1);
if (err)
return err;
return err;
return grib_set_long(a->parent->h, self->doExtractSubsets, 1);
}

View File

@ -280,11 +280,13 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
values = (double*)grib_context_malloc_clear(a->parent->h->context, size * sizeof(double));
err = grib_get_double_array(a->parent->h, "codedValues", values, &size);
if (err)
if (err) {
grib_context_free(a->parent->h->context, values);
return err;
}
*val = values[idx];
grib_context_free(a->parent->h->context, values);
return err;
return GRIB_SUCCESS;
}
static int pack_double(grib_accessor* a, const double* val, size_t* len)
@ -367,7 +369,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
grib_context_free(a->context, values);
return ret;
return GRIB_SUCCESS;
}
static int get_native_type(grib_accessor* a)

View File

@ -328,11 +328,13 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
values = (double*)grib_context_malloc_clear(a->context, size * sizeof(double));
err = grib_get_double_array(grib_handle_of_accessor(a), "codedValues", values, &size);
if (err)
if (err) {
grib_context_free(a->context, values);
return err;
}
*val = values[idx];
grib_context_free(a->context, values);
return err;
return GRIB_SUCCESS;
}
static int unpack_double(grib_accessor* a, double* values, size_t* len)
@ -1889,7 +1891,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
grib_context_free(a->context, groupWidths);
grib_context_free(a->context, firstOrderValues);
return ret;
return GRIB_SUCCESS;
}
static void destroy(grib_context* context, grib_accessor* a)

View File

@ -159,7 +159,7 @@ static int value_count(grib_accessor* a, long* count)
return err;
*count = expand_by * len;
return err;
return GRIB_SUCCESS;
}
static int pack_double(grib_accessor* a, const double* val, size_t* len)

View File

@ -951,11 +951,13 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
values = (double*)grib_context_malloc_clear(a->context, size * sizeof(double));
err = grib_get_double_array(grib_handle_of_accessor(a), "codedValues", values, &size);
if (err)
if (err) {
grib_context_free(a->context, values);
return err;
}
*val = values[idx];
grib_context_free(a->context, values);
return err;
return GRIB_SUCCESS;
}
static int value_count(grib_accessor* a, long* count)

View File

@ -591,9 +591,11 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
values = (double*)grib_context_malloc_clear(a->context, size * sizeof(double));
err = grib_get_double_array(grib_handle_of_accessor(a), "codedValues", values, &size);
if (err)
if (err) {
grib_context_free(a->context, values);
return err;
}
*val = values[idx];
grib_context_free(a->context, values);
return err;
return GRIB_SUCCESS;
}

View File

@ -368,7 +368,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
*val = atol(buffer);
*len = 1;
return err;
return GRIB_SUCCESS;
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
@ -384,5 +384,5 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
*val = atof(buffer);
*len = 1;
return err;
return GRIB_SUCCESS;
}

View File

@ -646,7 +646,7 @@ static int expand(grib_accessor* a)
if (expanded) {
self->expanded = expanded;
grib_context_free(c, u);
return err;
return GRIB_SUCCESS;
}
if (!self->tablesAccessor) {

View File

@ -173,7 +173,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
if (ret == GRIB_SUCCESS)
*len = 4;
return ret;
return GRIB_SUCCESS;
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
@ -205,7 +205,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (ret == GRIB_SUCCESS)
*len = 4;
return ret;
return GRIB_SUCCESS;
}
static void dump(grib_accessor* a, grib_dumper* dumper)

View File

@ -350,7 +350,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
if (ret == GRIB_SUCCESS)
*len = 1;
return ret;
return GRIB_SUCCESS;
}
static int is_missing(grib_accessor* a)

View File

@ -184,14 +184,14 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
*len = size;
return ret;
return GRIB_SUCCESS;
}
static int value_count(grib_accessor* a, long* count)
{
grib_accessor_latlonvalues* self = (grib_accessor_latlonvalues*)a;
grib_handle* h = grib_handle_of_accessor(a);
int ret;
int ret = GRIB_SUCCESS;
size_t size;
if ((ret = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS) {
grib_context_log(h->context, GRIB_LOG_ERROR, "unable to get size of %s", self->values);
@ -199,5 +199,5 @@ static int value_count(grib_accessor* a, long* count)
}
*count = 3 * size;
return ret;
return GRIB_SUCCESS;
}

View File

@ -198,7 +198,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
*val = self->yearOrMonth == 1 ? rdbYear : rdbMonth;
*len = 1;
return ret;
return GRIB_SUCCESS;
}
static int pack_long(grib_accessor* a, const long* v, size_t* len)

View File

@ -539,7 +539,7 @@ static int value_count(grib_accessor* a, long* count)
return err;
*count = self->tableCodesSize;
return err;
return GRIB_SUCCESS;
}
static void destroy(grib_context* context, grib_accessor* a)

View File

@ -163,7 +163,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
if (size == 0) {
*val = 0;
return ret;
return GRIB_SUCCESS;
}
values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size);
if (!values)
@ -177,7 +177,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
grib_context_free(a->context, values);
return ret;
return GRIB_SUCCESS;
}
static int unpack_double(grib_accessor* a, double* val, size_t* len)
@ -196,21 +196,24 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (size == 0) {
*val = 0;
return ret;
return GRIB_SUCCESS;
}
values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size);
if (!values)
return GRIB_OUT_OF_MEMORY;
grib_get_double_array(grib_handle_of_accessor(a), self->values, values, &size);
ret = grib_get_double_array(grib_handle_of_accessor(a), self->values, values, &size);
if (ret) {
grib_context_free(a->context, values);
return ret;
}
*val = 0;
for (i = 0; i < size; i++)
*val += values[i];
grib_context_free(a->context, values);
return ret;
return GRIB_SUCCESS;
}
static int value_count(grib_accessor* a, long* count)

View File

@ -222,7 +222,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
*len = 1;
return ret;
return GRIB_SUCCESS;
}
static int value_count(grib_accessor* a, long* count)

View File

@ -255,7 +255,7 @@ static int unpack_long(grib_accessor* a, long* v, size_t* len)
*v = strtol(val, &last, 10);
/* if (*last) {err=GRIB_WRONG_CONVERSION;} */
return err;
return GRIB_SUCCESS;
}
static int unpack_double(grib_accessor* a, double* v, size_t* len)