Przeglądaj źródła

Merge pull request #382 from richardkchapman/roxie_cppcheck

Roxie cppcheck fixes
Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 13 lat temu
rodzic
commit
5f093d3800

+ 7 - 0
roxie/ccd/ccd.hpp

@@ -161,6 +161,10 @@ public:
 
     inline RoxiePacketHeader(const RemoteActivityId &_remoteId, ruid_t _uid, unsigned _channel, unsigned _overflowSequence)
     {
+        packetlength = sizeof(RoxiePacketHeader);
+#ifdef TIME_PACKETS
+        tick = 0;
+#endif
         init(_remoteId, _uid, _channel, _overflowSequence);
     }
 
@@ -177,6 +181,9 @@ public:
         if (_activityId >= ROXIE_ACTIVITY_SPECIAL_FIRST && _activityId <= ROXIE_ACTIVITY_SPECIAL_LAST)
             overflowSequence |= OUTOFBAND_SEQUENCE; // Need to make sure it is not treated as dup of actual reply in the udp layer
         retries = getSubChannelMask(channel) | (source.retries & ~ROXIE_RETRIES_MASK);
+#ifdef TIME_PACKETS
+        tick = source.tick;
+#endif
         packetlength = sizeof(RoxiePacketHeader);
     }
 

+ 7 - 18
roxie/ccd/ccdactivities.cpp

@@ -2581,7 +2581,6 @@ public:
     {
         OptimizedRowBuilder rowBuilder(owner.rowAllocator, owner.meta, output, owner.serializer);
         helper->clearAggregate(rowBuilder);
-        unsigned __int64 totalCount  = 0;
         while (!aborted && !deserializeSource.eos())
         {
             prefetcher->readAhead(deserializeSource);
@@ -3031,8 +3030,6 @@ protected:
     Linked<TranslatorArray> layoutTranslators;
     Linked<IKeyArray> keyArray;
     IDefRecordMeta *activityMeta;
-
-    IRecordLayoutTranslator *lastTranslator;
     bool createSegmentMonitorsPending;
 
     virtual void createSegmentMonitors() = 0;
@@ -3088,7 +3085,8 @@ protected:
         : CRoxieSlaveActivity(_logctx, _packet, _hFactory, _aFactory), 
         keyArray(_aFactory->queryKeyArray()),
         layoutTranslators(_aFactory->queryLayoutTranslators()),
-        activityMeta(_aFactory->queryActivityMeta())
+        activityMeta(_aFactory->queryActivityMeta()),
+        createSegmentMonitorsPending(true)
     {
     }
 
@@ -3169,6 +3167,8 @@ public:
         indexHelper = (IHThorIndexReadBaseArg *) basehelper;
         variableFileName = (indexHelper->getFlags() & (TIRvarfilename|TIRdynamicfilename)) != 0;
         isOpt = (indexHelper->getFlags() & TDRoptional) != 0;
+        inputData = NULL;
+        inputCount = 0;
         inputsDone = 0;
         processed = 0;
         keyprocessed = 0;
@@ -3179,7 +3179,6 @@ public:
         numSeeks = 0;
         if (packet->getSmartStepInfoLength())
         {
-            unsigned smartStepInfoLength = packet->getSmartStepInfoLength();
             const byte *smartStepInfoValue = packet->querySmartStepInfoData();
             numSkipFields = * (unsigned short *) smartStepInfoValue;
             smartStepInfoValue += sizeof(unsigned short);
@@ -3203,7 +3202,6 @@ public:
             }
 #endif
         }
-        createSegmentMonitorsPending = true;
     }
 
     virtual void onCreate()
@@ -3307,10 +3305,7 @@ public:
                 i++;
             }
             if (allKeys->numParts())
-            {
                 tlk.setown(::createKeyMerger(allKeys, 0, steppingOffset, &logctx));
-                createSegmentMonitorsPending = true;
-            }
             else
                 tlk.clear();
             createSegmentMonitorsPending = true;
@@ -4089,7 +4084,6 @@ public:
         MTIME_SECTION(timer, "CRoxieIndexGroupAggregateActivity ::process");
         Owned<IRowManager> rowManager = roxiemem::createRowManager(0, NULL, logctx, NULL, true); // MORE - should not really use default limits
         Owned<IMessagePacker> output = ROQ->createOutputStream(packet->queryHeader(), false, logctx);
-        unsigned skipped = 0;
 
         unsigned processedBefore = processed;
         try
@@ -4161,7 +4155,7 @@ public:
         if (tlk) // a very early abort can mean it is NULL....
         {
             logctx.noteStatistic(STATS_ACCEPTED, processed-processedBefore, 1);
-            logctx.noteStatistic(STATS_REJECTED, skipped, 1);
+            logctx.noteStatistic(STATS_REJECTED, 0, 1);
         }
         logctx.flush(true, aborted);
         if (aborted)
@@ -4262,6 +4256,7 @@ public:
     {
         helper = (IHThorFetchBaseArg *) basehelper;
         fetchContext = static_cast<IHThorFetchContext *>(helper->selectInterface(TAIfetchcontext_1));
+        base = 0;
         variableFileName = (fetchContext->getFetchFlags() & (FFvarfilename|FFdynamicfilename)) != 0;
         isOpt = (fetchContext->getFetchFlags() & FFdatafileoptional) != 0;
         onCreate();
@@ -4354,7 +4349,6 @@ public:
     CRoxieFetchActivity(SlaveContextLogger &_logctx, IRoxieQueryPacket *_packet, HelperFactory *_hFactory, const CRoxieFetchActivityFactory *_aFactory)
         : CRoxieFetchActivityBase(_logctx, _packet, _hFactory, _aFactory)
     {
-        IHThorFetchArg *h = (IHThorFetchArg *) helper;
         IHThorFetchContext * fetchContext = static_cast<IHThorFetchContext *>(helper->selectInterface(TAIfetchcontext_1));
         IOutputMetaData *diskMeta = fetchContext->queryDiskRecordSize();
         diskAllocator.setown(getRowAllocator(diskMeta, basefactory->queryId()));
@@ -4938,9 +4932,7 @@ class CRoxieKeyedJoinFetchActivity : public CRoxieSlaveActivity
     IHThorKeyedJoinArg *helper;
     Owned<IFileIO> rawFile;
     const CRoxieKeyedJoinFetchActivityFactory *factory;
-    char *rawBuffer;
     offset_t base;
-    unsigned rawSize;
     const char *inputLimit;
     const char *inputData;
     Owned<IFileIOArray> varFiles;
@@ -4961,6 +4953,7 @@ public:
           CRoxieSlaveActivity(_logctx, _packet, _hFactory, _aFactory)
     {
         // MORE - no continuation row support?
+        base = 0;
         helper = (IHThorKeyedJoinArg *) basehelper;
         variableFileName = (helper->getFetchFlags() & (FFvarfilename|FFdynamicfilename)) != 0;
         onCreate();
@@ -5135,7 +5128,6 @@ public:
         MTIME_SECTION(timer, "CRoxieRemoteActivity ::process");
 
         Owned<IMessagePacker> output = ROQ->createOutputStream(packet->queryHeader(), false, logctx);
-        unsigned totalSizeSent = 0;
         unsigned __int64 rowLimit = remoteHelper->getRowLimit();
 
         rtlRowBuilder remoteExtractBuilder;
@@ -5148,8 +5140,6 @@ public:
         {
             remoteGraph->beforeExecute();
             Owned<IRoxieInput> input = remoteGraph->startOutput(0, remoteExtractBuilder.size(), remoteExtractBuilder.getbytes(), false);
-
-            unsigned processedBefore = processed;
             while (!aborted)
             {
                 const void * next = input->nextInGroup();
@@ -5179,7 +5169,6 @@ public:
                     output->putBuffer(recBuffer, nextSize, meta.isVariableSize());
                 }
                 ReleaseRoxieRow(next);
-                totalSizeSent += nextSize;
             }
 
             remoteGraph->afterExecute();

+ 1 - 1
roxie/ccd/ccddali.cpp

@@ -313,7 +313,7 @@ public:
     static IRoxieDaliHelper *connectToDali()
     {
         CriticalBlock b(daliConnectionCrit);
-        IRoxieDaliHelper *helper = LINK(daliHelper);
+        LINK(daliHelper);
         if (daliHelper && daliHelper->isAlive())
             return daliHelper;
         else

+ 0 - 5
roxie/ccd/ccdfile.cpp

@@ -1423,7 +1423,6 @@ public:
 
             RoxieFileType type = item->getFileType();
 
-            bool okToDelete = true;  // assume ok to delete - all DLLS are always good to delete
             if (cleanUpOneTimeQueries)  // only want to delete dlls
             {
                 if (type != ROXIE_WU_DLL)
@@ -1472,7 +1471,6 @@ public:
 
 ILazyFileIO *createDynamicFile(const char *id, IPartDescriptor *pdesc, RoxieFileType fileType, int numParts)
 {
-    unsigned short daliServixPort = getDaliServixPort();
     IPropertyTree &partProps = pdesc->queryProperties();
     offset_t dfsSize = partProps.getPropInt64("@size");
     unsigned crc;
@@ -1842,7 +1840,6 @@ public:
             IDistributedSuperFile *superFile = dFile->querySuperFile();
             if (superFile)
             {
-                unsigned numSubFiles = superFile->numSubFiles(true);
                 Owned<IDistributedFileIterator> subs = superFile->getSubFileIterator(true);
                 ForEach(*subs)
                 {
@@ -1931,7 +1928,6 @@ public:
             unsigned numParts = fdesc->numParts();
             if (numParts > 1 && fileType==ROXIE_KEY && isLocal)
                 numParts--; // don't want to send TLK
-            offset_t base = 0;
             UnsignedArray partNos;
             for (unsigned i = 1; i <= numParts; i++)
             {
@@ -1970,7 +1966,6 @@ public:
         if (fdesc)
         {
             unsigned numParts = fdesc->numParts();
-            offset_t base = 0;
             for (unsigned i = 1; i <= numParts; i++)
             {
                 if (!channel || getBondedChannel(i)==channel)

+ 1 - 2
roxie/ccd/ccdkey.cpp

@@ -1731,6 +1731,7 @@ public:
         midx = 1;
         lidx = 0;
         lastoffset = (unsigned) -1;
+        eof = false;
     }
 
     ~InMemoryIndexCursor()
@@ -1902,7 +1903,6 @@ bool InMemoryIndexManager::selectKey(InMemoryIndexCursor *cursor)
 {
     noteQuery(cursor->postFilter, 0);
     unsigned best = 0;
-    unsigned bestPos = 0;
 
     CriticalBlock b(activeCrit);
     InMemoryIndex *bestIndex = NULL;
@@ -1921,7 +1921,6 @@ bool InMemoryIndexManager::selectKey(InMemoryIndexCursor *cursor)
             if (score > best)
             {
                 bestIndex = &thisIndex;
-                bestPos = idx;
                 best = score;
             }
             if (score==cursor->maxScore)

+ 5 - 3
roxie/ccd/ccdmain.cpp

@@ -365,8 +365,10 @@ void FatalError(const char *format, ...)
 
 class MAbortHandler : implements IExceptionHandler
 {
-    unsigned x;
+    unsigned dummy; // to avoid complaints about an empty class...
 public:
+    MAbortHandler() : dummy(0) {};
+
     virtual bool fireException(IException *e)
     {
         ForEachItemIn(idx, socketListeners)
@@ -383,7 +385,7 @@ int myhook(int alloctype, void *, size_t nSize, int p1, long allocSeq, const uns
     // Handy place to put breakpoints when tracking down obscure memory leaks...
     if (nSize==68 && !file)
     {
-        int a = 1;
+        DBGLOG("memory hook matched");
     }
     return true;
 }
@@ -957,7 +959,7 @@ int STARTQUERY_API start_query(int argc, const char *argv[])
             const char *iptext = slave.queryProp("@netAddress");
             if (iptext)
             {
-                unsigned nodeIndex = addRoxieNode(iptext);
+                addRoxieNode(iptext);
                 IpAddress slaveIp(iptext);
                 bool isMe = ipMatch(slaveIp) && slave.getPropInt("@multihost", 0) == myHostNumber;
                 bool suspended = slave.getPropBool("@suspended", false);

+ 8 - 6
roxie/ccd/ccdqueue.cpp

@@ -641,8 +641,8 @@ public:
     void enqueue(IRoxieQueryPacket *x)
     {
         {
-            RoxiePacketHeader &header = x->queryHeader();
 #ifdef _DEBUG
+            RoxiePacketHeader &header = x->queryHeader();
             if (traceLevel > 10)
             {
                 StringBuffer xx;
@@ -804,8 +804,12 @@ class CRoxieWorker : public CInterface, implements IPooledThread
 
 public:
     IMPLEMENT_IINTERFACE;
-    CRoxieWorker() 
+    CRoxieWorker()
     {
+        queue = NULL;
+        stopped = false;
+        busy = false;
+        abortJob = false;
     }
     void init(void *_r) 
     {
@@ -885,7 +889,6 @@ public:
     {
         try 
         {
-            unsigned activityId = 0;
             if (activity && (logctx.queryTraceLevel() > 1))
             {
                 StringBuffer act;
@@ -893,7 +896,6 @@ public:
                 logctx.CTXLOG("throwRemoteException, activity %s, isUser=%d", act.str(), (int) isUser);
                 if (!isUser)
                     EXCLOG(E, "throwRemoteException");
-                activityId = activity->queryId();
             }
             
             RoxiePacketHeader &header = packet->queryHeader();
@@ -2537,8 +2539,8 @@ public:
                                 RecordLengthType *rowlen = (RecordLengthType *) len.get();
                                 OwnedConstRoxieRow row = callbackData->getNext(*rowlen);
                                 const char *rowdata = (const char *) row.get();
-                                bool isOpt = * (bool *) rowdata;
-                                bool isLocal = * (bool *) (rowdata+1);
+                                // bool isOpt = * (bool *) rowdata;
+                                // bool isLocal = * (bool *) (rowdata+1);
                                 ROQ->sendAbortCallback(header, rowdata+2, *logctx);
                             }
                             else

Plik diff jest za duży
+ 236 - 57
roxie/ccd/ccdserver.cpp


+ 1 - 1
roxie/ccd/ccdserver.hpp

@@ -352,7 +352,7 @@ extern void setStartRuid(unsigned restarts);
 class CIndexTransformCallback : public CInterface, implements IThorIndexCallback 
 {
 public:
-    CIndexTransformCallback() { keyManager = NULL; cleanupRequired = false; };
+    CIndexTransformCallback() { keyManager = NULL; cleanupRequired = false; filepos = 0; };
     IMPLEMENT_IINTERFACE
 
 //IThorIndexCallback

+ 0 - 1
roxie/ccd/ccdsnmp.cpp

@@ -524,7 +524,6 @@ void CRoxieMetricsManager::resetMetrics()
         INamedMetric *m = (INamedMetric *) *metricMap.mapToValue(&cur);
         if (m->isCumulative())
         {
-            const char *name = (const char *) cur.getKey();
             m->resetValue();
         }
     }

+ 1 - 21
roxie/ccd/ccdstate.cpp

@@ -566,7 +566,7 @@ public:
             Owned<IDirectoryIterator> iter = packageFile->directoryFiles("*.pkg",false,false);
             // sort the list of files based on name
             CIArrayOf<CDirectoryEntry> sortedfiles;
-            unsigned numfiles = sortDirectory(sortedfiles, *iter, SD_bynameNC, false, false);
+            sortDirectory(sortedfiles, *iter, SD_bynameNC, false, false);
             ForEachItemIn(idx, sortedfiles)
             {
                 CDirectoryEntry *de = &sortedfiles.item(idx);
@@ -1692,8 +1692,6 @@ public:
             }
             else if (stricmp(queryName, "control:suspend")==0)
             {
-                unsigned timeout = control->getPropInt("@timeout", 10000);
-
                 StringBuffer id(control->queryProp("Query/@id"));
                 if (!id.length())
                     badFormat();
@@ -2067,24 +2065,6 @@ extern void createResourceManagers(const IQueryDll *standAloneDll, unsigned numC
             E->Release();
         }
     }
-#ifdef NOTNOW
-    // now load from dali PackageSets
-    Owned<IPropertyTree> newPackageSet = daliHelper->getQuerySet(roxieName);
-    Owned<IPropertyTreeIterator> packages = newPackageSet->getElements("*");
-    ForEach(*packages)
-    {
-        IPropertyTree &pkg = packages->query();
-        const char *id = pkg.queryProp("@id");
-        const IRoxiePackage *package = packages.queryPackage(id);
-        if (package)
-        {
-            int i =0;
-        }
-        else
-            int dafs = 0;
-
-    }
-#endif
 
     if (!grms.length())
     {