浏览代码

HPCC-16452 - Suppress more coverity defect reports

More potentially incorrect code flagged up by coverity, none causing any
issues in practice.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 年之前
父节点
当前提交
53a28b61e7
共有 5 个文件被更改,包括 16 次插入17 次删除
  1. 1 0
      roxie/ccd/ccdfile.cpp
  2. 4 5
      roxie/ccd/ccdkey.cpp
  3. 1 1
      roxie/ccd/ccdquery.cpp
  4. 1 1
      roxie/ccd/ccdqueue.cpp
  5. 9 10
      roxie/ccd/ccdserver.cpp

+ 1 - 0
roxie/ccd/ccdfile.cpp

@@ -2686,6 +2686,7 @@ protected:
         remotes.append("test.remote");
 
         int f = open("test.remote", _O_WRONLY | _O_CREAT | _O_TRUNC, _S_IREAD | _S_IWRITE);
+        CPPUNIT_ASSERT(f >= 0);
         int val = 1;
         int wrote = write(f, &val, sizeof(int));
         CPPUNIT_ASSERT(wrote==sizeof(int));

+ 4 - 5
roxie/ccd/ccdkey.cpp

@@ -1869,11 +1869,7 @@ public:
                 }
                 ret = GETROW(midx++);
             }
-            if (!ret)
-            {
-                DBGLOG("ERROR: nextMatch found NULL pointer");
-                DBGLOG("midx = %d, lidx=%d, numptrs=%d", midx, lidx, numPtrs);
-            }
+            assertex(ret);
             if ((!postFiltering) || matches(ret, postFilter))
                 return ret;
         }
@@ -2112,6 +2108,7 @@ protected:
 
         Owned<IInMemoryIndexCursor> dd = indexes.createCursor();
         InMemoryIndexCursor *d = QUERYINTERFACE(dd.get(), InMemoryIndexCursor);
+        ASSERT(d != nullptr);
         dd->append(createSingleKeySegmentMonitor(false, 4, sizeof(unsigned), &searchval));
         dd->append(createSingleKeySegmentMonitor(false, 8, sizeof(unsigned), &searchval));
         ASSERT(d->postFilter.length()==2);
@@ -2126,6 +2123,7 @@ protected:
 
         dd.setown(indexes.createCursor());
         d = QUERYINTERFACE(dd.get(), InMemoryIndexCursor);
+        ASSERT(d != nullptr);
         dd->append(createSingleKeySegmentMonitor(false, 16, sizeof(unsigned), &searchval));
         dd->append(createSingleKeySegmentMonitor(false, 8, sizeof(unsigned), &searchval));
         ASSERT(d->postFilter.length()==2);
@@ -2140,6 +2138,7 @@ protected:
     
         dd.setown(indexes.createCursor());
         d = QUERYINTERFACE(dd.get(), InMemoryIndexCursor);
+        ASSERT(d != nullptr);
         dd->append(createSingleKeySegmentMonitor(false, 12, sizeof(unsigned), &searchval));
         dd->append(createSingleKeySegmentMonitor(false, 16, sizeof(unsigned), &searchval));
         dd->append(createSingleKeySegmentMonitor(false, 8, sizeof(unsigned), &searchval));

+ 1 - 1
roxie/ccd/ccdquery.cpp

@@ -1467,7 +1467,7 @@ public:
         }
         else
             result = package.queryEnv(name);
-        if (!result)
+        if (!result && name)
             result = getenv(name);
         return strdup(result ? result : defaultValue);
     }

+ 1 - 1
roxie/ccd/ccdqueue.cpp

@@ -1794,7 +1794,7 @@ public:
 #ifdef _DEBUG
         bool udpResendEnabled = topology->getPropBool("@udpResendEnabled", false);
 #else
-        bool udpResendEnabled = false;  // As long as it is known to be broken, we don't want it accidentally enabled in any release version
+        const bool udpResendEnabled = false;  // As long as it is known to be broken, we don't want it accidentally enabled in any release version
 #endif
         maxPacketSize = multicastSocket->get_max_send_size();
         if ((maxPacketSize==0)||(maxPacketSize>65535))

+ 9 - 10
roxie/ccd/ccdserver.cpp

@@ -953,7 +953,7 @@ public:
           factory(_factory),
           basehelper(_factory->getHelper()),
           activityId(_factory->queryId()),
-          stats(_factory ? _factory->queryStatsMapping() : actStatistics),
+          stats(_factory->queryStatsMapping()),
           probeManager(_probeManager)
     {
         input = NULL;
@@ -1015,7 +1015,7 @@ public:
                 factory->noteProcessed(0, processed);
             factory->mergeActivityStats(stats, totalCycles, localCycles);
         }
-        if (ctx)
+        if (ctx && factory)
         {
             if (processed)
                 ctx->noteProcessed(factory->querySubgraphId(), activityId, 0, processed, 0);
@@ -1715,7 +1715,7 @@ public:
         {
             if (factory && !debugging)
                 factory->noteProcessed(0, processed);
-            if (ctx)
+            if (ctx && factory)
                 ctx->noteProcessed(factory->querySubgraphId(), activityId, 0, processed, strands.ordinality());
             processed = 0;  // To avoid reprocessing in base destructor
         }
@@ -3147,8 +3147,6 @@ public:
     virtual const void *getMessageHeader(unsigned &length) const
     {
         throwUnexpected(); // should never get called - I don't have a header available
-        length = 0;
-        return NULL;
     }
 
     virtual const void *getMessageMetadata(unsigned &length) const
@@ -4247,8 +4245,7 @@ public:
         }
         if (ctx->queryDebugContext() && ctx->queryDebugContext()->getExecuteSequentially())
             deferredStart = true;
-        if (ctx)
-            timeActivities = ctx->queryOptions().timeActivities;
+        timeActivities = ctx->queryOptions().timeActivities;
     }
 
     virtual void onStart(unsigned _parentExtractSize, const byte * _parentExtract)
@@ -24151,7 +24148,7 @@ public:
     virtual void onLimitExceeded(bool isKeyed)
     {
         if (traceLevel > 4)
-            DBGLOG("activityid = %d  isKeyed = %d  line = %d", activityId, isKeyed, __LINE__);DBGLOG("%d  activityid = %d", __LINE__, activityId);
+            DBGLOG("activityid = %d  isKeyed = %d  line = %d", activityId, isKeyed, __LINE__);
         throwUnexpected();
     }
 
@@ -27847,11 +27844,13 @@ protected:
                     if (!next)
                     {
                         ASSERT(repeats==0);
-                        ASSERT(output[count++] == NULL);
+                        ASSERT(output[count] == NULL);
+                        count++;
                         next = outStream->nextRow();
                         if (!next)
                         {
-                            ASSERT(output[count++] == NULL);
+                            ASSERT(output[count] == NULL);
+                            count++;
                             break;
                         }
                     }