Compiler warnings

This commit is contained in:
shahramn 2024-09-05 16:49:41 +01:00
parent 23651d524f
commit 845a461665
3 changed files with 15 additions and 23 deletions

View File

@ -810,14 +810,14 @@ void grib_context_reset(grib_context* c)
if (c->grib_definition_files_dir) { if (c->grib_definition_files_dir) {
grib_string_list* next = c->grib_definition_files_dir; grib_string_list* next = c->grib_definition_files_dir;
grib_string_list* cur = NULL; grib_string_list* cur = NULL;
while (next) { while (next) {
cur = next; cur = next;
next = next->next; next = next->next;
grib_context_free(c, cur->value); grib_context_free(c, cur->value);
grib_context_free(c, cur); grib_context_free(c, cur);
} }
c->grib_definition_files_dir=0; c->grib_definition_files_dir = 0;
} }
if (c->multi_support_on) if (c->multi_support_on)

View File

@ -113,14 +113,12 @@ static int grib_fieldset_new_column(grib_fieldset* set, int id, char* key, int t
static void grib_fieldset_delete_columns(grib_fieldset* set) static void grib_fieldset_delete_columns(grib_fieldset* set)
{ {
int i = 0;
grib_context* c;
if (!set) if (!set)
return; return;
c = set->context;
for (i = 0; i < set->columns_size; i++) { const grib_context* c = set->context;
for (size_t i = 0; i < set->columns_size; i++) {
int j = 0; int j = 0;
switch (set->columns[i].type) { switch (set->columns[i].type) {
case GRIB_TYPE_LONG: case GRIB_TYPE_LONG:
@ -146,22 +144,19 @@ static void grib_fieldset_delete_columns(grib_fieldset* set)
static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize) static int grib_fieldset_columns_resize(grib_fieldset* set, size_t newsize)
{ {
double* newdoubles;
long* newlongs;
char** newstrings;
int* newerrors;
int i = 0;
grib_context* c;
if (!set || !set->columns) if (!set || !set->columns)
return GRIB_INVALID_ARGUMENT; return GRIB_INVALID_ARGUMENT;
c = set->context; double* newdoubles = NULL;
long* newlongs = NULL;
char** newstrings = NULL;
int* newerrors = NULL;
const grib_context* c = set->context;
if (newsize <= set->columns[0].values_array_size) if (newsize <= set->columns[0].values_array_size)
return 0; return 0;
for (i = 0; i < set->columns_size; i++) { for (size_t i = 0; i < set->columns_size; i++) {
switch (set->columns[i].type) { switch (set->columns[i].type) {
case GRIB_TYPE_LONG: case GRIB_TYPE_LONG:
newlongs = (long*)grib_context_realloc(c, set->columns[i].long_values, newlongs = (long*)grib_context_realloc(c, set->columns[i].long_values,
@ -818,12 +813,9 @@ static int grib_fieldset_resize_int_array(grib_int_array* a, size_t newsize)
static void grib_fieldset_delete_int_array(grib_int_array* f) static void grib_fieldset_delete_int_array(grib_int_array* f)
{ {
grib_context* c = NULL; if (!f) return;
if (!f)
return;
c = f->context;
const grib_context* c = f->context;
grib_context_free(c, f->el); grib_context_free(c, f->el);
grib_context_free(c, f); grib_context_free(c, f);
} }

View File

@ -287,8 +287,8 @@ void grib_file_pool_delete_file(grib_file* file)
void grib_file_close(const char* filename, int force, int* err) void grib_file_close(const char* filename, int force, int* err)
{ {
grib_file* file = NULL; grib_file* file = NULL;
grib_context* context = grib_context_get_default(); const grib_context* context = grib_context_get_default();
/* Performance: keep the files open to avoid opening and closing files when writing the output. */ /* Performance: keep the files open to avoid opening and closing files when writing the output. */
/* So only call fclose() when too many files are open. */ /* So only call fclose() when too many files are open. */