Browse Source

HPCC-21879 Enable warnings on eclrtl

Found a couple of bugs - separate Jiras opened - in the process.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 6 years ago
parent
commit
1fd4d92f3f

+ 4 - 0
rtl/eclrtl/CMakeLists.txt

@@ -108,6 +108,10 @@ if (USE_ICU)
         )
 endif ()
 
+if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
+  SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-switch -Wno-unused-parameter -Werror -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual")
+endif()
+
 
 
 if (NOT PLUGIN)

+ 3 - 24
rtl/eclrtl/eclhelper_dyn.cpp

@@ -101,16 +101,6 @@ extern ECLRTL_API IOutputMetaData *createTypeInfoOutputMetaData(const char *json
 }
 //---------------------------------------------------------------------------------------------------------------------
 
-static int compareOffsets(const unsigned *a, const unsigned *b)
-{
-    if (*a < *b)
-        return -1;
-    else if (*a==*b)
-        return 0;
-    else
-        return 1;
-}
-
 class ECLRTL_API CDynamicDiskReadArg : public CThorDiskReadArg, implements IDynamicIndexReadArg
 {
 public:
@@ -162,6 +152,7 @@ public:
     }
     virtual unsigned __int64 getChooseNLimit() override final { return chooseN; }
     virtual unsigned __int64 getRowLimit() override final { return rowLimit; }
+    virtual unsigned __int64 getSkipN() final { return skipN; }   // Work in progress, not yet implemented
 // IDynamicIndexReadArg
     virtual void addFilter(const char *filter) override final
     {
@@ -187,7 +178,7 @@ class ECLRTL_API CDynamicIndexReadArg : public CThorIndexReadArg, implements IDy
 public:
     CDynamicIndexReadArg(const char *_fileName, IOutputMetaData *_in, IOutputMetaData *_projected, IOutputMetaData *_out,
                          unsigned __int64 _chooseN, unsigned __int64 _skipN, unsigned __int64 _rowLimit, IVirtualFieldCallback &_callback)
-        : fileName(_fileName), in(_in), projected(_projected), out(_out), chooseN(_chooseN), skipN(_skipN), rowLimit(_rowLimit), callback(_callback)
+        : fileName(_fileName), in(_in), projected(_projected), out(_out), callback(_callback), chooseN(_chooseN), skipN(_skipN), rowLimit(_rowLimit)
     {
         translator.setown(createRecordTranslator(out->queryRecordAccessor(true), in->queryRecordAccessor(true)));
 #ifdef _DEBUG
@@ -237,6 +228,7 @@ public:
     }
     virtual unsigned __int64 getChooseNLimit() override final { return chooseN; }
     virtual unsigned __int64 getRowLimit() override final { return rowLimit; }
+    virtual unsigned __int64 getSkipN() final { return skipN; }   // Work in progress, not yet implemented
 // IDynamicIndexReadArg
     virtual void addFilter(const char *filter) override final
     {
@@ -245,7 +237,6 @@ public:
 
 private:
     StringAttr fileName;
-    unsigned flags = 0;
     Owned<IOutputMetaData> in;
     Owned<IOutputMetaData> projected;
     Owned<IOutputMetaData> out;
@@ -269,18 +260,6 @@ private:
     Owned<IOutputMetaData> in;
 };
 
-static IOutputMetaData *loadTypeInfo(IPropertyTree &xgmml, const char *key)
-{
-    StringBuffer xpath;
-    MemoryBuffer binInfo;
-    xgmml.getPropBin(xpath.setf("att[@name='%s_binary']/value", key), binInfo);
-    assertex(binInfo.length());
-    bool grouped = xgmml.getPropBool(xpath.setf("att[@name='%s_binary']/value", key), false);
-
-    return new CDeserializedOutputMetaData(binInfo, grouped);
-}
-
-
 extern ECLRTL_API IHThorDiskReadArg *createDiskReadArg(const char *fileName, IOutputMetaData *in, IOutputMetaData *projected, IOutputMetaData *out, unsigned __int64 chooseN, unsigned __int64 skipN, unsigned __int64 rowLimit)
 {
     return new CDynamicDiskReadArg(fileName, in, projected, out, chooseN, skipN, rowLimit);

+ 2 - 2
rtl/eclrtl/eclhelper_dyn.hpp

@@ -31,8 +31,8 @@ interface IDynamicIndexReadArg
     virtual void addFilter(const char *filter) = 0;
 };
 
-extern ECLRTL_API IHThorDiskReadArg *createDiskReadArg(const char *fileName, IOutputMetaData *in, IOutputMetaData *projected, IOutputMetaData *out, unsigned __int64 chooseN, unsigned __int64 skipN, unsigned __int64 rowLimit);
-extern ECLRTL_API IHThorIndexReadArg *createIndexReadArg(const char *fileName, IOutputMetaData *in, IOutputMetaData *projecte, IOutputMetaData *out, unsigned __int64 chooseN, unsigned __int64 skipN, unsigned __int64 rowLimit, IVirtualFieldCallback &callback);
+//extern ECLRTL_API IHThorDiskReadArg *createDiskReadArg(const char *fileName, IOutputMetaData *in, IOutputMetaData *projected, IOutputMetaData *out, unsigned __int64 chooseN, unsigned __int64 skipN, unsigned __int64 rowLimit);
+//extern ECLRTL_API IHThorIndexReadArg *createIndexReadArg(const char *fileName, IOutputMetaData *in, IOutputMetaData *projecte, IOutputMetaData *out, unsigned __int64 chooseN, unsigned __int64 skipN, unsigned __int64 rowLimit, IVirtualFieldCallback &callback);
 extern ECLRTL_API IEclProcess* createDynamicEclProcess();
 
 #endif

+ 2 - 2
rtl/eclrtl/eclregex.cpp

@@ -269,11 +269,11 @@ private:
     bool            matched;
     RegexMatcher *  matcher;
     UnicodeString   sample;
-    unsigned        matchedSize = 0;
+    unsigned        matchedSize;
 
 public:
     CUStrRegExprFindInstance(RegexMatcher * _matcher, const UChar * _str, size32_t _from, size32_t _len)
-        : matcher(_matcher)
+        : matcher(_matcher), matchedSize(0)
     {
         matched = false;
 

+ 5 - 2
rtl/eclrtl/eclrtl.cpp

@@ -558,8 +558,9 @@ double rtlRoundTo(const double x, int places)
 {
     if (x < 0)
         return -rtlRoundTo(-x, places);
-    volatile double tt = x * kk;
-    double x0 = x + tt;
+// See HPCC-15557 and HPCC-21878 regarding the following two lines.
+//    volatile double tt = x * kk;
+//    double x0 = x + tt;
     if (places >= 0)
     {
         double scale = powerOfTen(places);
@@ -5100,6 +5101,7 @@ void rtlStrToUtf8X(size32_t & outlen, char * & out, size32_t inlen, const char *
     outlen = rtlUtf8Length(outsize, out);
 }
 
+#if U_ICU_VERSION_MAJOR_NUM<50
 static int rtlCompareUtf8Utf8ViaUnicode(size32_t llen, const char * left, size32_t rlen, const char * right, const char * locale)
 {
     rtlDataAttr uleft(llen*sizeof(UChar));
@@ -5108,6 +5110,7 @@ static int rtlCompareUtf8Utf8ViaUnicode(size32_t llen, const char * left, size32
     rtlUtf8ToUnicode(rlen, uright.getustr(), rlen, right);
     return rtlCompareUnicodeUnicode(llen, uleft.getustr(), rlen, uright.getustr(), locale);
 }
+#endif
 
 #ifdef _USE_ICU
 int rtlCompareUtf8Utf8(size32_t llen, const char * left, size32_t rlen, const char * right, const char * locale)

+ 1 - 1
rtl/eclrtl/rtldistr.cpp

@@ -181,7 +181,7 @@ class CFixedDistributionTable : public CDistributionTable
 {
 public:
     CFixedDistributionTable(const char *_fieldname, unsigned _ksize, unsigned _threshold) 
-        : CDistributionTable(_fieldname), threshold(_threshold), table(_ksize, false), ksize(_ksize)
+        : CDistributionTable(_fieldname), ksize(_ksize), threshold(_threshold), table(_ksize, false)
     {
         estimated = false;
         cardinality = 0;

+ 1 - 2
rtl/eclrtl/rtlds.cpp

@@ -694,7 +694,6 @@ extern ECLRTL_API unsigned __int64 rtlDictionaryCount(size32_t tableSize, const
 
 extern ECLRTL_API bool rtlDictionaryExists(size32_t tableSize, const byte **table)
 {
-    unsigned __int64 ret = 0;
     for (size32_t i = 0; i < tableSize; i++)
         if (table[i])
             return true;
@@ -1620,7 +1619,7 @@ const byte * RtlVariableDatasetCursor::select(unsigned idx)
 
 //---------------------------------------------------------------------------
 
-RtlLinkedDatasetCursor::RtlLinkedDatasetCursor(unsigned _numRows, const byte * * _rows) : numRows(_numRows), rows(_rows)
+RtlLinkedDatasetCursor::RtlLinkedDatasetCursor(unsigned _numRows, const byte * * _rows) : rows(_rows), numRows(_numRows)
 {
     cur = (unsigned)-1;
 }

+ 4 - 4
rtl/eclrtl/rtldynfield.cpp

@@ -824,7 +824,7 @@ private:
             type.readPacked(numFields);
             info.fieldsArray = new const RtlFieldInfo * [numFields+1];
             info.fieldsArray[numFields] = nullptr;
-            for (int n = 0; n < numFields; n++)
+            for (unsigned n = 0; n < numFields; n++)
             {
                 const char *fieldName;
                 type.read(fieldName);
@@ -959,7 +959,7 @@ extern ECLRTL_API void getFieldVal(size32_t & __lenResult,char * & __result, int
     if (column >= 0)
     {
         const RtlRecord &r = metaVal.queryRecordAccessor(true);
-        if (column < r.getNumFields())
+        if ((unsigned) column < r.getNumFields())
         {
             unsigned numOffsets = r.getNumVarFields() + 1;
             size_t * variableOffsets = (size_t *)alloca(numOffsets * sizeof(size_t));
@@ -1426,7 +1426,7 @@ private:
             const RtlTypeInfo *type = field->type;
             MatchInfo &info = matchInfo[idx];
             info.matchIdx = sourceRecInfo.getFieldNum(destRecInfo.queryName(idx));
-            if (info.matchIdx == -1)
+            if (info.matchIdx == (unsigned) -1)
             {
                 const byte * initializer = field->initializer;
                 info.matchType = isVirtualInitializer(initializer) ? match_virtual : match_none;
@@ -1692,7 +1692,7 @@ public:
         for (unsigned expectedIdx = 0; expectedIdx < expected.getNumFields(); expectedIdx++)
         {
             unsigned actualIdx = actual.getFieldNum(expected.queryName(expectedIdx));
-            if (actualIdx != -1)
+            if (actualIdx != (unsigned) -1)
             {
                 const RtlTypeInfo *expectedType = expected.queryType(expectedIdx);
                 const RtlTypeInfo *actualType = actual.queryType(actualIdx);

+ 1 - 1
rtl/eclrtl/rtlembed.hpp

@@ -28,7 +28,7 @@ class NullFieldProcessor : public CInterfaceOf<IFieldProcessor>
 public:
     NullFieldProcessor(const RtlFieldInfo * field)
     : intResult(0), uintResult(0), boolResult(false), doubleResult(0),
-      unicodeResult(NULL), stringResult(NULL), resultChars(0), fieldExpected(field)
+      stringResult(NULL), unicodeResult(NULL), resultChars(0), fieldExpected(field)
     {
         if (field && field->initializer && !isVirtualInitializer(field->initializer))
         {

+ 3 - 3
rtl/eclrtl/rtlkey.cpp

@@ -174,7 +174,7 @@ void CWildKeySegmentMonitor::endRange(void *bufptr) const
 }
 
 CSetKeySegmentMonitor::CSetKeySegmentMonitor(bool _optional, IStringSet *_set, unsigned _fieldIdx, unsigned _offset, unsigned _size)
-    : set(_set), CKeySegmentMonitor(_fieldIdx, _offset, _size)
+    : CKeySegmentMonitor(_fieldIdx, _offset, _size), set(_set)
 {
     optional = _optional;
 }
@@ -189,7 +189,7 @@ bool CSetKeySegmentMonitor::increment(void *bufptr) const
         bool res = set->inRange(ptr, nextTransition);
         if (!res)
         {
-            if (-1 == nextTransition) return false;
+            if ((unsigned) -1 == nextTransition) return false;
             set->getTransitionValue(ptr, nextTransition);
         }
     }
@@ -1393,7 +1393,7 @@ class LegacySetCreator : implements ISetCreator
 {
 public:
     LegacySetCreator(IStringSet & _set, size32_t _minRecordSize, const RtlTypeInfo * _fieldType)
-    : set(_set), minRecordSize(_minRecordSize), fieldType(_fieldType) {}
+    : set(_set), fieldType(_fieldType), minRecordSize(_minRecordSize) {}
 
     virtual void addRange(TransitionMask lowerMask, const StringBuffer & lowerString, TransitionMask upperMask, const StringBuffer & upperString) override
     {

+ 0 - 2
rtl/eclrtl/rtlnktest.cpp

@@ -1059,8 +1059,6 @@ protected:
             memcpy(row, buff.bufferBase(), offset);
             rows.append(row);
 
-            unsigned pf2 = f2;
-            unsigned pf3 = f3;
             if (++countf3 == numf3)
             {
                 f2++;

+ 1 - 1
rtl/include/eclhelper_base.hpp

@@ -1503,7 +1503,7 @@ class ECLRTL_API CLibraryConstantRawIteratorArg : public CThorLinkedRawIteratorA
 {
 public:
     inline CLibraryConstantRawIteratorArg(unsigned _numRows, const byte * * _rows, IOutputMetaData * _meta)
-        : numRows(_numRows), meta(_meta),  rows(_rows)
+        : numRows(_numRows), meta(_meta), rows(_rows)
     {
         cur = 0;
     }

+ 1 - 1
system/jlib/jhash.ipp

@@ -176,7 +176,7 @@ template <class VALUE_T,class VALINIT>
 class MappingConstStringTo : public CInterfaceOf<IAtom>
 {
 public:
-    MappingConstStringTo(const char *k, VALINIT a) : key(k), val(a), hash(0)
+    MappingConstStringTo(const char *k, VALINIT a) : hash(0), key(k), val(a)
     { };
 
     inline VALUE_T &            getValue()      { return val; };