Commit e2f7af53 authored by Oliver Heidmann's avatar Oliver Heidmann
Browse files

added explicit casts in several files

parent 99c1347f
...@@ -73,7 +73,7 @@ CdiInputFile* cdiInputFile_make(const char* path) ...@@ -73,7 +73,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
} }
else else
{ {
result = xmalloc(sizeof(*result)); result = (CdiInputFile *)xmalloc(sizeof(*result));
if(!cdiInputFile_condestruct(result, path)) if(!cdiInputFile_condestruct(result, path))
{ {
//An error occured during construction, avoid a memory leak. //An error occured during construction, avoid a memory leak.
...@@ -87,7 +87,7 @@ CdiInputFile* cdiInputFile_make(const char* path) ...@@ -87,7 +87,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
{ {
openFileListSize *= 2; openFileListSize *= 2;
if(openFileListSize < 16) openFileListSize = 16; if(openFileListSize < 16) openFileListSize = 16;
openFileList = xrealloc(openFileList, openFileListSize); openFileList = (CdiInputFile **)xrealloc(openFileList, openFileListSize);
} }
xassert(openFileCount < openFileListSize); xassert(openFileCount < openFileListSize);
openFileList[openFileCount++] = result; openFileList[openFileCount++] = result;
...@@ -101,7 +101,7 @@ CdiInputFile* cdiInputFile_make(const char* path) ...@@ -101,7 +101,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer) int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer)
{ {
char* byteBuffer = buffer; char* byteBuffer = (char *)buffer;
size_t trash; size_t trash;
if(!outActualReadSize) outActualReadSize = &trash; if(!outActualReadSize) outActualReadSize = &trash;
*outActualReadSize = 0; *outActualReadSize = 0;
......
...@@ -301,7 +301,7 @@ char* cdiIterator_serialize(CdiIterator* me) ...@@ -301,7 +301,7 @@ char* cdiIterator_serialize(CdiIterator* me)
const char *ftypeStr = fileType2String(me->filetype), const char *ftypeStr = fileType2String(me->filetype),
*advStr = me->isAdvanced ? kAdvancedString : kUnadvancedString; *advStr = me->isAdvanced ? kAdvancedString : kUnadvancedString;
char* result = xmalloc(strlen(ftypeStr) + 1 + strlen(advStr) + 1 char* result = (char *)xmalloc(strlen(ftypeStr) + 1 + strlen(advStr) + 1
+ strlen(subclassDescription) + 1); + strlen(subclassDescription) + 1);
sprintf(result, "%s %s %s", ftypeStr, advStr, subclassDescription); sprintf(result, "%s %s %s", ftypeStr, advStr, subclassDescription);
free(subclassDescription); free(subclassDescription);
......
...@@ -14,7 +14,7 @@ static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator* ...@@ -14,7 +14,7 @@ static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator*
{ {
if(me) goto destruct; if(me) goto destruct;
me = xmalloc(sizeof(*me)); me = (CdiFallbackIterator *)xmalloc(sizeof(*me));
baseIterConstruct(&me->super, filetype); baseIterConstruct(&me->super, filetype);
me->streamId = streamOpenRead(path); me->streamId = streamOpenRead(path);
...@@ -90,7 +90,7 @@ char* cdiFallbackIterator_serialize(CdiIterator* super) ...@@ -90,7 +90,7 @@ char* cdiFallbackIterator_serialize(CdiIterator* super)
CdiFallbackIterator* me = (CdiFallbackIterator*)super; CdiFallbackIterator* me = (CdiFallbackIterator*)super;
char* escapedPath = cdiEscapeSpaces(me->path); char* escapedPath = cdiEscapeSpaces(me->path);
char* result = xmalloc(strlen(escapedPath) char* result = (char *)xmalloc(strlen(escapedPath)
+ 5 * (3 * sizeof (int) * CHAR_BIT / 8 + 1) + 1); + 5 * (3 * sizeof (int) * CHAR_BIT / 8 + 1) + 1);
sprintf(result, "%s %d %d %d %d %d", escapedPath, me->variableCount, me->curVariable, me->curLevelCount, me->curLevel, me->curTimestep); sprintf(result, "%s %d %d %d %d %d", escapedPath, me->variableCount, me->curVariable, me->curLevelCount, me->curLevel, me->curTimestep);
free(escapedPath); free(escapedPath);
...@@ -99,7 +99,7 @@ char* cdiFallbackIterator_serialize(CdiIterator* super) ...@@ -99,7 +99,7 @@ char* cdiFallbackIterator_serialize(CdiIterator* super)
CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description) CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
{ {
CdiFallbackIterator* me = xmalloc(sizeof(*me)); CdiFallbackIterator* me = (CdiFallbackIterator *)xmalloc(sizeof(*me));
if(!me) goto fail; if(!me) goto fail;
description = baseIter_constructFromString(&me->super, description); description = baseIter_constructFromString(&me->super, description);
...@@ -186,7 +186,7 @@ char* cdiFallbackIterator_inqTime(CdiIterator* super, bool getEndTime) ...@@ -186,7 +186,7 @@ char* cdiFallbackIterator_inqTime(CdiIterator* super, bool getEndTime)
int year, month, day, hour, minute, second; int year, month, day, hour, minute, second;
cdiDecodeDate(date, &year, &month, &day); cdiDecodeDate(date, &year, &month, &day);
cdiDecodeTime(time, &hour, &minute, &second); cdiDecodeTime(time, &hour, &minute, &second);
char *result = xmalloc( 4+1 +2+1 +2+1 +2+1 +2+1 +2+4+1); char *result = (char *)xmalloc( 4+1 +2+1 +2+1 +2+1 +2+1 +2+4+1);
sprintf(result, "%04d-%02d-%02dT%02d:%02d:%02d.000", year, month, day, hour, minute, second); sprintf(result, "%04d-%02d-%02dT%02d:%02d:%02d.000", year, month, day, hour, minute, second);
return result; return result;
} }
......
...@@ -918,7 +918,7 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted) ...@@ -918,7 +918,7 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted)
{ {
fileClose(fileID); fileClose(fileID);
if (recordBufIsToBeDeleted) if (recordBufIsToBeDeleted)
srvDelete(streamptr->record->exsep); srvDelete((srvrec_t *)streamptr->record->exsep);
break; break;
} }
#endif #endif
...@@ -936,7 +936,7 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted) ...@@ -936,7 +936,7 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted)
{ {
fileClose(fileID); fileClose(fileID);
if (recordBufIsToBeDeleted) if (recordBufIsToBeDeleted)
iegDelete(streamptr->record->exsep); iegDelete((iegrec_t *)streamptr->record->exsep);
break; break;
} }
#endif #endif
...@@ -1366,7 +1366,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi ...@@ -1366,7 +1366,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
case FILETYPE_GRB2: case FILETYPE_GRB2:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("grbReadVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("grbReadVar not implemented for memtype float!");
grbReadVarDP(streamptr, varID, data, nmiss); grbReadVarDP(streamptr, varID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1374,7 +1374,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi ...@@ -1374,7 +1374,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
case FILETYPE_SRV: case FILETYPE_SRV:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("srvReadVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("srvReadVar not implemented for memtype float!");
srvReadVarDP(streamptr, varID, data, nmiss); srvReadVarDP(streamptr, varID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1382,7 +1382,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi ...@@ -1382,7 +1382,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
case FILETYPE_EXT: case FILETYPE_EXT:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("extReadVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("extReadVar not implemented for memtype float!");
extReadVarDP(streamptr, varID, data, nmiss); extReadVarDP(streamptr, varID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1390,7 +1390,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi ...@@ -1390,7 +1390,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
case FILETYPE_IEG: case FILETYPE_IEG:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("iegReadVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("iegReadVar not implemented for memtype float!");
iegReadVarDP(streamptr, varID, data, nmiss); iegReadVarDP(streamptr, varID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1401,9 +1401,9 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi ...@@ -1401,9 +1401,9 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
case FILETYPE_NC4C: case FILETYPE_NC4C:
{ {
if ( memtype == MEMTYPE_FLOAT ) if ( memtype == MEMTYPE_FLOAT )
cdfReadVarSP(streamptr, varID, data, nmiss); cdfReadVarSP(streamptr, varID, (float *)data, nmiss);
else else
cdfReadVarDP(streamptr, varID, data, nmiss); cdfReadVarDP(streamptr, varID, (double *)data, nmiss);
break; break;
} }
...@@ -1492,7 +1492,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data, ...@@ -1492,7 +1492,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
case FILETYPE_SRV: case FILETYPE_SRV:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVar not implemented for memtype float!");
srvWriteVarDP(streamptr, varID, data); srvWriteVarDP(streamptr, varID, (double *)data);
break; break;
} }
#endif #endif
...@@ -1500,7 +1500,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data, ...@@ -1500,7 +1500,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
case FILETYPE_EXT: case FILETYPE_EXT:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVar not implemented for memtype float!");
extWriteVarDP(streamptr, varID, data); extWriteVarDP(streamptr, varID, (double *)data);
break; break;
} }
#endif #endif
...@@ -1508,7 +1508,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data, ...@@ -1508,7 +1508,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
case FILETYPE_IEG: case FILETYPE_IEG:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVar not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVar not implemented for memtype float!");
iegWriteVarDP(streamptr, varID, data); iegWriteVarDP(streamptr, varID, (double *)data);
break; break;
} }
#endif #endif
...@@ -1519,7 +1519,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data, ...@@ -1519,7 +1519,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
case FILETYPE_NC4C: case FILETYPE_NC4C:
{ {
if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr); if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
cdf_write_var(streamptr, varID, memtype, data, nmiss); cdf_write_var(streamptr, varID, memtype, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1609,7 +1609,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi ...@@ -1609,7 +1609,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
case FILETYPE_GRB2: case FILETYPE_GRB2:
{ {
if ( memtype == MEMTYPE_FLOAT ) return 1; if ( memtype == MEMTYPE_FLOAT ) return 1;
grbReadVarSliceDP(streamptr, varID, levelID, data, nmiss); grbReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1617,7 +1617,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi ...@@ -1617,7 +1617,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
case FILETYPE_SRV: case FILETYPE_SRV:
{ {
if ( memtype == MEMTYPE_FLOAT ) return 1; if ( memtype == MEMTYPE_FLOAT ) return 1;
srvReadVarSliceDP(streamptr, varID, levelID, data, nmiss); srvReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1625,7 +1625,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi ...@@ -1625,7 +1625,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
case FILETYPE_EXT: case FILETYPE_EXT:
{ {
if ( memtype == MEMTYPE_FLOAT ) return 1; if ( memtype == MEMTYPE_FLOAT ) return 1;
extReadVarSliceDP(streamptr, varID, levelID, data, nmiss); extReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1633,7 +1633,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi ...@@ -1633,7 +1633,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
case FILETYPE_IEG: case FILETYPE_IEG:
{ {
if ( memtype == MEMTYPE_FLOAT ) return 1; if ( memtype == MEMTYPE_FLOAT ) return 1;
iegReadVarSliceDP(streamptr, varID, levelID, data, nmiss); iegReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1644,9 +1644,9 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi ...@@ -1644,9 +1644,9 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
case FILETYPE_NC4C: case FILETYPE_NC4C:
{ {
if ( memtype == MEMTYPE_FLOAT ) if ( memtype == MEMTYPE_FLOAT )
cdfReadVarSliceSP(streamptr, varID, levelID, data, nmiss); cdfReadVarSliceSP(streamptr, varID, levelID, (float *)data, nmiss);
else else
cdfReadVarSliceDP(streamptr, varID, levelID, data, nmiss); cdfReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
break; break;
} }
#endif #endif
...@@ -1714,7 +1714,7 @@ void streamReadVarSliceF(int streamID, int varID, int levelID, float *data, int ...@@ -1714,7 +1714,7 @@ void streamReadVarSliceF(int streamID, int varID, int levelID, float *data, int
// In case the file format does not support single precision reading, // In case the file format does not support single precision reading,
// we fall back to double precision reading, converting the data on the fly. // we fall back to double precision reading, converting the data on the fly.
size_t elementCount = (size_t)gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID)); size_t elementCount = (size_t)gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
double* conversionBuffer = malloc(elementCount * sizeof(*conversionBuffer)); double* conversionBuffer = (double *)malloc(elementCount * sizeof(*conversionBuffer));
streamReadVarSlice(streamID, varID, levelID, conversionBuffer, nmiss); streamReadVarSlice(streamID, varID, levelID, conversionBuffer, nmiss);
for (size_t i = elementCount; i--; ) data[i] = (float)conversionBuffer[i]; for (size_t i = elementCount; i--; ) data[i] = (float)conversionBuffer[i];
free(conversionBuffer); free(conversionBuffer);
...@@ -1753,7 +1753,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c ...@@ -1753,7 +1753,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
case FILETYPE_SRV: case FILETYPE_SRV:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVarSlice not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVarSlice not implemented for memtype float!");
srvWriteVarSliceDP(streamptr, varID, levelID, data); srvWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break; break;
} }
#endif #endif
...@@ -1761,7 +1761,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c ...@@ -1761,7 +1761,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
case FILETYPE_EXT: case FILETYPE_EXT:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVarSlice not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVarSlice not implemented for memtype float!");
extWriteVarSliceDP(streamptr, varID, levelID, data); extWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break; break;
} }
#endif #endif
...@@ -1769,7 +1769,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c ...@@ -1769,7 +1769,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
case FILETYPE_IEG: case FILETYPE_IEG:
{ {
if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVarSlice not implemented for memtype float!"); if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVarSlice not implemented for memtype float!");
iegWriteVarSliceDP(streamptr, varID, levelID, data); iegWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
break; break;
} }
#endif #endif
...@@ -2135,7 +2135,7 @@ int streamInqFileID(int streamID) ...@@ -2135,7 +2135,7 @@ int streamInqFileID(int streamID)
void cdiDefAccesstype(int streamID, int type) void cdiDefAccesstype(int streamID, int type)
{ {
stream_t *streamptr = reshGetVal(streamID, &streamOps); stream_t *streamptr = (stream_t *)reshGetVal(streamID, &streamOps);
if ( streamptr->accesstype == CDI_UNDEFID ) if ( streamptr->accesstype == CDI_UNDEFID )
{ {
...@@ -2206,14 +2206,14 @@ void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig) ...@@ -2206,14 +2206,14 @@ void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
} }
void cdiStreamGetIndexList(unsigned numIDs, int IDs[numIDs]) void cdiStreamGetIndexList(unsigned numIDs, int *IDs)
{ {
reshGetResHListOfType(numIDs, IDs, &streamOps); reshGetResHListOfType(numIDs, IDs, &streamOps);
} }
int streamInqNvars ( int streamID ) int streamInqNvars ( int streamID )
{ {
stream_t *streamptr = reshGetVal(streamID, &streamOps); stream_t *streamptr = (stream_t *)reshGetVal(streamID, &streamOps);
return streamptr->nvars; return streamptr->nvars;
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
void swap4byte(void *ptr, size_t size) void swap4byte(void *ptr, size_t size)
{ {
int32_t *ptrtmp = ptr; int32_t *ptrtmp = (int32_t *)ptr;
if (sizeof (int32_t) == 4) if (sizeof (int32_t) == 4)
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
...@@ -22,7 +22,7 @@ void swap4byte(void *ptr, size_t size) ...@@ -22,7 +22,7 @@ void swap4byte(void *ptr, size_t size)
void swap8byte(void *ptr, size_t size) void swap8byte(void *ptr, size_t size)
{ {
int64_t *ptrtmp = ptr; int64_t *ptrtmp = (int64_t *)ptr;
if (sizeof (int64_t) == 8) if (sizeof (int64_t) == 8)
for (size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i)
......
...@@ -1657,7 +1657,7 @@ zaxisPack(void * voidP, void * packBuffer, int packBufferSize, ...@@ -1657,7 +1657,7 @@ zaxisPack(void * voidP, void * packBuffer, int packBufferSize,
} }
void cdiZaxisGetIndexList(unsigned nzaxis, int zaxisResHs[nzaxis]) void cdiZaxisGetIndexList(unsigned nzaxis, int *zaxisResHs)
{ {
reshGetResHListOfType(nzaxis, zaxisResHs, &zaxisOps); reshGetResHListOfType(nzaxis, zaxisResHs, &zaxisOps);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment