Browse Source

HPCC-9853 Fix various warnings (a couple may have revealed minor bugs)

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 years ago
parent
commit
17c5f01c29
51 changed files with 124 additions and 95 deletions
  1. 18 18
      common/deftype/defvalue.cpp
  2. 2 0
      common/fileview2/fvresultset.cpp
  3. 2 2
      common/remote/sockfile.cpp
  4. 2 0
      common/thorhelper/thorparse.cpp
  5. 1 1
      common/thorhelper/thorsoapcall.cpp
  6. 1 1
      common/thorhelper/thortparse.cpp
  7. 1 1
      common/workunit/wujobq.cpp
  8. 2 2
      dali/base/danqs.cpp
  9. 3 1
      dali/base/dautils.cpp
  10. 5 1
      dali/daliadmin/daliadmin.cpp
  11. 1 1
      dali/dalidiag/dalidiag.cpp
  12. 1 1
      dali/dfuXRefLib/dfurdir.cpp
  13. 1 1
      dali/sasha/sasha.cpp
  14. 1 1
      dali/sasha/saxref.cpp
  15. 2 2
      deployment/deploy/DeploymentEngine.cpp
  16. 5 5
      ecl/hql/hqlfold.cpp
  17. 2 0
      ecl/hqlcpp/hqlckey.cpp
  18. 8 8
      ecl/hqlcpp/hqlcpp.cpp
  19. 1 1
      ecl/hqlcpp/hqlcpp.ipp
  20. 1 1
      ecl/hqlcpp/hqlhtcpp.cpp
  21. 1 1
      ecl/hthor/hthorkey.cpp
  22. 1 1
      esp/bindings/SOAP/xpp/xpp/xpputils.cpp
  23. 3 0
      esp/services/WsDeploy/WsDeployService.cpp
  24. 1 1
      esp/services/ws_workunits/ws_workunitsHelpers.cpp
  25. 1 1
      esp/services/ws_workunits/ws_workunitsQuerySets.cpp
  26. 1 1
      plugins/fileservices/fileservices.cpp
  27. 1 1
      plugins/javaembed/javaembed.cpp
  28. 2 2
      roxie/ccd/ccddali.cpp
  29. 1 1
      roxie/ccd/ccdlistener.cpp
  30. 1 1
      roxie/roxieclient/roxieclient.cpp
  31. 1 1
      roxie/roxiepipe/roxiepipe.cpp
  32. 1 1
      roxie/udplib/uttest.cpp
  33. 2 0
      rtl/eclrtl/eclrtl.cpp
  34. 11 6
      rtl/eclrtl/eclrtl.hpp
  35. 1 1
      system/hrpc/hrpc.cpp
  36. 2 2
      system/jhtree/ctfile.cpp
  37. 1 1
      system/jhtree/keydiff.cpp
  38. 1 1
      system/jlib/jdebug.cpp
  39. 1 1
      system/jlib/jexcept.hpp
  40. 4 2
      system/jlib/jfile.cpp
  41. 1 0
      system/jlib/jlzw.cpp
  42. 1 1
      system/jlib/jmisc.cpp
  43. 2 2
      system/jlib/jregexp.cpp
  44. 10 10
      system/jlib/jsocket.cpp
  45. 2 0
      system/jlib/jsort.cpp
  46. 2 0
      system/security/LdapSecurity/ldapsecurity.cpp
  47. 1 1
      thorlcr/activities/indexread/thindexread.cpp
  48. 1 1
      thorlcr/activities/msort/thsortu.cpp
  49. 1 1
      thorlcr/activities/thdiskbase.cpp
  50. 1 1
      thorlcr/msort/tsorta.cpp
  51. 4 4
      tools/copyexp/copyexp.cpp

+ 18 - 18
common/deftype/defvalue.cpp

@@ -2385,7 +2385,7 @@ IValue *createValueFromMem(ITypeInfo *type, const void *mem)
     {
         RealUnion u;
         memcpy(&u, mem, size);
-        double val;
+        double val = 0;
         switch (size)
         {
         case 4:
@@ -2450,7 +2450,7 @@ IValue * addValues(IValue * left, IValue * right)
             break;
         }
     default:
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -2492,7 +2492,7 @@ IValue * subtractValues(IValue * left, IValue * right)
             break;
         }
     default:
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -2523,7 +2523,7 @@ IValue * multiplyValues(IValue * left, IValue * right)
             break;
         }
     default:
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -2584,7 +2584,7 @@ IValue * divideValues(IValue * left, IValue * right, byte dbz)
         return createDecimalValueFromStack(pnt);
     }
     default:
-        assertThrow(false);
+        throwUnexpected();
         return NULL;
     }
 }
@@ -2644,7 +2644,7 @@ IValue * modulusValues(IValue * left, IValue * right, byte dbz)
         return createDecimalValueFromStack(pnt);
     }
     default:
-        assertThrow(false);
+        throwUnexpected();
         return NULL;
     }
 }
@@ -2674,7 +2674,7 @@ IValue * powerValues(IValue * left, IValue * right)
 */
     default:
         pnt->Release();
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -2697,7 +2697,7 @@ IValue * negateValue(IValue * v)
             return ((CDecimalTypeInfo*)v->queryType())->createValueFromStack();
         }
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -2725,7 +2725,7 @@ IValue * roundUpValue(IValue * v)
             return createDecimalValueFromStack(resultType);
         }
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -2748,7 +2748,7 @@ IValue * roundValue(IValue * v)
             return createDecimalValueFromStack(resultType);
         }
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -2771,7 +2771,7 @@ IValue * roundToValue(IValue * v, int places)
             return createDecimalValueFromStack(resultType);
         }
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -2794,7 +2794,7 @@ IValue * truncateValue(IValue * v)
             return createDecimalValueFromStack(resultType);
         }
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -2871,7 +2871,7 @@ IValue * sqrtValue(IValue * v)
         //MORE: This should probably do this more accurately.
         return createRealValue(rtlSqrt(v->getRealValue()), 8);
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -2902,7 +2902,7 @@ IValue * absValue(IValue * v)
             return ((CDecimalTypeInfo*)v->queryType())->createValueFromStack();
         }
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 
@@ -3125,7 +3125,7 @@ IValue * binaryAndValues(IValue * left, IValue * right)
         ret = createTruncIntValue(left->getIntValue() & right->getIntValue(), pnt.getClear());
         break;
     default:
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -3145,7 +3145,7 @@ IValue * binaryOrValues(IValue * left, IValue * right)
         ret = createTruncIntValue(left->getIntValue() | right->getIntValue(), pnt.getClear());
         break;
     default:
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -3163,7 +3163,7 @@ IValue * binaryXorValues(IValue * left, IValue * right)
         ret = createTruncIntValue(left->getIntValue() ^ right->getIntValue(), pnt);
         break;
     default:
-        assertThrow(false);
+        throwUnexpected();
     }
     return ret;
 }
@@ -3177,7 +3177,7 @@ IValue * binaryNotValues(IValue * v)
     case type_packedint:
         return createTruncIntValue(~v->getIntValue(), v->getType());
     }
-    assertThrow(false);
+    throwUnexpected();
     return NULL;
 }
 

+ 2 - 0
common/fileview2/fvresultset.cpp

@@ -253,6 +253,8 @@ static __int64 getIntFromSwapInt(ITypeInfo & type, const void * cur, bool isMapp
         case 6: result = rtlRevUInt6(cur); break;
         case 7: result = rtlRevUInt7(cur); break;
         case 8: result = rtlRevUInt8(cur); break;
+        default:
+            throwUnexpected();
         }
         if (isSigned && isMappedIndexField)
             result -= getIntBias(size);

+ 2 - 2
common/remote/sockfile.cpp

@@ -2732,7 +2732,7 @@ class CAsyncCommandManager
             }
             int run()
             {
-                int ret;
+                int ret = -1;
                 try {
                     ret = parent->run();
                     parent->setDone();
@@ -2910,7 +2910,7 @@ public:
                 cjob->start();
             }
         }
-        AsyncCommandStatus ret;
+        AsyncCommandStatus ret = ACSerror;
         Owned<IException> rete;
         try {
             ret = job->poll(done,total,timeout);

+ 2 - 0
common/thorhelper/thorparse.cpp

@@ -213,6 +213,8 @@ size32_t CMatchedResults::getMatchLength(unsigned idx)
     case NlpUnicode:
         len = size / sizeof(UChar);
         break;
+    default:
+        throwUnexpected();
     }
     return len;
 }

+ 1 - 1
common/thorhelper/thorsoapcall.cpp

@@ -1411,7 +1411,7 @@ private:
         size32_t payloadofs = 0;
         size32_t payloadsize = 0;
         StringBuffer dbgheader;
-        bool chunked;
+        bool chunked = false;
         size32_t read = 0;
         do {
             checkTimeLimitExceeded(&remainingMS);

+ 1 - 1
common/thorhelper/thortparse.cpp

@@ -86,7 +86,7 @@ Terminal::Terminal(symbol_id _id, const FeatureInfo * featureInfo, unsigned _len
 NonTerminal::NonTerminal(symbol_id _id, IAtom * _name, FeatureValue & _features, unsigned numSymbols, GrammarSymbol * * symbols, const byte * _reducePtr, size32_t _resultSize, byte * _resultRow) : GrammarSymbol(_id), resultSize(_resultSize), resultRow(_resultRow)
 {
     unsigned nullCount = 0;
-    unsigned nonNullIndex;
+    unsigned nonNullIndex = 0;
     reduced.ensure(numSymbols);
     for (unsigned i= 0; i < numSymbols; i++)
     {

+ 1 - 1
common/workunit/wujobq.cpp

@@ -829,7 +829,7 @@ public:
         IJobQueueItem *ret=NULL;
         bool waitingset = false;
         while (!dequeuestop) {
-            unsigned t;
+            unsigned t = 0;
             if (timeout!=(unsigned)INFINITE)
                 t = msTick();
             {

+ 2 - 2
dali/base/danqs.cpp

@@ -793,8 +793,8 @@ public:
         bool usingpriorities = root->getPropInt("@priorities",0)!=0;
         int priority;
         if (usingpriorities) {
-            int topidx;
-            int priority;
+            int topidx = 0;
+            int priority = 0;
             unsigned i = 0;
             Owned<IPropertyTree> topitem;
             {

+ 3 - 1
dali/base/dautils.cpp

@@ -2595,8 +2595,10 @@ public:
             mb.read(nm);
             s = (const char *)mb.readDirect(mb.length()-mb.getPos());
         }
-        else
+        else {
             nm = 0;
+            s = NULL;
+        }
         unsigned i;
         unsigned no = 0;
         mbout.append(no);

+ 5 - 1
dali/daliadmin/daliadmin.cpp

@@ -167,7 +167,11 @@ static const char *splitpath(const char *path,StringBuffer &head,StringBuffer &t
 static unsigned __int64 hextoll(const char *str, bool &error)
 {
     unsigned len = strlen(str);
-    if (!len) return 0;
+    if (!len)
+    {
+        error = true;
+        return 0;
+    }
 
     unsigned __int64 factor = 1;
     unsigned __int64 rolling = 0;

+ 1 - 1
dali/dalidiag/dalidiag.cpp

@@ -105,7 +105,7 @@ void timeQorSDS(bool timeq)
     MemoryBuffer mb;
     Owned<INamedQueueConnection> qconn;
     Owned<IRemoteConnection> sdsconn;
-    IPropertyTree *sdsroot;
+    IPropertyTree *sdsroot = NULL;
     Owned<IQueueChannel> channel;
     CTestSDSSubscription testsdssub;
     SubscriptionId sdssubid=0;

+ 1 - 1
dali/dfuXRefLib/dfurdir.cpp

@@ -176,7 +176,7 @@ public:
 IPropertyTree *getDirectory(const char * directory, INode * node, unsigned short port)
 {
     //DBGLOG("IPropertyTree * getDirectory");
-    unsigned retries;
+    unsigned retries = 0;
     loop {
         StringAttr nextDir;
         try {

+ 1 - 1
dali/sasha/sasha.cpp

@@ -143,7 +143,7 @@ void DumpWorkunitTimings(IPropertyTree *wu)
 {
     Owned<IFile> file;
     Owned<IFileIO> fileio;
-    offset_t filepos;
+    offset_t filepos = 0;
     const char *basename = "DaAudit.";
     StringBuffer curfilename;
     StringBuffer wuid;

+ 1 - 1
dali/sasha/saxref.cpp

@@ -1050,7 +1050,7 @@ public:
                     StringBuffer fn;
                     StringBuffer dir;
                     StringBuffer lastdir;
-                    cDirDesc *pdir;
+                    cDirDesc *pdir = NULL;
                     bool islost = false;
                     bool incluster = true;          
                     for (unsigned p=0;p<np;p++) {

+ 2 - 2
deployment/deploy/DeploymentEngine.cpp

@@ -2200,7 +2200,7 @@ bool CInstallFileMap::resolveConflicts(IPropertyTree& processNode, const char* m
         const_iterator iLower = lower_bound(destPath);
         const_iterator iUpper = upper_bound(destPath);
         offset_t srcSz = 0;
-        unsigned srcCRC;
+        unsigned srcCRC = 0;
 
         for (const_iterator it=iLower; it != iUpper; it++)
         {
@@ -2407,7 +2407,7 @@ void CDeploymentEngine::processCustomMethod(const char* method, const char *sour
 //---------------------------------------------------------------------------
 void CDeploymentEngine::siteCertificate(IPropertyTree& process, const char *instanceName, const char *outputFile)
 {
-    const char* pszCertFile;
+    const char* pszCertFile = NULL;
     const char* pszPrivFile;
     StringBuffer sPrivKey;
     StringBuffer sCertificate;

+ 5 - 5
ecl/hql/hqlfold.cpp

@@ -779,14 +779,14 @@ IValue * foldExternalCall(IHqlExpression* expr, unsigned foldOptions, ITemplateC
 #endif
     char* strbuf = fstack.getMem();
 
-    int intresult;
+    int intresult = 0;
 #ifdef __64BIT__
-    __int64 int64result;
+    __int64 int64result = 0;
 #else
-    int intresulthigh;
+    int intresulthigh = 0;
 #endif
-    float floatresult;
-    double doubleresult;
+    float floatresult = 0.0;
+    double doubleresult = 0.0;
 
 #ifdef __64BIT__
 //  __asm__ ("\tint $0x3\n"); // for debugging

+ 2 - 0
ecl/hqlcpp/hqlckey.cpp

@@ -1355,6 +1355,8 @@ ABoundActivity * HqlCppTranslator::doBuildActivityKeyedJoinOrDenormalize(BuildCt
     case no_denormalizegroup:
         kind = TAKkeyeddenormalizegroup;
         break;
+    default:
+        throwUnexpected();
     }
     Owned<ActivityInstance> instance = new ActivityInstance(*this, ctx, kind, expr, (op == no_join) ? "KeyedJoin" : "KeyedDenormalize");
 

+ 8 - 8
ecl/hqlcpp/hqlcpp.cpp

@@ -10248,6 +10248,7 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
             unsigned srclen = from->getSize();
             ICharsetInfo * srcset = NULL;
             ICharsetInfo * tgtset = to->queryCharset();
+            IIdAtom * func = NULL;
 
             switch (fromType)
             {
@@ -10282,7 +10283,6 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                             {
                                 if (fromType == type_varstring)
                                 {
-                                    IIdAtom * func;
                                     switch (toType)
                                     {
                                     case type_varstring: func = vstr2VStrId; break;
@@ -10308,7 +10308,6 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                                 }
                                 else
                                 {
-                                    IIdAtom * func;
                                     switch (toType)
                                     {
                                     case type_data:
@@ -10358,7 +10357,6 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                     }
                     else
                     {
-                        IIdAtom * func;
                         switch (toType)
                         {
                         case type_varstring: func = qstr2VStrId; break;
@@ -10376,7 +10374,6 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                 case type_unicode:
                 case type_varunicode:
                     {
-                        IIdAtom * func;
                         switch(toType)
                         {
                         case type_data:
@@ -10401,7 +10398,6 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                     break;
                 case type_utf8:
                     {
-                        IIdAtom * func;
                         switch(toType)
                         {
                         case type_data:
@@ -10479,7 +10475,6 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                         OwnedHqlExpr sp = getElementPointer(targetVar);
                         args.append(*ensureIndexable(sp));
 
-                        IIdAtom * func;
                         switch (toType)
                         {
                         case type_string: func = DecPopStringId; break;
@@ -10494,7 +10489,7 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                     break;
                 case type_boolean:
                     {
-                        IIdAtom * func = (toType == type_varstring) ? bool2VStrId : (toType == type_data) ? bool2DataId : bool2StrId;
+                        func = (toType == type_varstring) ? bool2VStrId : (toType == type_data) ? bool2DataId : bool2StrId;
                         args.append(*getSizetConstant(toSize));
                         args.append(*getElementPointer(targetVar));
                         args.append(*pure.expr.getLink());
@@ -10507,7 +10502,7 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                         args.append(*strlen);
                         args.append(*getElementPointer(targetVar));
                         args.append(*pure.expr.getLink());
-                        IIdAtom * func = (toType == type_varstring) ? f2vnId : f2anId;
+                        func = (toType == type_varstring) ? f2vnId : f2anId;
                         callProcedure(ctx, func, args);
                         if (toType != type_data)
                         {
@@ -10563,6 +10558,8 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                     }
                     func = utf82UnicodeId;
                     break;
+                default:
+                    throwUnexpected();
                 }
                 args.append(*getSizetConstant(toSize/2));
                 args.append(*getElementPointer(targetVar));
@@ -10606,6 +10603,8 @@ void HqlCppTranslator::assignAndCast(BuildCtx & ctx, const CHqlBoundTarget & tar
                 case type_varstring:
                     func = codepageToUtf8Id;
                     break;
+                default:
+                    throwUnexpected();
                 }
                 args.append(*getSizetConstant(toSize/4));
                 args.append(*getElementPointer(targetVar));
@@ -11931,6 +11930,7 @@ IHqlExpression * HqlCppTranslator::getIndexedElementPointer(IHqlExpression * sou
 
 IHqlExpression * HqlCppTranslator::needFunction(IIdAtom * name)
 {
+    assertex(name);
     HqlDummyLookupContext dummyctx(errors);
     return internalScope->lookupSymbol(name, LSFsharedOK, dummyctx);
 }

+ 1 - 1
ecl/hqlcpp/hqlcpp.ipp

@@ -853,7 +853,7 @@ public:
 
 // Helper functions
 
-    void ThrowStringException(int code,const char *format, ...) __attribute__((format(printf, 3, 4)));            // override the global function to try and add more context information
+    void ThrowStringException(int code,const char *format, ...) __attribute__((format(printf, 3, 4), noreturn));            // override the global function to try and add more context information
 
     void buildAddress(BuildCtx & ctx, IHqlExpression * expr, CHqlBoundExpr & tgt);
     void buildBlockCopy(BuildCtx & ctx, IHqlExpression * tgt, CHqlBoundExpr & src);

+ 1 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -4909,7 +4909,7 @@ void HqlCppTranslator::buildGetResultInfo(BuildCtx & ctx, IHqlExpression * expr,
     case type_row:      UNIMPLEMENTED; break; //should be translated to rawData.
     default:
         PrintLog("%d", ttc);
-        assertex(!"No getResult defined for this type");
+        throwUnexpectedX("No getResult defined for this type");
         break;
     }
 

+ 1 - 1
ecl/hthor/hthorkey.cpp

@@ -3706,7 +3706,7 @@ public:
                 case TAKkeyedjoin:
                 case TAKkeyeddenormalizegroup:
                     {
-                        size32_t transformedSize;
+                        size32_t transformedSize = 0;
                         try
                         {
                             RtlDynamicRowBuilder rowBuilder(rowAllocator);

+ 1 - 1
esp/bindings/SOAP/xpp/xpp/xpputils.cpp

@@ -52,7 +52,7 @@ IMultiException *xppMakeException(XmlPullParser &xppx)
     }
 
     IMultiException * me = MakeMultiException(sourcestr.str());
-    me->append(*MakeStringException(code, msg.str()));
+    me->append(*MakeStringExceptionDirect(code, msg.str()));
 
     return me;
 }

+ 3 - 0
esp/services/WsDeploy/WsDeployService.cpp

@@ -1170,6 +1170,9 @@ bool CWsDeployFileInfo::saveSetting(IEspContext &context, IEspSaveSettingRequest
                   pBuildSet->addProp(XML_ATTR_SCHEMA, "directories.xsd");
                   pBuildSet->addProp(XML_ATTR_PROCESS_NAME, "Directories");
                 }
+                else
+                    throwUnexpected();
+
                 const char* buildSetName = pBuildSet->queryProp(XML_ATTR_NAME);
                 const char* processName = pBuildSet->queryProp(XML_ATTR_PROCESS_NAME);
 

+ 1 - 1
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -366,7 +366,7 @@ void WsWuInfo::getTimers(IEspECLWorkunit &info, unsigned flags)
     try
     {
         StringBuffer totalThorTimeValue;
-        unsigned totalThorTimerCount; //Do we need this?
+        unsigned totalThorTimerCount = 0; //Do we need this?
 
         IArrayOf<IEspECLTimer> timers;
         Owned<IStringIterator> it = &cw->getTimers();

+ 1 - 1
esp/services/ws_workunits/ws_workunitsQuerySets.cpp

@@ -918,7 +918,7 @@ bool addWUQSQueryFilterInt(WUQuerySortField *filters, unsigned short &count, Mem
 
 bool addWUQSQueryFilterInt64(WUQuerySortField *filters, unsigned short &count, MemoryBuffer &buff, __int64 value, WUQuerySortField name)
 {
-    VStringBuffer vBuf("%ld", value);
+    VStringBuffer vBuf("%"I64F"d", value);
     filters[count++] = name;
     buff.append(vBuf.str());
     return true;

+ 1 - 1
plugins/fileservices/fileservices.cpp

@@ -394,7 +394,7 @@ FILESERVICES_API bool FILESERVICES_CALL fsFileValidate(ICodeContext *ctx, const
             IDistributedFilePart & part = partIter->query();
             unsigned numCopies = part.numCopies();
             bool gotone = false;
-            offset_t partSize;
+            offset_t partSize = (offset_t)-1;
             for (unsigned copy=0; copy < numCopies; copy++)
             {
                 RemoteFilename remote;

+ 1 - 1
plugins/javaembed/javaembed.cpp

@@ -912,7 +912,7 @@ protected:
     jvalue result;
 private:
 
-    void typeError(const char *ECLtype)
+    void typeError(const char *ECLtype) __attribute__((noreturn))
     {
         const char *javaType;
         int javaLen = 0;

+ 2 - 2
roxie/ccd/ccddali.cpp

@@ -349,8 +349,8 @@ public:
     CRoxieDaliHelper() : connectWatcher(this), serverStatus(NULL)
     {
         userdesc.setown(createUserDescriptor());
-        const char *roxieUser;
-        const char *roxiePassword;
+        const char *roxieUser = NULL;
+        const char *roxiePassword = NULL;
         if (topology)
         {
             roxieUser = topology->queryProp("@ldapUser");

+ 1 - 1
roxie/ccd/ccdlistener.cpp

@@ -746,7 +746,7 @@ public:
     {
         bool allowed = true;
         StringBuffer errorMsg;
-        int errorCode;
+        int errorCode = -1;
         ForEachItemIn(idx, accessTable)
         {
             AccessTableEntry &item = accessTable.item(idx);

+ 1 - 1
roxie/roxieclient/roxieclient.cpp

@@ -35,7 +35,7 @@ int CDataInputCache::readInput()
     if(inputstream == NULL)
         return 0;
 
-    int bytes;
+    int bytes = 0;
     if(input->record_width > 0)
     {
         char* inbuf = (char*)buffer.str();

+ 1 - 1
roxie/roxiepipe/roxiepipe.cpp

@@ -118,7 +118,7 @@ public:
     {
         synchronized procedure(readMutex);
 
-        int bytesRead;
+        int bytesRead = 0;
         inputLen = 0;
         while ((inputLen < bytesPerQuery) && (bytesRead = read(0, inputBuffer+inputLen, bytesPerQuery-inputLen)) > 0)
             inputLen += bytesRead;

+ 1 - 1
roxie/udplib/uttest.cpp

@@ -442,7 +442,7 @@ public:
 
     int requestToSend(int sendingNode)
     {
-        int receivingNode;
+        int receivingNode = 0;
         if (simpleSequential)
         {
             {

+ 2 - 0
rtl/eclrtl/eclrtl.cpp

@@ -5280,6 +5280,8 @@ ECLRTL_API void xmlDecodeUStrX(size32_t & outLen, UChar * & out, size32_t inLen,
                         digit = next-'a'+10;
                     else if (next==';')
                         break;
+                    else
+                        digit = base;
                     if (digit >= base)
                     {
                         error = true;

+ 11 - 6
rtl/eclrtl/eclrtl.hpp

@@ -41,6 +41,11 @@
 #define ECLRTL_API
 #endif
 
+#ifdef _MSC_VER
+#undef __attribute__ // in case platform.h has been included
+#define __attribute__(param) /* do nothing */
+#endif
+
 #ifndef I64C
 #ifdef _WIN32
 #define I64C(n) n##i64
@@ -377,12 +382,12 @@ ECLRTL_API unsigned rtlCrcVUnicode(UChar const * k, unsigned initval);
 
 ECLRTL_API unsigned rtlRandom();
 ECLRTL_API void rtlSeedRandom(unsigned value);
-ECLRTL_API void rtlFail(int code, const char *msg);
-ECLRTL_API void rtlSysFail(int code, const char *msg);
-ECLRTL_API void rtlFailUnexpected();
-ECLRTL_API void rtlFailOnAssert();
-ECLRTL_API void rtlFailDivideByZero();
-ECLRTL_API void rtlThrowOutOfMemory(int code, const char *msg);
+ECLRTL_API void rtlFail(int code, const char *msg) __attribute__((noreturn));
+ECLRTL_API void rtlSysFail(int code, const char *msg) __attribute__((noreturn));
+ECLRTL_API void rtlFailUnexpected() __attribute__((noreturn));
+ECLRTL_API void rtlFailOnAssert() __attribute__((noreturn));
+ECLRTL_API void rtlFailDivideByZero() __attribute__((noreturn));
+ECLRTL_API void rtlThrowOutOfMemory(int code, const char *msg) __attribute__((noreturn));
 
 ECLRTL_API void rtlReportFieldOverflow(unsigned size, unsigned max, const char * name);
 ECLRTL_API void rtlReportRowOverflow(unsigned size, unsigned max);

+ 1 - 1
system/hrpc/hrpc.cpp

@@ -305,7 +305,7 @@ struct SafeInc
 };
 void HRPCcommon::doproxy(HRPCcallframe &frame,int fn,IHRPCtransport *tr,HRPCbuffer &buff,HRPCbuffer &rbuff,int cb,int locked)
 {
-    unsigned duetime;
+    unsigned duetime = 0;
     if (timelimit)
         duetime = msTick()+timelimit;
     size32_t base=buff.markwrite();

+ 2 - 2
system/jhtree/ctfile.cpp

@@ -648,8 +648,8 @@ void CJHTreeNode::unpack(const void *node, bool needCopy)
                 }
 
                 // this is where next row gets data from
-                const char *prev, *next;
-                unsigned prevOffset;
+                const char *prev, *next = NULL;
+                unsigned prevOffset = 0;
                 if (handleVariable)
                     prevOffset = target-((char *)keyBufMb.bufferBase());
                 else

+ 1 - 1
system/jhtree/keydiff.cpp

@@ -1132,7 +1132,7 @@ private:
         bool eosold = !readOld();
         while(true)
         {
-            int cmp;
+            int cmp = -1;
             unsigned skipcount = 0;
             size32_t doc = (size32_t)-1;
             while (!eosold&&(skipcount < CKeyDiff::MAX_SKIP))

+ 1 - 1
system/jlib/jdebug.cpp

@@ -2496,7 +2496,7 @@ void printProcMap(const char *fn, bool printbody, bool printsummary, StringBuffe
                     else
                         PROGLOG("%08"I64F"x,%08"I64F"x,%"I64F"d,%08"I64F"x,%s,%s",start,end,(offset_t)(end-start),offset,perms,path);
                 }
-                SegTypes t;
+                SegTypes t = segtype_data;
                 if (strcmp(perms,"---p")==0)
                     t = segtype_guard;
                 else if (strcmp(perms,"rwxp")==0) {

+ 1 - 1
system/jlib/jexcept.hpp

@@ -72,7 +72,7 @@ IException jlib_decl *MakeStringExceptionDirect(int code,const char *why);
 IException jlib_decl *MakeStringException(MessageAudience aud,int code,const char *why, ...) __attribute__((format(printf, 3, 4)));
 IException jlib_decl *MakeStringExceptionVA(MessageAudience aud,int code,const char *why, va_list args);
 IException jlib_decl *MakeStringExceptionDirect(MessageAudience aud,int code,const char *why);
-void jlib_decl ThrowStringException(int code,const char *format, ...) __attribute__((format(printf, 2, 3)));
+void jlib_decl ThrowStringException(int code,const char *format, ...) __attribute__((format(printf, 2, 3), noreturn));
 
 interface jlib_thrown_decl IOSException: extends IException{};
 IOSException jlib_decl *MakeOsException(int code);

+ 4 - 2
system/jlib/jfile.cpp

@@ -2395,7 +2395,7 @@ public:
 
     void seek(offset_t pos, IFSmode origin)
     {
-        offset_t newOffset;
+        offset_t newOffset = 0;
         switch (origin)
         {
         case IFScurrent:
@@ -2407,6 +2407,8 @@ public:
         case IFSbegin:
             newOffset = pos;
             break;
+        default:
+            throwUnexpected();
         }
 
         if (reading)
@@ -2798,7 +2800,7 @@ void doCopyFile(IFile * target, IFile * source, size32_t buffersize, ICopyFilePr
     void * buffer = copyintercept?NULL:mb.allocate(buffersize);
     
     offset_t offset = 0;
-    offset_t total; 
+    offset_t total = 0;
     Owned<IException> exc;
     try
     {

+ 1 - 0
system/jlib/jlzw.cpp

@@ -1015,6 +1015,7 @@ public:
         b=(const byte *)prev;
         state = S_pre_repeat;
         rs = _rs;
+        cnt = 0;
     }
 
     inline void skip(size32_t sz)

+ 1 - 1
system/jlib/jmisc.cpp

@@ -898,7 +898,7 @@ void throwExceptionIfAborting()
 StringBuffer & hexdump2string(byte const * in, size32_t inSize, StringBuffer & out)
 {
     out.append("[");
-    byte last;
+    byte last = 0;
     unsigned seq = 1;
     for(unsigned i=0; i<inSize; ++i)
     {

+ 2 - 2
system/jlib/jregexp.cpp

@@ -280,7 +280,7 @@ bool RegExpr::init(const char *exp,bool nocase)
       re->mlen = (size32_t)len;
     }
   }
-  int reloc;
+  int reloc = 0;
   if (re->must)
     reloc = re->must-re->program;
   re->program = (char *)realloc(re->program,(re->code-re->program)+1);
@@ -524,7 +524,7 @@ char *RECOMP::reg (bool paren, REGFLAGS &flags)
   char *ret;
   char *br;
   char *ender;
-  int parno;
+  int parno = 0;
 
   flags = HASWIDTH;  /* Tentatively. */
 

+ 10 - 10
system/jlib/jsocket.cpp

@@ -1539,7 +1539,7 @@ void CSocket::read(void* buf, size32_t min_size, size32_t max_size, size32_t &si
     unsigned startt=usTick();
     size_read = 0;
     unsigned start;
-    unsigned timeleft;
+    unsigned timeleft = 0;
     if (state != ss_open) {
         THROWJSOCKEXCEPTION(JSOCKERR_not_opened);
     }
@@ -1895,7 +1895,7 @@ EintrRetry:
     i = 0;
     size32_t os = 0;
     size32_t left = total;
-    byte *b;
+    byte *b = NULL;
     size32_t s=0;
     loop {
         while (!s&&(i<num)) {
@@ -1940,8 +1940,8 @@ bool CSocket::send_block(const void *blk,size32_t sz)
 {
     unsigned startt=usTick();
 #ifdef TRACE_SLOW_BLOCK_TRANSFER
-    unsigned startt2;
-    unsigned startt3;
+    unsigned startt2 = startt;
+    unsigned startt3 = startt;
 #endif
     if (blockflags&BF_SYNC_TRANSFER_PULL) {
         size32_t rd;
@@ -3920,11 +3920,11 @@ public:
             T_FD_SET wrfds;
             T_FD_SET exfds;
             timeval selecttimeout;
-            bool isrd;
-            bool iswr;
-            bool isex;
-            T_SOCKET maxsockid;
-            unsigned ni;
+            bool isrd = false;
+            bool iswr = false;
+            bool isex = false;
+            T_SOCKET maxsockid = 0;
+            unsigned ni = 0;
             selectvarschange = true;
             unsigned numto = 0;
             unsigned lastnumto = 0;
@@ -4298,7 +4298,7 @@ public:
         assertex(!sock);
         ISocket *newsock=NULL;
         state = Sconnect;
-        unsigned start;
+        unsigned start = 0;
         if (timeoutms!=(unsigned)INFINITE)
             start = msTick();
         while (state==Sconnect) {

+ 2 - 0
system/jlib/jsort.cpp

@@ -305,6 +305,8 @@ class cParQSortBase
             NonReentrantSpinUnblock unblock(joblock);
             jobqsem.wait();
         }
+        s = 0; // remove uninitialised variable warnings
+        n = 0;
         return false;
     }
 

+ 2 - 0
system/security/LdapSecurity/ldapsecurity.cpp

@@ -521,6 +521,8 @@ void CLdapSecManager::init(const char *serviceName, IPropertyTree* cfg)
         pp = new CIPlanetAciProcessor(cfg);
     else if(ldap_client->getServerType() == OPEN_LDAP)
         pp = new COpenLdapAciProcessor(cfg);
+    else
+        throwUnexpected();
 
     ldap_client->init(pp);
     pp->setLdapClient(ldap_client);

+ 1 - 1
thorlcr/activities/indexread/thindexread.cpp

@@ -87,7 +87,7 @@ protected:
         }
         unsigned width = f->numParts()-1;
         assertex(width);
-        unsigned tlkCrc;
+        unsigned tlkCrc = 0;
         bool first = true;
         unsigned superSubIndex=0;
         bool fileCrc = false, rowCrc = false;

+ 1 - 1
thorlcr/activities/msort/thsortu.cpp

@@ -1479,7 +1479,7 @@ public:
     {
         MemoryBuffer rmatchedbuf;  
         CThorExpandingRowArray &rgroup = selfJoin?work.lgroup:work.rgroup;
-        bool *rmatched;
+        bool *rmatched = NULL;
         if (rightouter) {
             rmatched = (bool *)rmatchedbuf.clear().reserve(rgroup.ordinality());
             memset(rmatched,0,rgroup.ordinality());

+ 1 - 1
thorlcr/activities/thdiskbase.cpp

@@ -392,7 +392,7 @@ const void *getAggregate(CActivityBase &activity, unsigned partialResults, IRowI
         }
     }
     RtlDynamicRowBuilder result(rowIf.queryRowAllocator(), false);
-    size32_t sz;
+    size32_t sz = 0;
     bool first = true;
     _partialResults = 0;
     for (;_partialResults<partialResults; _partialResults++)

+ 1 - 1
thorlcr/msort/tsorta.cpp

@@ -344,7 +344,7 @@ int CThorKeyArray::binchopPartition(const void * row,bool lt)
         return -1;
     int a = 0;
     int b = n;
-    int cmp;
+    int cmp = 0;
 #ifdef _TESTING
 try {
 #endif

+ 4 - 4
tools/copyexp/copyexp.cpp

@@ -134,8 +134,8 @@ int copyExpanded(const char *from, const char *to, bool stats)
         printf("ERROR: file '%s' already exists\n",to);
         doexit(4);
     }
-    unsigned start;
-    unsigned startu;
+    unsigned start = 0;
+    unsigned startu = 0;
     if (stats) {
          start = msTick();
          startu = usTick();
@@ -240,8 +240,8 @@ void copyCompress(const char *from, const char *to, size32_t rowsize, bool fast,
         printf("ERROR: file '%s' already exists\n",to);
         doexit(4);
     }
-    unsigned start;
-    unsigned startu;
+    unsigned start = 0;
+    unsigned startu = 0;
     if (stats) {
          start = msTick();
          startu = usTick();