Pārlūkot izejas kodu

Clean up more issues reported by cppcheck

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 13 gadi atpakaļ
vecāks
revīzija
287e533993

+ 3 - 7
rtl/eclrtl/eclrtl.cpp

@@ -433,7 +433,6 @@ void codepageBlankFill(char const * codepage, char * out, unsigned len)
     }
     else
     {
-        UConverter * conv = queryRTLUnicodeConverter(codepage)->query();
         unsigned blanklen;
         char * blank;
         rtlUnicodeToCodepageX(blanklen, blank, 1, &unicodeSpace, codepage);
@@ -4373,7 +4372,6 @@ void rtlUtf8ToUnicode(unsigned outlen, UChar * out, unsigned inlen, char const *
 ECLRTL_API void rtlUtf8SubStrFT(unsigned tlen, char * tgt, unsigned slen, char const * src, unsigned from, unsigned to)
 {
     normalizeFromTo(from, to);
-    unsigned len = to - from;
     clipFromTo(from, to, slen);
 
     unsigned copylen = to - from;
@@ -4416,7 +4414,6 @@ ECLRTL_API void rtlUtf8SubStrFX(unsigned & tlen, char * & tgt, unsigned slen, ch
 ECLRTL_API void rtlUtf8ToLower(size32_t l, char * t, char const * locale)
 {
     //Convert to lower case, but only go via unicode routines if we have to...
-    const byte * buffer = (const byte *)t;
     for (unsigned i=0; i< l; i++)
     {
         byte next = *t;
@@ -4582,7 +4579,7 @@ public:
                 matched = boost::regex_search(_str + _from, _str + _len, subs, *regEx);
             }
         }
-        catch (std::runtime_error e)
+        catch (const std::runtime_error & e)
         {
             throw MakeStringException(0, "Error in regex search: %s (regex: %s)", e.what(), regEx->str().c_str());
         }
@@ -4648,7 +4645,7 @@ public:
             else
                 regEx.assign(_regExp, boost::regbase::perl | boost::regbase::icase);                
         }
-        catch(boost::bad_expression e)
+        catch(const boost::bad_expression & e)
         {
             StringBuffer msg;
             msg.append("Bad regular expression: ").append(e.what()).append(": ").append(_regExp);
@@ -4668,7 +4665,7 @@ public:
 //          tgt = boost::regex_merge(src, cre->regEx, fmt, boost::format_perl); //Algorithm regex_merge has been renamed regex_replace, existing code will continue to compile, but new code should use regex_replace instead.
             tgt = boost::regex_replace(src, regEx, fmt, boost::format_perl);
         }
-        catch(std::runtime_error e)
+        catch(const std::runtime_error & e)
         {
             throw MakeStringException(0, "Error in regex replace: %s (regex: %s)", e.what(), regEx.str().c_str());
         }
@@ -5274,7 +5271,6 @@ ECLRTL_API void xmlDecodeUStrX(size32_t & outLen, UChar * & out, size32_t inLen,
 
 ECLRTL_API void xmlEncodeStrX(size32_t & outLen, char * & out, size32_t inLen, const char * in, unsigned flags)
 {
-    unsigned encodeFlags = 0;
     StringBuffer temp;
     encodeXML(in, temp, flags, inLen, false);
     outLen = temp.length();

+ 1 - 1
rtl/eclrtl/eclrtl_imp.hpp

@@ -55,7 +55,7 @@ public:
 private:
     //Force errors....
     inline rtlDataAttr(const rtlDataAttr &) {}
-    inline rtlDataAttr & operator = (const rtlDataAttr & other) { return *this; }
+    inline rtlDataAttr & operator = (const rtlDataAttr & other) { ptr = NULL; return *this; }
 
 protected:
     void * ptr;

+ 2 - 2
rtl/eclrtl/rtlds_imp.hpp

@@ -160,7 +160,7 @@ protected:
 private:
     //Force errors....
     inline rtlRowAttr(const rtlRowAttr &) {}
-    inline rtlRowAttr & operator = (const rtlRowAttr & other) { return *this; }
+    inline rtlRowAttr & operator = (const rtlRowAttr & other) { row = NULL; return *this; }
 
 protected:
     byte * row;
@@ -194,7 +194,7 @@ protected:
 private:
     //Force errors....
     inline rtlRowsAttr(const rtlRowsAttr &) {}
-    inline rtlRowsAttr & operator = (const rtlRowsAttr & other) { return *this; }
+    inline rtlRowsAttr & operator = (const rtlRowsAttr & other) { count = 0; rows = NULL; return *this; }
 
 public:
     unsigned count;

+ 1 - 1
rtl/eclrtl/rtlint.cpp

@@ -47,7 +47,7 @@ int rtlReadInt3(const void * data)                      { return (*(int *)data >
 __int64 rtlReadInt5(const void * data)                  { return (*(__int64 *)data >> 24); }
 __int64 rtlReadInt6(const void * data)                  { return (*(__int64 *)data >> 16); }
 __int64 rtlReadInt7(const void * data)                  { return (*(__int64 *)data >> 8); }
-unsigned rtlReadUInt3(const void * data)                { return (*(unsigned *)data >> 8; }
+unsigned rtlReadUInt3(const void * data)                { return (*(unsigned *)data >> 8); }
 unsigned __int64 rtlReadUInt5(const void * data)        { return (*(unsigned __int64 *)data >> 24); }
 unsigned __int64 rtlReadUInt6(const void * data)        { return (*(unsigned __int64 *)data >> 16); }
 unsigned __int64 rtlReadUInt7(const void * data)        { return (*(unsigned __int64 *)data >> 8); }

+ 1 - 1
rtl/eclrtl/rtlqstr.cpp

@@ -109,7 +109,7 @@ static const char compressXlat[256] =
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-#define compressQChar(c) compressXlat[c]
+#define compressQChar(c) compressXlat[(byte)c]
 
 #else
 

+ 1 - 1
rtl/eclrtl/rtlsize.cpp

@@ -215,7 +215,7 @@ void IfBlockOffsetInfo::setValid(bool nowValid)
         }
         else
         {
-            unsigned offset = getOffset();
+            //unsigned offset = getOffset();
             //copy from offset to end of record to end of record.
             //create a default for this level (and possibly any child records).
             //child nodes need to notice that values have been created/destroyed

+ 8 - 8
rtl/eclrtl/workflow.cpp

@@ -485,7 +485,7 @@ private:
     class ListItemPtr : public CInterface, implements IRuntimeWorkflowItemIterator
     {
     public:
-        ListItemPtr(ListItem * _start) : start(_start) {}
+        ListItemPtr(ListItem * _start) : start(_start) { ptr = NULL; }
         IMPLEMENT_IINTERFACE;
         virtual bool         first() { ptr = start; return isValid(); }
         virtual bool         isValid() { return ptr != NULL; }
@@ -733,7 +733,7 @@ bool WorkflowMachine::executeItem(unsigned wfid, unsigned scheduledWfid)
         catch(WorkflowException * ce)
         {
             if(ce->queryType() == WorkflowException::ABORT)
-                throw ce;
+                throw;
             reportContingencyFailure("SUCCESS", ce);
             ce->Release();
         }
@@ -764,11 +764,11 @@ bool WorkflowMachine::doExecuteItemDependency(IRuntimeWorkflowItem & item, unsig
     catch(WorkflowException * e)
     {
         if(e->queryType() == WorkflowException::ABORT)
-            throw e;
+            throw;
         if(!attemptRetry(item, dep, scheduledWfid))
         {
             handleFailure(item, e, true);
-            throw e;
+            throw;
         }
         e->Release();
     }
@@ -784,11 +784,11 @@ void WorkflowMachine::doExecuteItem(IRuntimeWorkflowItem & item, unsigned schedu
     catch(WorkflowException * ein)
     {
         if(ein->queryType() == WorkflowException::ABORT)
-            throw ein;
+            throw;
         if(!attemptRetry(item, 0, scheduledWfid))
         {
             handleFailure(item, ein, true);
-            throw ein;
+            throw;
         }
         ein->Release();
     }
@@ -914,7 +914,7 @@ bool WorkflowMachine::attemptRetry(IRuntimeWorkflowItem & item, unsigned dep, un
         {
             okay = false;
             if(ce->queryType() == WorkflowException::ABORT)
-                throw ce;
+                throw;
             reportContingencyFailure("RECOVERY", ce);
             ce->Release();
         }
@@ -963,7 +963,7 @@ void WorkflowMachine::handleFailure(IRuntimeWorkflowItem & item, WorkflowExcepti
         catch(WorkflowException * ce)
         {
             if(ce->queryType() == WorkflowException::ABORT)
-                throw ce;
+                throw;
             reportContingencyFailure("FAILURE", ce);
             ce->Release();
         }

+ 2 - 0
system/jlib/jmisc.hpp

@@ -294,8 +294,10 @@ private:
 
 class NoQuickEditSection
 {
+#ifdef _WIN32
     DWORD savedmode;
     bool saved;
+#endif
 public:
     NoQuickEditSection()
     {

+ 4 - 2
system/jlib/jsocket.hpp

@@ -104,9 +104,10 @@ public:
     size32_t getNetAddress(size32_t maxsz,void *dst) const;     // for internal use - returns 0 if address doesn't fit
     void setNetAddress(size32_t sz,const void *src);            // for internal use
 
-    inline void operator = ( const IpAddress &other )
+    inline IpAddress & operator = ( const IpAddress &other )
     {
         ipset(other);
+        return *this;
     }
 
 };
@@ -151,10 +152,11 @@ public:
     void getUrlStr(char * str, size32_t len) const;             // in form ip4:port or [ip6]:port
     StringBuffer &getUrlStr(StringBuffer &str) const;           // in form ip4:port or [ip6]:port
 
-    inline void operator = ( const SocketEndpoint &other )
+    inline SocketEndpoint & operator = ( const SocketEndpoint &other )
     {
         ipset(other);
         port = other.port;
+        return *this;
     }
 	bool operator == (const SocketEndpoint &other) const { return equals(other); }
 

+ 2 - 2
system/jlib/jthread.hpp

@@ -135,8 +135,8 @@ class CThreaded : public Thread
 {
     IThreaded *owner;
 public:
-    CThreaded(const char *name) : Thread(name) { }
-    void init(IThreaded *_owner) { owner = _owner; start(); }
+    inline CThreaded(const char *name) : Thread(name) { owner = NULL; }
+    inline void init(IThreaded *_owner) { owner = _owner; start(); }
     virtual int run() { owner->main(); return 1; }
 };