Clang static analyser warnings

This commit is contained in:
Shahram Najm 2020-02-28 11:46:39 +00:00
parent cfcb0c764d
commit ab0ec2387e
5 changed files with 25 additions and 19 deletions

View File

@ -481,7 +481,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
{
grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d;
long value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, icount;
@ -493,15 +493,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

@ -443,7 +443,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
{
grib_dumper_bufr_simple* self = (grib_dumper_bufr_simple*)d;
long value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, icount;
@ -455,15 +455,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

@ -139,18 +139,18 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_default* self = (grib_dumper_default*)d;
long value = 0;
size_t size = 1;
size_t size = 1, size2 = 0;
long* values = NULL;
int err = 0;
int i;
long count = 0;
grib_value_count(a, &count);
size = count;
if ((a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0)
return;
grib_value_count(a, &count);
size = size2 = count;
print_offset(self->dumper.out, d, a);
if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) {
@ -160,11 +160,12 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
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);
aliases(d, a);
if (comment) {

View File

@ -18,7 +18,8 @@ int grib_expression_native_type(grib_handle* h, grib_expression* g)
return c->native_type(g, h);
c = c->super ? *(c->super) : NULL;
}
grib_context_log(h->context, GRIB_LOG_ERROR, "No native_type() in %s\n", g->cclass->name);
if (g->cclass)
grib_context_log(h->context, GRIB_LOG_ERROR, "No native_type() in %s\n", g->cclass->name);
Assert(1 == 0);
return 0;
}
@ -53,7 +54,8 @@ const char* grib_expression_evaluate_string(grib_handle* h, grib_expression* g,
return c->evaluate_string(g, h, buf, size, err);
c = c->super ? *(c->super) : NULL;
}
grib_context_log(h->context, GRIB_LOG_ERROR, "No evaluate_string() in %s\n", g->cclass->name);
if (g->cclass)
grib_context_log(h->context, GRIB_LOG_ERROR, "No evaluate_string() in %s\n", g->cclass->name);
*err = GRIB_INVALID_TYPE;
return 0;

View File

@ -75,7 +75,7 @@ int grib_tool_init(grib_runtime_options* options)
if (options->latlon) {
lat = strtod(options->latlon, &theEnd);
if (*theEnd != ',') {
printf("ERROR: wrong latitude value\n");
fprintf(stderr, "Error %s: wrong latitude value. Please use 'latitude,longitude'\n",grib_tool_name);
exit(1);
}
lon = strtod(++theEnd, &end1);
@ -95,11 +95,12 @@ int grib_tool_init(grib_runtime_options* options)
options->latlon_mode = 1;
}
else {
printf("ERROR %s: wrong mode given in option -l\n", grib_tool_name);
fprintf(stderr, "Error %s: wrong mode given in option -l\n", grib_tool_name);
exit(1);
}
}
if (*p == ',') {
Assert(p);
if (p && *p == ',') {
p++;
options->latlon_mask = strdup(p);
}