From 408517854f9ecb3e1ab3d76ad96649389f53fee5 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de>
Date: Tue, 18 Jun 2019 13:04:40 +0200
Subject: [PATCH 1/2] cleanup: reduce scope of variables, initialize `curr`
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This addresses the following warning from GCC 9:

    parallel/ddd/xfer/unpack.cc:410:11: warning:
    ‘curr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
---
 parallel/ddd/xfer/unpack.cc | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/parallel/ddd/xfer/unpack.cc b/parallel/ddd/xfer/unpack.cc
index b731be58f..886e77583 100644
--- a/parallel/ddd/xfer/unpack.cc
+++ b/parallel/ddd/xfer/unpack.cc
@@ -323,23 +323,18 @@ static void PutDepData (DDD::DDDContext& context,
                         const SYMTAB_ENTRY *theSymTab,
                         int newness)
 {
-  TYPE_DESC    *descDep;
-  char         *chunk, *curr, *adr, **table;
-  int i, j, chunks;
-  int addCnt;
-  DDD_TYPE addTyp;
-
-
   /* get overall number of chunks */
-  chunks = ((int *)data)[0];
-  chunk  = data + CEIL(sizeof(int));
+  const int chunks = ((int *)data)[0];
+  char* chunk = data + CEIL(sizeof(int));
+
+  char* curr = nullptr;
 
   /* loop through all chunks */
-  for(j=0; j<chunks; j++)
+  for(int j=0; j<chunks; j++)
   {
     /* first entries of chunk are addCnt and addTyp */
-    addCnt = ((int *)chunk)[0];
-    addTyp = ((DDD_TYPE *)chunk)[1];
+    int addCnt = ((int *)chunk)[0];
+    DDD_TYPE addTyp = ((DDD_TYPE *)chunk)[1];
     chunk += CEIL(sizeof(int)+sizeof(DDD_TYPE));
 
     if (addCnt>=0)
@@ -347,9 +342,9 @@ static void PutDepData (DDD::DDDContext& context,
       if (addTyp<DDD_USER_DATA || addTyp>DDD_USER_DATA_MAX)
       {
         /* convert pointers using SymTab */
-        descDep = &context.typeDefs()[addTyp];
+        TYPE_DESC* descDep = &context.typeDefs()[addTyp];
         curr = chunk;
-        for(i=0; i<addCnt; i++)
+        for(int i=0; i<addCnt; i++)
         {
           /* insert pointers into copy using SymTab */
           if (descDep->nPointers>0)
@@ -381,10 +376,11 @@ static void PutDepData (DDD::DDDContext& context,
       addCnt *= -1;
 
       /* convert offset table into pointer table */
-      descDep = &context.typeDefs()[addTyp];
-      table = (char **)chunk;
+      TYPE_DESC* descDep = &context.typeDefs()[addTyp];
+      char** table = (char **)chunk;
       chunk += CEIL(sizeof(int)*addCnt);
-      for(i=0, adr=chunk; i<addCnt; i++)
+      char* adr = chunk;
+      for(int i=0; i<addCnt; i++)
       {
         table[i] = ((long int)table[i])+adr;
 
-- 
GitLab


From f2b2095abf5b4e2c169ffdae2780ad0030a7fc13 Mon Sep 17 00:00:00 2001
From: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de>
Date: Tue, 18 Jun 2019 13:12:06 +0200
Subject: [PATCH 2/2] cleanup: only define `f` when `NDEBUG` is not defined
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This addresses the following compiler warning from GCC 9:

    gm/ugm.cc:1247:12: warning: unused variable ‘f’ [-Wunused-variable]
---
 gm/ugm.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gm/ugm.cc b/gm/ugm.cc
index 74d2ea9d1..00805af38 100644
--- a/gm/ugm.cc
+++ b/gm/ugm.cc
@@ -1244,7 +1244,9 @@ int GetSideIDFromScratchSpecialRule22Tet (ELEMENT *theElement, NODE *theNode)
 INT GetSideIDFromScratchSpecialRule (ELEMENT *theElement, NODE *theNode)
 {
   int j,l;
+#ifndef NDEBUG
   ELEMENT *f = EFATHER(theElement);
+#endif
 
   assert(TAG(f)==HEXAHEDRON);
   assert(ECLASS(theElement)==GREEN_CLASS);
-- 
GitLab