Fix issues reported by cppcheck

This commit is contained in:
Shahram Najm 2014-10-07 16:29:15 +01:00
parent ea43cfe0e4
commit 62946c8ae0
4 changed files with 35 additions and 34 deletions

View File

@ -258,6 +258,7 @@ void grib_file_pool_delete_file(grib_file* file) {
if (prev->next==file) break;
prev=prev->next;
}
Assert(prev);
prev->next=file->next;
}

View File

@ -792,7 +792,7 @@ grib_handle* taf_new_from_file ( grib_context* c, FILE* f,int headers_only,int *
if ( !gl )
{
*error = GRIB_DECODING_ERROR;
grib_context_log ( gl->context, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
grib_context_log ( c, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
grib_context_free ( c,data );
return NULL;
}
@ -833,7 +833,7 @@ grib_handle* metar_new_from_file ( grib_context* c, FILE* f,int headers_only,int
if ( !gl )
{
*error = GRIB_DECODING_ERROR;
grib_context_log ( gl->context, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
grib_context_log ( c, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
grib_context_free ( c,data );
return NULL;
}
@ -873,7 +873,7 @@ grib_handle* codes_new_from_file ( grib_context* c, FILE* f,int headers_only,int
if ( !gl )
{
*error = GRIB_DECODING_ERROR;
grib_context_log ( gl->context, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
grib_context_log ( c, GRIB_LOG_ERROR, "grib_handle_new_from_file : cannot create handle \n" );
grib_context_free ( c,data );
return NULL;
}

View File

@ -36,12 +36,12 @@ grib_iarray* grib_iarray_new(grib_context* c,size_t size,size_t incsize) {
if (!c) c=grib_context_get_default();
v=(grib_iarray*)grib_context_malloc(c,sizeof(grib_iarray));
v->context=c;
if (!v) {
grib_context_log(c,GRIB_LOG_ERROR,
"grib_iarray_new unable to allocate %d bytes\n",sizeof(grib_iarray));
return NULL;
}
v->context=c;
v->size=size;
v->n=0;
v->incsize=incsize;

View File

@ -50,8 +50,8 @@ int grib_lookup_long_from_array(grib_context* gc,grib_loader* loader,const char*
}
break;
default:
return GRIB_NOT_FOUND;
printf("lookup: wrong type (%d)\n",type);
return GRIB_NOT_FOUND;
break;
}