Clean up Coverity warnings from last checkin.

This commit is contained in:
Quincey Koziol 2014-02-20 08:24:55 -06:00
parent b98a475f37
commit d033f9f6ff
5 changed files with 27 additions and 15 deletions

View File

@ -369,6 +369,9 @@ by the desired type. */
#define NC_EDAPCONSTRAINT (-75) /**< Malformed DAP Constraint*/
#define NC_ETRANSLATION (-76) /**< Untranslatable construct */
/* Misc. additional errors */
#define NC_ECANTREMOVE (-77) /**< Can't remove file */
/* The following was added in support of netcdf-4. Make all netcdf-4
error codes < -100 so that errors can be added to netcdf-3 if
needed. */

View File

@ -659,19 +659,15 @@ static NClist*
clonedimset3(NCDAPCOMMON* nccomm, NClist* dimset, CDFnode* var)
{
NClist* result = NULL;
int i;
if(dimset != NULL) {
for(i=0;i<nclistlength(dimset);i++) {
CDFnode *dim = NULL;
if(result == NULL)
result = nclistnew();
int i;
dim = (CDFnode*)nclistget(dimset,i);
nclistpush(result,(void*)clonedim(nccomm,dim,var));
}
for(i=0;i<nclistlength(dimset);i++) {
CDFnode *dim = NULL;
if(result == NULL)
result = nclistnew();
dim = (CDFnode*)nclistget(dimset,i);
nclistpush(result,(void*)clonedim(nccomm,dim,var));
}
return result;
}

View File

@ -1970,6 +1970,9 @@ nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
assert(grp && grp->name);
LOG((3, "%s: grp->name %s", __func__, grp->name));
/* Portably initialize user data for later */
memset(&udata, 0, sizeof(udata));
/* Open this HDF5 group and retain its grpid. It will remain open
* with HDF5 until this file is nc_closed. */
if (!grp->hdf_grpid)
@ -2009,8 +2012,7 @@ nc4_rec_read_metadata(NC_GRP_INFO_T *grp)
iter_index = H5_INDEX_NAME;
}
/* Portably initialize user data for iteration */
memset(&udata, 0, sizeof(udata));
/* Set user data for iteration */
udata.grp = grp;
/* Iterate over links in this group, building lists for the types,
@ -2981,7 +2983,8 @@ NC4_abort(int ncid)
/* Delete the file, if we should. */
if (delete_file)
remove(path);
if (remove(path) < 0)
return NC_ECANTREMOVE;
return retval;
}

View File

@ -746,7 +746,10 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
return NC_ENOMEM;
if (*(char **)var->fill_value)
if (!(*(char **)fill_valuep = strdup(*(char **)var->fill_value)))
{
free(fill_valuep);
return NC_ENOMEM;
}
}
else {
assert(var->type_info->size);
@ -760,7 +763,10 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
if (!(fill_valuep = calloc(1, sizeof(char *))))
return NC_ENOMEM;
if ((retval = nc4_get_default_fill_value(var->type_info, (char **)fill_valuep)))
{
free(fill_valuep);
return retval;
}
}
else
{

View File

@ -725,6 +725,10 @@ ocmktmp(const char* base, char** tmpnamep, int* fdp)
# endif
}
#endif /* !HAVE_MKSTEMP */
if(fd < 0) {
free(tmpname);
return OC_EOPEN;
}
if(tmpnamep) *tmpnamep = tmpname;
else free(tmpname);
if(fdp) *fdp = fd;