From cee1558838a5d8a6bcbc41bf619c33aafc690c22 Mon Sep 17 00:00:00 2001
From: Thomas Jahns <jahns@dkrz.de>
Date: Wed, 25 Mar 2015 12:42:12 +0000
Subject: [PATCH] Merge declarations and initializations in srv_add_record.

---
 src/stream_srv.c | 39 +++++++++++++++++----------------------
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/src/stream_srv.c b/src/stream_srv.c
index 6e2d2e2b1..da62efbd4 100644
--- a/src/stream_srv.c
+++ b/src/stream_srv.c
@@ -206,25 +206,17 @@ static
 void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ysize,
                     size_t recsize, off_t position, int prec)
 {
-  int leveltype;
-  int gridID = CDI_UNDEFID;
-  int levelID = 0;
-  int tsID, recID, varID;
-  int datatype;
-  record_t *record;
-  grid_t grid;
-  int vlistID;
+  int vlistID = streamptr->vlistID;
+  int tsID    = streamptr->curTsID;
+  int recID   = recordNewEntry(streamptr, tsID);
+  record_t *record = &streamptr->tsteps[tsID].records[recID];
 
-  vlistID = streamptr->vlistID;
-  tsID    = streamptr->curTsID;
-  recID   = recordNewEntry(streamptr, tsID);
-  record  = &streamptr->tsteps[tsID].records[recID];
-
-  (*record).size     = recsize;
-  (*record).position = position;
-  (*record).param    = param;
-  (*record).ilevel   = level;
+  record->size     = recsize;
+  record->position = position;
+  record->param    = param;
+  record->ilevel   = level;
 
+  grid_t grid;
   memset(&grid, 0, sizeof(grid_t));
   grid.type  = GRID_GENERIC;
   grid.size  = xsize*ysize;
@@ -232,21 +224,24 @@ void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ys
   grid.ysize = ysize;
   grid.xvals = NULL;
   grid.yvals = NULL;
-  gridID = varDefGrid(vlistID, &grid, 0);
+  int gridID = varDefGrid(vlistID, &grid, 0);
   /*
   if ( level == 0 ) leveltype = ZAXIS_SURFACE;
   else              leveltype = ZAXIS_GENERIC;
   */
-  leveltype = ZAXIS_GENERIC;
+  int leveltype = ZAXIS_GENERIC;
+
+  int datatype = srvInqDatatype(prec);
 
-  datatype = srvInqDatatype(prec);
+  int levelID = 0;
+  int varID;
 
   varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
 	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
 
   xassert(varID <= SHRT_MAX && levelID <= SHRT_MAX);
-  (*record).varID   = (short)varID;
-  (*record).levelID = (short)levelID;
+  record->varID   = (short)varID;
+  record->levelID = (short)levelID;
 
   streamptr->tsteps[tsID].nallrecs++;
   streamptr->nrecs++;
-- 
GitLab