Clang static analyser warnings

This commit is contained in:
Shahram Najm 2020-02-24 15:35:09 +00:00
parent 3ebc9baabc
commit 73b815bce7
14 changed files with 84 additions and 84 deletions

View File

@ -177,7 +177,7 @@ static int notify_change(grib_action* act, grib_accessor* notified,
if (err) {
if (err == GRIB_NOT_FOUND && strcmp(act->name, "dataValues") == 0) {
/* FIXME: Allow this error. Needed when changing some packingTypes e.g. CCSDS to Simple */
err = GRIB_SUCCESS;
/*err = GRIB_SUCCESS;*/
}
else {
return err;

View File

@ -330,6 +330,7 @@ static int select_datetime(grib_accessor* a)
ret = 0;
second[0] = 0;
n = 1;
(void)ret;
}
if (n != numberOfSubsets) {
if (n == 1) {

View File

@ -724,7 +724,6 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
mmax = 0;
maxv = pen_j + 1;
i = 0;
lcount = 0;
hcount = 0;
sub_k = sub_j;
@ -804,8 +803,6 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
mmax = 0;
maxv = pen_j + 1;
i = 0;
lcount = 0;
hcount = 0;
sub_k = sub_j;

View File

@ -402,10 +402,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
long number_of_data_points;
long nn = 0;
self->dirty = 1;
n_vals = 0;
err = grib_value_count(a, &nn);
n_vals = nn;
if (err)
@ -542,8 +540,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
buflen++;
}
}
/* buflen = n_vals*(bits_per_value/8);*/
/* buflen = n_vals*(bits_per_value/8); */
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_data_png_packing : pack_double : packing %s, %d values", a->name, n_vals);
buf = grib_context_buffer_malloc_clear(a->context, buflen);

View File

@ -240,7 +240,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
long n_vals = 0;
double* scals = NULL;
/* double *pscals=NULL; */
double dummy = 0;
double s = 0;
double d = 0;
@ -375,9 +374,8 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
lup = mmax;
if (sub_k >= 0) {
for (hcount = 0; hcount < sub_k + 1; hcount++) {
dummy = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes));
dummy = decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes));
(void)dummy;
decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes));
decode_float(grib_decode_unsigned_long(hres, &hpos, 8 * bytes));
lup++;
}
sub_k--;

View File

@ -371,6 +371,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
/* pscals=scals+lup; */
for (lcount = hcount; lcount < maxv; lcount++) {
dummy = d * (double)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value);
(void)dummy;
dummy = d * (double)((grib_decode_unsigned_long(lres, &lpos, bits_per_value) * s) + reference_value);
(void)dummy; /* suppress gcc warning */
lup++;

View File

@ -194,7 +194,6 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
grib_iterator* iter = NULL;
self->save = 1;
size = 0;
ret = value_count(a, &count);
if (ret)
return ret;

View File

@ -173,7 +173,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_bufr_encode_C* self = (grib_dumper_bufr_encode_C*)d;
double value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, r, icount;
@ -187,15 +187,16 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, 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(size2 == size);
self->empty = 0;
@ -280,8 +281,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
return;
grib_value_count(a, &count);
size = count;
size2 = size;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, sizeof(double) * size);
@ -290,7 +290,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
else {
err = grib_unpack_double(a, &value, &size2);
}
Assert(size == size2);
Assert(size2 == size);
self->empty = 0;
@ -349,7 +349,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
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, r, icount;
@ -365,7 +365,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0);
grib_value_count(a, &count);
size = count;
size = size2 = count;
if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf == 0) {
@ -391,11 +391,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);
self->empty = 0;

View File

@ -154,7 +154,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_bufr_encode_filter* self = (grib_dumper_bufr_encode_filter*)d;
double value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, r;
@ -167,15 +167,16 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, 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(size2 == size);
self->begin = 0;
self->empty = 0;
@ -256,8 +257,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
return;
grib_value_count(a, &count);
size = count;
size2 = size;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, sizeof(double) * size);
@ -266,7 +266,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
else {
err = grib_unpack_double(a, &value, &size2);
}
Assert(size == size2);
Assert(size2 == size);
self->empty = 0;
@ -316,7 +316,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_encode_filter* self = (grib_dumper_bufr_encode_filter*)d;
long value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, r, icount;
@ -329,7 +329,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf == 0) {
@ -355,11 +355,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);
self->begin = 0;
self->empty = 0;
@ -426,7 +427,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
{
grib_dumper_bufr_encode_filter* self = (grib_dumper_bufr_encode_filter*)d;
long value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, icount;
@ -438,15 +439,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

@ -221,7 +221,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d;
double value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, r, icount;
@ -235,15 +235,16 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, 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(size2 == size);
self->empty = 0;
@ -328,8 +329,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
return;
grib_value_count(a, &count);
size = count;
size2 = size;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, sizeof(double) * size);
@ -338,7 +338,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
else {
err = grib_unpack_double(a, &value, &size2);
}
Assert(size == size2);
Assert(size2 == size);
self->empty = 0;
@ -397,7 +397,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_bufr_encode_fortran* self = (grib_dumper_bufr_encode_fortran*)d;
long value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
long* values = NULL;
int err = 0;
int i, r, icount;
@ -413,7 +413,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0);
grib_value_count(a, &count);
size = count;
size = size2 = count;
if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf == 0) {
@ -439,11 +439,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);
self->empty = 0;
@ -540,8 +541,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
return;
grib_value_count(a, &count);
size = count;
size2 = size;
size = size2 = count;
if (size > 1) {
values = (long*)grib_context_malloc_clear(a->context, sizeof(long) * size);
@ -550,7 +550,7 @@ static void dump_long_attribute(grib_dumper* d, grib_accessor* a, const char* pr
else {
err = grib_unpack_long(a, &value, &size2);
}
Assert(size == size2);
Assert(size2 == size);
self->empty = 0;

View File

@ -173,7 +173,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_bufr_encode_python* self = (grib_dumper_bufr_encode_python*)d;
double value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, r, icount;
@ -187,15 +187,16 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, 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(size2 == size);
self->empty = 0;
@ -281,8 +282,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
return;
grib_value_count(a, &count);
size = count;
size2 = size;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, sizeof(double) * size);
@ -291,7 +291,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
else {
err = grib_unpack_double(a, &value, &size2);
}
Assert(size == size2);
Assert(size2 == size);
self->empty = 0;
@ -351,7 +351,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
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, r, icount;
@ -367,7 +367,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
doing_unexpandedDescriptors = (strcmp(a->name, "unexpandedDescriptors") == 0);
grib_value_count(a, &count);
size = count;
size = size2 = count;
if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf == 0) {
@ -393,11 +393,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);
self->empty = 0;

View File

@ -151,7 +151,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
{
grib_dumper_bufr_simple* self = (grib_dumper_bufr_simple*)d;
double value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, r;
@ -164,15 +164,16 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, 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(size2 == size);
self->empty = 0;
@ -241,7 +242,7 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
{
grib_dumper_bufr_simple* self = (grib_dumper_bufr_simple*)d;
double value = 0;
size_t size = 0;
size_t size = 0, size2 = 0;
double* values = NULL;
int err = 0;
int i, icount;
@ -253,15 +254,16 @@ static void dump_values_attribute(grib_dumper* d, grib_accessor* a, const char*
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(c, 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(size2 == size);
self->empty = 0;
@ -312,7 +314,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
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, r, icount;
@ -325,7 +327,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
return;
grib_value_count(a, &count);
size = count;
size = size2 = count;
if ((a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) != 0) {
if (self->isLeaf == 0) {
@ -360,11 +362,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);
self->empty = 0;

View File

@ -144,8 +144,7 @@ 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;
size = size2 = count;
if (size > 1) {
values = (double*)grib_context_malloc_clear(a->context, sizeof(double) * size);
@ -154,7 +153,7 @@ static void dump_values(grib_dumper* d, grib_accessor* a)
else {
err = grib_unpack_double(a, &value, &size2);
}
Assert(size == size2);
Assert(size2 == size);
(void)err; /* TODO */
if (self->begin == 0 && self->empty == 0 && self->isAttribute == 0)
@ -227,7 +226,7 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
{
grib_dumper_json* self = (grib_dumper_json*)d;
long value = 0;
size_t size = 1;
size_t size = 1, size2 = 0;
long* values = NULL;
int err = 0;
int i;
@ -238,15 +237,16 @@ static void dump_long(grib_dumper* d, grib_accessor* a, const char* comment)
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);
if (self->begin == 0 && self->empty == 0 && self->isAttribute == 0)
fprintf(self->dumper.out, ",");

View File

@ -1510,7 +1510,7 @@ static int grib2_has_next_section(unsigned char* msgbegin, size_t msglen, unsign
return 0;
}
secbegin += seclen;
/*secbegin += seclen;*/
return 1;
}