Clang static analyser warnings

This commit is contained in:
Shahram Najm 2020-03-02 13:42:07 +00:00
parent d5f1febca2
commit 4cf02d70bd
2 changed files with 18 additions and 12 deletions

View File

@ -32,6 +32,9 @@ int compute_bufr_key_rank(grib_handle* h, grib_string_list* keys, const char* ke
next = prev->next; next = prev->next;
} }
} }
DebugAssert(next);
if (!next) return 0;
if (!next->value) { if (!next->value) {
next->value = strdup(key); next->value = strdup(key);
next->count = 0; next->count = 0;

View File

@ -250,20 +250,23 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
a->name, number_of_points); a->name, number_of_points);
if (latitude_of_first_point == 0) { if (latitude_of_first_point == 0) {
if (number_of_values && !coded_vals) for (i = 0; i < number_of_values; i++) {
return GRIB_INTERNAL_ERROR; DebugAssert(coded_vals);
for (i = 0; i < number_of_values; i++) if (coded_vals) val[i] = coded_vals[i];
val[i] = coded_vals[i]; }
for (i = number_of_values; i < number_of_points; i++) for (i = number_of_values; i < number_of_points; i++) {
val[i] = coded_vals[number_of_values - 1]; DebugAssert(coded_vals);
if (coded_vals) val[i] = coded_vals[number_of_values - 1];
}
} }
else { else {
if ((ni-1) && !coded_vals) for (i = 0; i < ni - 1; i++) {
return GRIB_INTERNAL_ERROR; DebugAssert(coded_vals);
for (i = 0; i < ni - 1; i++) if (coded_vals) val[i] = coded_vals[0];
val[i] = coded_vals[0]; }
for (i = ni - 1; i < number_of_points; i++) for (i = ni - 1; i < number_of_points; i++) {
val[i] = coded_vals[i - ni + 1]; if (coded_vals && (i - ni + 1) < number_of_values) val[i] = coded_vals[i - ni + 1];
}
} }
*len = number_of_points; *len = number_of_points;