From e7fae04170c3431f1fda3a7f1f728c31cfd4540e Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Wed, 15 Jan 2025 11:45:38 +0100
Subject: [PATCH] Renamed cdfCopyRecord() to cdfCopyField()

---
 src/stream.c        | 15 ++++++++-------
 src/stream_cdf.h    |  2 +-
 src/stream_cdf_o.c  | 12 ++++++------
 src/stream_record.c |  9 ++++++---
 4 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/src/stream.c b/src/stream.c
index 0498fcac7..dfd969ae7 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -796,7 +796,7 @@ streamOpenA(const char *filename, const char *filemode, int filetype)
   if (str_is_equal(filemode, "r")) cdiVlistMakeImmutable(streamptr->vlistID);
 
   {
-    void (*streamCloseDelegate)(stream_t * streamptr, int recordBufIsToBeDeleted)
+    void (*streamCloseDelegate)(stream_t *streamptr, int recordBufIsToBeDeleted)
         = (void (*)(stream_t *, int)) namespaceSwitchGet(NSSWITCH_STREAM_CLOSE_BACKEND).func;
 
     streamCloseDelegate(streamptr, 0);
@@ -1342,7 +1342,7 @@ streamDestroyViaDelegate(stream_t *streamptr, void (*streamCloseDelegate)(stream
 static void
 streamDestroy(stream_t *streamptr)
 {
-  void (*streamCloseDelegate)(stream_t * streamptr, int recordBufIsToBeDeleted)
+  void (*streamCloseDelegate)(stream_t *streamptr, int recordBufIsToBeDeleted)
       = (void (*)(stream_t *, int)) namespaceSwitchGet(NSSWITCH_STREAM_CLOSE_BACKEND).func;
 
   streamDestroyViaDelegate(streamptr, streamCloseDelegate);
@@ -1439,7 +1439,7 @@ streamSync(int streamID)
 {
   stream_t *streamptr = stream_to_pointer(streamID);
 
-  void (*myStreamSync_)(stream_t * streamptr) = (void (*)(stream_t *)) namespaceSwitchGet(NSSWITCH_STREAM_SYNC).func;
+  void (*myStreamSync_)(stream_t *streamptr) = (void (*)(stream_t *)) namespaceSwitchGet(NSSWITCH_STREAM_SYNC).func;
   myStreamSync_(streamptr);
 }
 
@@ -1473,7 +1473,7 @@ cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
       /* usually points to cdfDefTimestep in serial mode but
        * to cdiPioCdfDefTimestep on servers and to a null-op on
        * clients in client/server mode */
-      void (*myCdfDefTimestep)(stream_t * streamptr, int tsID, size_t)
+      void (*myCdfDefTimestep)(stream_t *streamptr, int tsID, size_t)
           = (void (*)(stream_t *, int, size_t)) namespaceSwitchGet(NSSWITCH_CDF_DEF_TIMESTEP).func;
       myCdfDefTimestep(streamptr, tsID, 1);
     }
@@ -1511,7 +1511,7 @@ streamDefTimestep(int streamID, int tsID)
 
   if (streamptr->lockIO) CDI_IO_LOCK();
 
-  int (*myStreamDefTimestep_)(stream_t * streamptr, int tsID)
+  int (*myStreamDefTimestep_)(stream_t *streamptr, int tsID)
       = (int (*)(stream_t *, int)) namespaceSwitchGet(NSSWITCH_STREAM_DEF_TIMESTEP_).func;
   int status = myStreamDefTimestep_(streamptr, tsID);
 
@@ -1792,7 +1792,7 @@ streamTxCode(void *s)
 void
 cdiStreamSetupVlist(stream_t *s, int vlistID)
 {
-  void (*myStreamSetupVlist)(stream_t * s, int vlistID)
+  void (*myStreamSetupVlist)(stream_t *s, int vlistID)
       = (void (*)(stream_t *, int)) namespaceSwitchGet(NSSWITCH_STREAM_SETUP_VLIST).func;
   myStreamSetupVlist(s, vlistID);
 }
@@ -1850,7 +1850,7 @@ cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
             /* calls cdfDefCoordinateVars in serial mode but
              * cdiPioClientStreamNOP (i.e. nothing) on client ranks
              * and cdiPioServerCdfDefVars on server ranks in parallel mode*/
-            void (*myCdfDefVars)(stream_t * streamptr) = (void (*)(stream_t *)) namespaceSwitchGet(NSSWITCH_CDF_STREAM_SETUP).func;
+            void (*myCdfDefVars)(stream_t *streamptr) = (void (*)(stream_t *)) namespaceSwitchGet(NSSWITCH_CDF_STREAM_SETUP).func;
             myCdfDefVars(streamptr);
           }
           break;
@@ -2024,6 +2024,7 @@ streamUnpack(char *unpackBuffer, int unpackBufferSize, int *unpackBufferPos, int
 void
 freePtrAfterNCMem(stream_t *streamptr, int recordBufIsToBeDeleted)
 {
+  (void) recordBufIsToBeDeleted;
   int fileID = streamptr->fileID;
 
   if (fileID == CDI_UNDEFID)
diff --git a/src/stream_cdf.h b/src/stream_cdf.h
index d4b379742..8d61ec280 100644
--- a/src/stream_cdf.h
+++ b/src/stream_cdf.h
@@ -32,7 +32,7 @@ int cdfInqContents(stream_t *streamptr);
 void cdfEndDef(stream_t *streamptr);
 void cdfDefField(stream_t *streamptr);
 
-void cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1);
+void cdfCopyField(stream_t *streamptr2, stream_t *streamptr1);
 
 void cdfDefineAttributes(int filetype, int vlistID, int varID, int fileID, int ncvarID);
 
diff --git a/src/stream_cdf_o.c b/src/stream_cdf_o.c
index 987fb0514..4be42ced0 100644
--- a/src/stream_cdf_o.c
+++ b/src/stream_cdf_o.c
@@ -18,7 +18,7 @@
 static const char bndsName[] = "bnds";
 
 void
-cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
+cdfCopyField(stream_t *streamptr2, stream_t *streamptr1)
 {
   int vlistID1 = streamptr1->vlistID;
   int tsID = streamptr1->curTsID;
@@ -121,7 +121,7 @@ cdfSearchIDBySize(size_t startIdx, size_t numIDs, const ncgrid_t ncgrid[/*numIDs
             }
         }
     }
-  return (struct idSearch){ .numNonMatching = numNonMatching, .foundID = foundID, .foundIdx = foundIdx };
+  return (struct idSearch) { .numNonMatching = numNonMatching, .foundID = foundID, .foundIdx = foundIdx };
 }
 
 static SizeType
@@ -522,7 +522,7 @@ cdfPostDefActionAddPutVal(struct cdfPostDefActionList **list_, int fileID, int n
   delayedPutVals->fileID = fileID;
   delayedPutVals->ncvarid = ncvarid;
   *list_ = cdfPostDefActionAdd(
-      *list_, (struct cdfPostDefAction){ .data = (void *) delayedPutVals, .action = cdfDelayedPutVarDouble, .cleanup = cleanup });
+      *list_, (struct cdfPostDefAction) { .data = (void *) delayedPutVals, .action = cdfDelayedPutVarDouble, .cleanup = cleanup });
 }
 
 static inline void
@@ -533,7 +533,7 @@ cdfPostDefActionAddPut1Int(struct cdfPostDefActionList **list_, int fileID, int
   delayedPutVals->fileID = fileID;
   delayedPutVals->ncvarid = ncvarid;
   *list_ = cdfPostDefActionAdd(
-      *list_, (struct cdfPostDefAction){ .data = (void *) delayedPutVals, .action = cdfDelayedPutVarInt1, .cleanup = cleanup });
+      *list_, (struct cdfPostDefAction) { .data = (void *) delayedPutVals, .action = cdfDelayedPutVarInt1, .cleanup = cleanup });
 }
 
 static void
@@ -930,7 +930,7 @@ cdfDefIrregularGridCommon(stream_t *streamptr, int gridID, size_t xsize, size_t
       streamptr->ncmode = 2;
     }
 
-  return (struct cdfDefIrregularGridCommonIDs){
+  return (struct cdfDefIrregularGridCommonIDs) {
     .xdimID = xdimID, .ydimID = ydimID, .ncxvarid = ncxvarid, .ncyvarid = ncyvarid, .ncavarid = ncavarid, .delayed = delayed
   };
 }
@@ -1560,7 +1560,7 @@ static struct cdfPostDefActionList *
 cdf_def_zaxis_hybrid(stream_t *streamptr, int type, int *ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID,
                      char *axisname)
 {
-  struct cdfPostDefActionList *(*def_zaxis_hybrid_delegate)(stream_t * streamptr, int type, int *ncvarid, int zaxisID,
+  struct cdfPostDefActionList *(*def_zaxis_hybrid_delegate)(stream_t *streamptr, int type, int *ncvarid, int zaxisID,
                                                             int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
       = ((!CDI_CMOR_Mode && CDI_Convention == CDI_CONVENTION_ECHAM) || type == ZAXIS_HYBRID_HALF) ? cdf_def_zaxis_hybrid_echam
                                                                                                   : cdf_def_zaxis_hybrid_cf;
diff --git a/src/stream_record.c b/src/stream_record.c
index 2e435eb77..5660b47a6 100644
--- a/src/stream_record.c
+++ b/src/stream_record.c
@@ -206,8 +206,11 @@ streamDefField(int streamID, int varID, int levelID)
 void
 streamCopyField(int streamID2, int streamID1)
 {
-  stream_t *streamptr1 = stream_to_pointer(streamID1), *streamptr2 = stream_to_pointer(streamID2);
-  int filetype1 = streamptr1->filetype, filetype2 = streamptr2->filetype, filetype = CDI_FILETYPE_UNDEF;
+  stream_t *streamptr1 = stream_to_pointer(streamID1);
+  stream_t *streamptr2 = stream_to_pointer(streamID2);
+  int filetype1 = streamptr1->filetype;
+  int filetype2 = streamptr2->filetype;
+  int filetype = CDI_FILETYPE_UNDEF;
 
   if (cdiBaseFiletype(filetype1) == cdiBaseFiletype(filetype2)) filetype = filetype2;
 
@@ -229,7 +232,7 @@ streamCopyField(int streamID2, int streamID1)
     case CDI_FILETYPE_IEG: iegCopyField(streamptr2, streamptr1); break;
 #endif
 #ifdef HAVE_LIBNETCDF
-    case CDI_FILETYPE_NETCDF: cdfCopyRecord(streamptr2, streamptr1); break;
+    case CDI_FILETYPE_NETCDF: cdfCopyField(streamptr2, streamptr1); break;
 #endif
     default: Error("%s support not compiled in!", strfiletype(filetype));
     }
-- 
GitLab