Clang static analyser warnings

This commit is contained in:
Shahram Najm 2020-02-14 12:13:30 +00:00
parent 65c337cf69
commit 88f82ec0d6
8 changed files with 12 additions and 13 deletions

View File

@ -118,7 +118,7 @@ static int notify_change(grib_action* act, grib_accessor* notified,
la = grib_action_reparse(act, notified, &doit);
old_section = notified->sub_section;
Assert(old_section);
if (!old_section) return GRIB_INTERNAL_ERROR;
Assert(old_section->h == h);

View File

@ -266,6 +266,7 @@ int grib_g1_step_get_steps(grib_accessor* a, long* start, long* theEnd)
/* TODO move to the def file */
err = grib_get_long(hand, "timeRangeIndicatorFromStepRange", &timeRangeIndicatorFromStepRange);
if (err) return err;
if (timeRangeIndicatorFromStepRange == 10)
timeRangeIndicator = timeRangeIndicatorFromStepRange;

View File

@ -313,7 +313,6 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
sval = dval_to_string(c, values[i]);
fprintf(self->dumper.out, "rvalues[%d]=%s;", i, sval);
@ -417,7 +416,6 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
fprintf(self->dumper.out, "ivalues[%d]=%ld;", i, values[i]);

View File

@ -283,7 +283,6 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
fprintf(self->dumper.out, "%.18e", values[i]);
@ -384,7 +383,6 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
fprintf(self->dumper.out, "%ld ", values[i]);
@ -465,7 +463,6 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
fprintf(self->dumper.out, "%ld ", values[i]);
depth -= 2;

View File

@ -215,7 +215,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
sval = dval_to_string(c, values[i]);
fprintf(self->dumper.out, "%s", sval);
@ -520,7 +519,6 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, " \n ");
icount = 0;
}
fprintf(self->dumper.out, "%ld ", values[i]);

View File

@ -199,7 +199,6 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
}
if (icount > cols || i == 0) {
fprintf(self->dumper.out, "\n ");
icount = 0;
}
fprintf(self->dumper.out, "%g", values[i]);

View File

@ -130,7 +130,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_json* self = (grib_dumper_json*)d;
double value = 0;
size_t size = 1;
size_t size = 1, size2 = 0;
double* values = NULL;
int err = 0;
int i;
@ -145,14 +145,17 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
h = grib_handle_of_accessor(a);
grib_value_count(a, &count);
size = count;
size2 = size;
if (size > 1) {
values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size);
err = grib_unpack_double(a, values, &size);
err = grib_unpack_double(a, values, &size2);
}
else {
err = grib_unpack_double(a, &value, &size);
err = grib_unpack_double(a, &value, &size2);
}
Assert(size == size2);
(void)err; /* TODO */
if (self->begin == 0 && self->empty == 0 && self->isAttribute == 0)
fprintf(self->dumper.out, ",");

View File

@ -2627,7 +2627,10 @@ static void scale(double* vals, long n, void* data, dataset_t* g)
grib_context_log(ctx,GRIB_LOG_DEBUG,"No scale required");
return;
}
*/
*/
DebugAssert(vals);
DebugAssert(n>0);
if(!vals) return;
switch (nctype) {
case NC_BYTE: {