Commit e1ea901c authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Change iegCopyRecord to not propagate errors.

Fail early instead.
parent cefadde1
......@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
......@@ -524,35 +525,29 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
int iegCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
void iegCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
int fileID1, fileID2;
int tsID, recID, vrecID;
long recsize;
off_t recpos;
int status = 0;
char *buffer;
int fileID1 = streamptr1->fileID;
int fileID2 = streamptr2->fileID;
fileID1 = streamptr1->fileID;
fileID2 = streamptr2->fileID;
int tsID = streamptr1->curTsID;
int vrecID = streamptr1->tsteps[tsID].curRecID;
int recID = streamptr1->tsteps[tsID].recIDs[vrecID];
off_t recpos = streamptr1->tsteps[tsID].records[recID].position;
size_t recsize = streamptr1->tsteps[tsID].records[recID].size;
tsID = streamptr1->curTsID;
vrecID = streamptr1->tsteps[tsID].curRecID;
recID = streamptr1->tsteps[tsID].recIDs[vrecID];
recpos = streamptr1->tsteps[tsID].records[recID].position;
recsize = streamptr1->tsteps[tsID].records[recID].size;
if (fileSetPos(fileID1, recpos, SEEK_SET) != 0)
Error("Cannot seek input file for IEG record copy!");
fileSetPos(fileID1, recpos, SEEK_SET);
char *buffer = xmalloc(recsize);
buffer = (char *) malloc(recsize);
if (fileRead(fileID1, buffer, recsize) != recsize)
Error("Failed to read record from IEG file for copying!");
fileRead(fileID1, buffer, recsize);
fileWrite(fileID2, buffer, recsize);
if (fileWrite(fileID2, buffer, recsize) != recsize)
Error("Failed to write record to IEG file when copying!");
return (status);
......@@ -10,7 +10,7 @@ int iegInqTimestep(stream_t *streamptr, int tsID);
int iegInqRecord(stream_t *streamptr, int *varID, int *levelID);
void iegDefRecord(stream_t *streamptr);
int iegCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
void iegCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
void iegReadRecord(stream_t *streamptr, double *data, int *nmiss);
void iegWriteRecord(stream_t *streamptr, const double *data);
......@@ -458,11 +458,8 @@ void streamCopyRecord(int streamID2, int streamID1)
#if defined (HAVE_LIBIEG)
/* FIXME: return value not inspected */
status = iegCopyRecord(streamptr2, streamptr1);
iegCopyRecord(streamptr2, streamptr1);
#if defined (HAVE_LIBNETCDF)
Supports Markdown
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