Clang static analyser warnings

This commit is contained in:
Shahram Najm 2020-02-27 13:12:49 +00:00
parent e8d3a34295
commit 76dfc35268
4 changed files with 25 additions and 21 deletions

View File

@ -200,8 +200,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
long nn = 0;
int err = 0;
size_t size = 0;
long missing_value;
long missing_value = 0;
double* coded_vals = NULL;
err = grib_value_count(a, &nn);
@ -231,7 +230,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
if (number_of_values > 0) {
coded_vals = (double*)grib_context_malloc(a->context, number_of_values * sizeof(double));
if (coded_vals == NULL)
return GRIB_OUT_OF_MEMORY;
}
@ -252,12 +250,16 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
a->name, number_of_points);
if (latitude_of_first_point == 0) {
if (number_of_values && !coded_vals)
return GRIB_INTERNAL_ERROR;
for (i = 0; i < number_of_values; i++)
val[i] = coded_vals[i];
for (i = number_of_values; i < number_of_points; i++)
val[i] = coded_vals[number_of_values - 1];
}
else {
if ((ni-1) && !coded_vals)
return GRIB_INTERNAL_ERROR;
for (i = 0; i < ni - 1; i++)
val[i] = coded_vals[0];
for (i = ni - 1; i < number_of_points; i++)

View File

@ -208,8 +208,10 @@ static grib_points* get_points(grib_box* box, double north, double west, double
grib_context* c = box->context;
points = grib_points_new(c, self->size);
if (!points)
grib_context_log(c, GRIB_LOG_FATAL, "unable to create grib_points\n");
if (!points) {
grib_context_log(c, GRIB_LOG_ERROR, "unable to create grib_points\n");
return NULL;
}
index = 0;
l = 0;

View File

@ -271,8 +271,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
double value = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, icount;
int err = 0, i = 0, icount = 0;
int cols = 2;
long count = 0;
char* sval;
@ -353,8 +352,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
long value = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, r, icount;
int err = 0, i = 0, r = 0, icount = 0;
int cols = 4;
long count = 0;
char* sval = NULL;
@ -483,10 +481,9 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
{
grib_dumper_bufr_encode_python* self = (grib_dumper_bufr_encode_python*)d;
long value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, icount;
int err = 0, i = 0, icount = 0;
int cols = 4;
long count = 0;
grib_context* c = a->context;
@ -495,15 +492,16 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size);
err = grib_unpack_long(a, values, &size);
err = grib_unpack_long(a, values, &size2);
}
else {
err = grib_unpack_long(a, &value, &size);
err = grib_unpack_long(a, &value, &size2);
}
Assert(size2 == size);
self->empty = 0;

View File

@ -265,6 +265,8 @@ int main(int argc, char *argv[])
if(result)
grib_handle_delete(result);
free(values);
if(fclose(out))
{
perror(argv[argc-1]);