Browse Source

HPCC-24003 Clean up some coverity issues

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 5 năm trước cách đây
mục cha
commit
c61ab6b0b9

+ 1 - 1
dali/base/danqs.cpp

@@ -473,7 +473,7 @@ class CDaliNamedQueueServer: public IDaliServer, public Thread, implements IConn
     bool stopped;
     CIArrayOf<CNamedQueueSubscriptionStub> stubs; // kept in priority order
     CheckedCriticalSection subsect;
-    int fn;
+    int fn = 0;
 public:
     IMPLEMENT_IINTERFACE;
 

+ 7 - 3
dali/base/dasds.cpp

@@ -4832,9 +4832,11 @@ IPropertyTree *loadStore(const char *storeFilename, IPTreeMaker *iMaker, unsigne
 // Not really coalescing, blocking transations and saving store (which will delete pending transactions).
 class CLightCoalesceThread : implements ICoalesce, public CInterface
 {
-    bool stopped, within24;
+    bool stopped = false;
+    bool within24 = false;
     Semaphore sem;
-    unsigned writeTransactionsNow, lastSaveWriteTransactions, lastWarning;
+    unsigned lastSaveWriteTransactions = 0;
+    unsigned lastWarning = 0;
     unsigned idlePeriod, minimumTimeBetweenSaves, idleRate;
     Linked<IPropertyTree> config;
     Owned<IJlibDateTime> quietStartTime, quietEndTime;
@@ -4853,7 +4855,6 @@ public:
     IMPLEMENT_IINTERFACE;
     CLightCoalesceThread(IPropertyTree &_config, IStoreHelper *_iStoreHelper) : config(&_config), iStoreHelper(_iStoreHelper)
     {
-        stopped = false;
         idlePeriod = config->getPropInt("@lCIdlePeriod", DEFAULT_LCIDLE_PERIOD)*1000;
         minimumTimeBetweenSaves = config->getPropInt("@lCMinTime", DEFAULT_LCMIN_TIME)*1000;
         idleRate = config->getPropInt("@lCIdleRate", DEFAULT_LCIDLE_RATE);
@@ -8626,6 +8627,8 @@ bool CCovenSDSManager::fireException(IException *e)
     // so ignore unhandled exceptions for the moment! 
     IERRLOG(e, "Caught unhandled exception!");
     return true;
+
+#if 0
     { CHECKEDCRITICALBLOCK(unhandledCrit, fakeCritTimeout);
         if (processingUnhandled)
         {
@@ -8682,6 +8685,7 @@ bool CCovenSDSManager::fireException(IException *e)
     };
     unhandledThread.setown(new CHandleException(*this, e, restartOnError));
     return true;
+#endif
 }
 
 void CCovenSDSManager::addNodeSubscriber(ISubscription *sub, SubscriptionId id)

+ 2 - 2
dali/server/daldap.cpp

@@ -148,8 +148,8 @@ public:
         Owned<ISecUser> user = ldapsecurity->createUser(username);
         user->setAuthenticateStatus(AS_AUTHENTICATED);
 
-        bool filescope = stricmp(key,"Scope")==0;
-        bool wuscope = stricmp(key,"workunit")==0;
+        bool filescope = key && stricmp(key,"Scope")==0;
+        bool wuscope = key && stricmp(key,"workunit")==0;
 
         if (filescope || wuscope) {
             SecAccessFlags perm = SecAccess_None;

+ 1 - 1
ecl/hql/hqlgram2.cpp

@@ -1629,7 +1629,7 @@ protected:
 
 static bool wasLegacyAssignable(ITypeInfo * to, ITypeInfo * from)
 {
-    return (to->getTypeCode() == type_boolean) && isIntegralType(from);
+    return to && from && (to->getTypeCode() == type_boolean) && isIntegralType(from);
 }
 
 /* this func does not affect linkage */

+ 1 - 1
ecl/hqlcpp/hqlcpp.ipp

@@ -300,7 +300,7 @@ class HQLCPP_API CHqlBoundTarget
 {
 public:
     CHqlBoundTarget() {}
-    ~CHqlBoundTarget() { validate(); }
+    ~CHqlBoundTarget() noexcept(false) { validate(); }
 
     bool extractFrom(const CHqlBoundExpr & bound);
     bool isFixedSize() const;

+ 1 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -14697,7 +14697,7 @@ ABoundActivity * HqlCppTranslator::doBuildActivityNWayDistribute(BuildCtx & ctx,
     {
         UNIMPLEMENTED_X("DISTRIBUTE(NWAY)");
         // Come back to this when DISTRIBUTE(ds, bool) is being implemented
-        doBuildBoolFunction(instance->startctx, "include", cond);
+        //doBuildBoolFunction(instance->startctx, "include", cond);
     }
 
     StringBuffer flags;

+ 0 - 3
ecl/hqlcpp/hqlinline.cpp

@@ -1820,9 +1820,6 @@ AliasKind ClassEvalContext::evaluateExpression(BuildCtx & ctx, IHqlExpression *
         }
     }
 
-    if (!evaluateLocally)
-        return NotFoundAlias;
-
     translator.expandAliases(ctx, value, NULL);
     translator.buildTempExpr(ctx, value, tgt);
     return RuntimeAlias;

+ 40 - 40
ecl/hthor/hthor.ipp

@@ -430,7 +430,7 @@ class CHThorProcessActivity : public CHThorSimpleActivityBase
     IHThorProcessArg &helper;
     OwnedConstRoxieRow curRight;
     OwnedConstRoxieRow initialRight;
-    unsigned __int64 counter;
+    unsigned __int64 counter = 0;
     Owned<IEngineRowAllocator> rightRowAllocator;
 
 public:
@@ -948,11 +948,11 @@ public:
 class CHThorFirstNActivity : public CHThorSimpleActivityBase
 {
     IHThorFirstNArg &helper;
-    __int64 doneThisGroup;
-    __uint64 limit;  // You would think int was enough for most practical cases...
-    __uint64 skip;
-    bool finished;
-    bool grouped;
+    __int64 doneThisGroup = 0;
+    __uint64 limit = 0;  // You would think int was enough for most practical cases...
+    __uint64 skip = 0;
+    bool finished = false;
+    bool grouped = false;
 public:
     CHThorFirstNActivity(IAgentContext &agent, unsigned _activityId, unsigned _subgraphId, IHThorFirstNArg &_arg, ThorActivityKind _kind);
 
@@ -966,9 +966,9 @@ public:
 class CHThorChooseSetsActivity : public CHThorSimpleActivityBase
 {
     IHThorChooseSetsArg &helper;
-    unsigned numSets;
-    unsigned * setCounts;
-    bool finished;
+    unsigned numSets = 0;
+    unsigned * setCounts = nullptr;
+    bool finished = false;
 public:
     CHThorChooseSetsActivity(IAgentContext &agent, unsigned _activityId, unsigned _subgraphId, IHThorChooseSetsArg &_arg, ThorActivityKind _kind);
     ~CHThorChooseSetsActivity();
@@ -983,12 +983,12 @@ class CHThorChooseSetsExActivity : public CHThorSimpleActivityBase
 {
 protected:
     IHThorChooseSetsExArg &helper;
-    unsigned numSets;
-    unsigned * setCounts;
-    count_t * limits;
-    bool finished;
+    unsigned numSets = 0;
+    unsigned * setCounts = nullptr;
+    count_t * limits = nullptr;
+    bool finished = false;
     OwnedRowArray gathered;
-    aindex_t curIndex;
+    aindex_t curIndex = 0;
     virtual bool includeRow(const void * row) = 0;
     virtual void calculateSelection() = 0;
 public:
@@ -1032,8 +1032,8 @@ class CHThorGroupActivity : public CHThorSteppableActivityBase
 {
     IHThorGroupArg &helper;
     OwnedConstRoxieRow next; 
-    bool endPending;
-    bool firstDone;
+    bool endPending = false;
+    bool firstDone = false;
 public:
     CHThorGroupActivity(IAgentContext &agent, unsigned _activityId, unsigned _subgraphId, IHThorGroupArg &_arg, ThorActivityKind _kind);
 
@@ -1107,7 +1107,7 @@ protected:
     IHThorSortArg &helper;
     bool gotSorted;
     Owned<ISorter> sorter;
-    bool sorterIsConst;
+    bool sorterIsConst = false;
     Owned<IDiskMerger> diskMerger;
     Owned<IRowStream> diskReader;
 };
@@ -1456,29 +1456,29 @@ private:
     };
 
     IHThorHashJoinArg & helper;
-    IHThorInput * input1;
-    bool leftOuterJoin;
-    bool exclude;
-    bool many;
-    bool dedupRHS;
-    unsigned keepLimit;
-    unsigned atmostLimit;
-    unsigned limitLimit;
-    unsigned joinCounter;
-    bool limitFail;
-    bool limitOnFail;
-    bool hasGroupLimit;
-    bool isSmartJoin;
-    unsigned keepCount;
+    IHThorInput * input1 = nullptr;
+    bool leftOuterJoin = false;
+    bool exclude = false;
+    bool many = true;
+    bool dedupRHS = false;
+    unsigned keepLimit = 0;
+    unsigned atmostLimit = 0;
+    unsigned limitLimit = 0;
+    unsigned joinCounter = 0;
+    bool limitFail = false;
+    bool limitOnFail = false;
+    bool hasGroupLimit = false;
+    bool isSmartJoin = false;
+    unsigned keepCount = 0;
     OwnedConstRoxieRow defaultRight;
     RtlDynamicRowBuilder outBuilder;
     Owned<LookupTable> table;
-    bool eog;
-    bool matchedGroup;
+    bool eog = false;
+    bool matchedGroup = false;
     OwnedConstRoxieRow left;
-    bool gotMatch;
+    bool gotMatch = false;
     ConstPointerArray rightGroup;
-    aindex_t rightGroupIndex;
+    aindex_t rightGroupIndex = 0;
     Owned<IException> failingLimit;
 
     ConstPointerArray filteredRight;
@@ -1855,8 +1855,8 @@ protected:
 class CHThorCombineGroupActivity : public CHThorSimpleActivityBase
 {
     IHThorCombineGroupArg &helper;
-    unsigned __int64 numProcessedLastGroup;
-    IHThorInput *input1;
+    unsigned __int64 numProcessedLastGroup = 0;
+    IHThorInput *input1 = nullptr;
 public:
     CHThorCombineGroupActivity(IAgentContext &agent, unsigned _activityId, unsigned _subgraphId, IHThorCombineGroupArg &_arg, ThorActivityKind _kind);
 
@@ -1914,9 +1914,9 @@ class CHThorDiskReadActivity;
 class CHThorWorkunitReadActivity : public CHThorSimpleActivityBase
 {
     IHThorWorkunitReadArg &helper;
-    bool grouped;
-    bool eogPending;
-    bool first;
+    bool grouped = false;
+    bool eogPending = false;
+    bool first = true;
 
     // for case where the workunit result was written to disk, so that the activity must dynamically change into a disk read
     Owned<IHThorDiskReadArg> diskreadHelper;

+ 1 - 1
esp/logging/logginglib/LogSerializer.hpp

@@ -36,7 +36,7 @@ class CLogRequestInFile : public CSimpleInterface
 {
     StringAttr fileName;
     offset_t pos;
-    unsigned size;
+    unsigned size = 0;
     StringAttr GUID;
     StringAttr option;
 public:

+ 1 - 6
esp/platform/cumulativetimer.hpp

@@ -41,11 +41,6 @@ public:
     {
     }
 
-    CumulativeTimer(const CumulativeTimer& t)
-        : mNestingDepth(t.mNestingDepth)
-        , mTotalTime(t.mTotalTime)
-    {}
-
     ~CumulativeTimer()
     {
     }
@@ -105,7 +100,7 @@ private:
 
     unsigned __int64 mNestingDepth;
     unsigned __int64 mTotalTime;
-    LogLevel logLevel;
+    LogLevel logLevel = 0;
 
 private:
     CumulativeTimer& operator =(const CumulativeTimer&) = delete;

+ 1 - 2
esp/platform/espprotocol.hpp

@@ -163,8 +163,7 @@ private:
     CApplicationPortMap m_portmap;
     bool m_viewConfig;
     int m_MaxRequestEntityLength;
-    IEspContainer *m_container;
-    unsigned m_nextSeq;
+    IEspContainer *m_container = nullptr;
     Owned<IPersistentHandler> m_persistentHandler;
     ReadWriteLock rwLock;
 

+ 1 - 1
esp/platform/espsession.ipp

@@ -33,7 +33,7 @@ private:
     StringAttr m_commentURL;
     StringAttr m_domain;
     StringAttr m_ports;
-    int        m_maxage;
+    int        m_maxage = 0;
     StringAttr m_path;
     bool       m_secure;
     bool       m_httponly;

+ 0 - 2
esp/platform/txsummary.hpp

@@ -30,8 +30,6 @@
 class CTxSummary : extends CInterface
 {
 public:
-    IMPLEMENT_IINTERFACE;
-    
     // Construct an instance with the given creation time. A non-zero value
     // allows the summary to be in sync with its owning object. A value of
     // zero causes the summary to base its elapsed time calculations on its

+ 17 - 23
system/jlib/jfcmp.hpp

@@ -25,20 +25,20 @@
 class jlib_decl CFcmpCompressor : public CSimpleInterfaceOf<ICompressor>
 {
 protected:
-    size32_t blksz;
-    size32_t bufalloc;
+    size32_t blksz = 0;
+    size32_t bufalloc = 0;
     MemoryBuffer inma;      // equals blksize len
-    MemoryBuffer *outBufMb; // used when dynamic output buffer (when open() used)
-    size32_t outBufStart;
-    byte *inbuf;
-    size32_t inmax;         // remaining
-    size32_t inlen;
-    size32_t inlenblk;      // set to COMMITTED when so
-    bool trailing;
-    byte *outbuf;
-    size32_t outlen;
-    size32_t wrmax;
-    size32_t dynamicOutSz;
+    MemoryBuffer *outBufMb = nullptr; // used when dynamic output buffer (when open() used)
+    size32_t outBufStart = 0;
+    byte *inbuf = nullptr;
+    size32_t inmax = 0;         // remaining
+    size32_t inlen = 0;
+    size32_t inlenblk = 0;      // set to COMMITTED when so
+    bool trailing = false;
+    byte *outbuf = nullptr;
+    size32_t outlen = 0;
+    size32_t wrmax = 0;
+    size32_t dynamicOutSz = 0;
 
     virtual void setinmax() = 0;
     virtual void flushcommitted() = 0;
@@ -56,14 +56,8 @@ protected:
 public:
     CFcmpCompressor()
     {
-        outlen = 0;
         outbuf = NULL;      // only set on close
-        bufalloc = 0;
         wrmax = 0;          // set at open
-        dynamicOutSz = 0;
-        outBufMb = NULL;
-        outBufStart = 0;
-        inbuf = NULL;
     }
 
     virtual ~CFcmpCompressor()
@@ -216,7 +210,7 @@ protected:
     byte *outbuf;
     size32_t outlen;
     size32_t bufalloc;
-    const size32_t *in;
+    const size32_t *in = nullptr;
 
 public:
     CFcmpExpander()
@@ -305,12 +299,12 @@ protected:
     bool reading;
     MemoryAttr ma;
     size32_t bufsize;
-    size32_t bufpos;        // reading only
-    offset_t expSize;
+    size32_t bufpos = 0;        // reading only
+    offset_t expSize = 0;
     __int64 compType;
 
 public:
-    CFcmpStream()
+    CFcmpStream(__int64 _compType) : compType(_compType)
     {
         expOffset = 0;
         cmpOffset = 0;

+ 2 - 2
system/jlib/jfile.hpp

@@ -582,8 +582,8 @@ public:
 
 public:
     StringAttr filename;
-    offset_t length;
-    offset_t offset;
+    offset_t length = 0;
+    offset_t offset = 0;
 };
 typedef CIArrayOf<ExtractedBlobInfo> ExtractedBlobArray;
 

+ 1 - 1
system/jlib/jflz.cpp

@@ -832,7 +832,7 @@ class CFastLZStream : public CFcmpStream
 
 
 public:
-    CFastLZStream() { compType = FLZSTRMCOMPRESSEDFILEFLAG; }
+    CFastLZStream() : CFcmpStream(FLZSTRMCOMPRESSEDFILEFLAG) { }
 
     virtual ~CFastLZStream() { flush(); }
 

+ 1 - 1
system/jlib/jlog.hpp

@@ -570,7 +570,7 @@ protected:
     LogMsgSysInfo             sysInfo;
     LogMsgJobInfo             jobInfo;
     LogMsgCode                msgCode = NoLogMsgCode;
-    unsigned                  component;
+    unsigned                  component = 0;    // Not sure this is used
     StringBuffer              text;
     bool                      remoteFlag = false;
 };

+ 1 - 1
system/jlib/jlog.ipp

@@ -735,7 +735,7 @@ private:
         bool more;
         CallbackInterThreadQueueOf<LogMsg, MsgProcessor, false> q;
         unsigned droppingLimit;
-        unsigned numToDrop;
+        unsigned numToDrop = 1;
         Mutex pullCycleMutex;
     };
     Owned<MsgProcessor> processor;

+ 1 - 1
system/jlib/jlz4.cpp

@@ -291,7 +291,7 @@ class CLZ4Stream : public CFcmpStream
 
 
 public:
-    CLZ4Stream() { compType = LZ4STRMCOMPRESSEDFILEFLAG; }
+    CLZ4Stream() : CFcmpStream(LZ4STRMCOMPRESSEDFILEFLAG) { }
 
     virtual ~CLZ4Stream() { flush(); }
 

+ 2 - 2
system/mp/test/mptest.cpp

@@ -1496,7 +1496,7 @@ void printHelp(char* executableName)
 int main(int argc, char* argv[])
 {
     int mpi_debug = 0;
-    char testname[256] = { "" };
+    const char * testname = "";
     rank_t max_ranks = 0;
     unsigned startupDelay = 0;
 
@@ -1581,7 +1581,7 @@ int main(int argc, char* argv[])
                 {
                     if ((j+1) < argSize)
                     {
-                        strcpy(testname, argL[j+1]);
+                        testname = argL[j+1];
                         j++;
                     }
                 }