OSDN Git Service

Cppcheck: Struct '...' has a constructor with 1 argument that is not explicit.
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 15 Aug 2016 06:33:20 +0000 (15:33 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 15 Aug 2016 06:33:20 +0000 (15:33 +0900)
Src/Common/MyCom.h
Src/Common/sizecbar.h
Src/CompareStats.cpp
Src/DiffItem.h
Src/DirActions.h
Src/DirScan.cpp

index e94f5bc..a8ae7ec 100644 (file)
@@ -17,8 +17,8 @@ class CMyComPtr
 public:\r
   // typedef T _PtrClass;\r
   CMyComPtr() { _p = NULL;}\r
-  CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }\r
-  CMyComPtr(const CMyComPtr<T>& lp)\r
+  explicit CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }\r
+  explicit CMyComPtr(const CMyComPtr<T>& lp)\r
   {\r
     if ((_p = lp._p) != NULL)\r
       _p->AddRef();\r
@@ -89,7 +89,7 @@ class CMyComBSTR
 public:\r
   BSTR m_str;\r
   CMyComBSTR(): m_str(NULL) {}\r
-  CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }\r
+  explicit CMyComBSTR(LPCOLESTR src) { m_str = ::SysAllocString(src); }\r
   // Move constructor\r
   explicit CMyComBSTR(BSTR *bstr): m_str(*bstr) { *bstr = NULL; }\r
   // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }\r
@@ -173,8 +173,8 @@ private:
        const CLIPFORMAT cf;\r
 public:\r
        operator CLIPFORMAT() const { return cf; }\r
-       CMyClipFormat(CLIPFORMAT cf) : cf(cf) { }\r
-       CMyClipFormat(LPCTSTR cfstr) : cf(RegisterClipboardFormat(cfstr)) { }\r
+       explicit CMyClipFormat(CLIPFORMAT cf) : cf(cf) { }\r
+       explicit CMyClipFormat(LPCTSTR cfstr) : cf(RegisterClipboardFormat(cfstr)) { }\r
 };\r
 \r
 class CMyFormatEtc : public FORMATETC\r
@@ -216,39 +216,39 @@ class CMyVariant : public VARIANT
 public:\r
        CMyVariant() { VariantInit(this); }\r
        ~CMyVariant() { VariantClear(this); }\r
-       CMyVariant(short value)\r
+       explicit CMyVariant(short value)\r
        {\r
                V_VT(this) = VT_I2;\r
                V_I2(this) = value;\r
        }\r
-       CMyVariant(long value)\r
+       explicit CMyVariant(long value)\r
        {\r
                V_VT(this) = VT_I4;\r
                V_I4(this) = value;\r
        }\r
-       CMyVariant(bool value)\r
+       explicit CMyVariant(bool value)\r
        {\r
                V_VT(this) = VT_BOOL;\r
                V_BOOL(this) = value ? VARIANT_TRUE : VARIANT_FALSE;\r
        }\r
-       CMyVariant(LPCOLESTR value)\r
+       explicit CMyVariant(LPCOLESTR value)\r
        {\r
                V_VT(this) = VT_BSTR;\r
                V_BSTR(this) = SysAllocString(value);\r
        }\r
-       CMyVariant(LPCOLESTR value, UINT len)\r
+       explicit CMyVariant(LPCOLESTR value, UINT len)\r
        {\r
                V_VT(this) = VT_BSTR;\r
                V_BSTR(this) = SysAllocStringLen(value, len);\r
        }\r
-       CMyVariant(IDispatch *value)\r
+       explicit CMyVariant(IDispatch *value)\r
        {\r
                V_VT(this) = VT_DISPATCH;\r
                V_DISPATCH(this) = value;\r
                if (value)\r
                        value->AddRef();\r
        }\r
-       CMyVariant(const CMyVariant &src)\r
+       explicit CMyVariant(const CMyVariant &src)\r
        {\r
                VariantInit(this);\r
 #if _MSC_VER < 1500 \r
index 1b8bf01..639a9cd 100644 (file)
@@ -198,7 +198,7 @@ class CSCBDockContext : public CDockContext
 {
 public:
 // Construction
-    CSCBDockContext(CControlBar* pBar) : CDockContext(pBar) {}
+    explicit CSCBDockContext(CControlBar* pBar) : CDockContext(pBar) {}
 
 // Drag Operations
     virtual void StartDrag(CPoint pt);
index 3af903f..90e4b00 100644 (file)
@@ -143,7 +143,7 @@ CompareStats::CMP_STATE CompareStats::GetCompareState() const
  */
 CompareStats::RESULT CompareStats::GetResultFromCode(unsigned diffcode) const
 {
-       DIFFCODE di = diffcode;
+       DIFFCODE di(diffcode);
        
        // Test first for skipped so we pick all skipped items as such 
        if (di.isResultFiltered())
index 483a256..348f89c 100644 (file)
@@ -59,7 +59,7 @@ struct DIFFCODE
 
        unsigned diffcode;
 
-       DIFFCODE(unsigned diffcode = 0) : diffcode(diffcode) { }
+       explicit DIFFCODE(unsigned diffcode = 0) : diffcode(diffcode) { }
 
 protected:
        /// Worker function, to check one area (mask) of code for a particular value (result)
index c012879..9980c07 100644 (file)
@@ -99,7 +99,7 @@ struct AllowUpwardDirectory
 struct DirViewFilterSettings
 {
        template<class GetOptionBool>
-       DirViewFilterSettings(GetOptionBool getoptbool)
+       explicit DirViewFilterSettings(GetOptionBool getoptbool)
        {
                show_skipped = getoptbool(OPT_SHOW_SKIPPED);
                show_unique_left = getoptbool(OPT_SHOW_UNIQUE_LEFT);
@@ -202,7 +202,7 @@ struct ConfirmationNeededException
 
 struct ContentsChangedException
 {
-       ContentsChangedException(const String& failpath);
+       explicit ContentsChangedException(const String& failpath);
        String m_msg;
 };
 
index 95744ec..09bc2ee 100644 (file)
@@ -886,7 +886,7 @@ static DIFFITEM *AddToList(const String& sLeftDir, const String& sMiddleDir, con
                        di->diffFileInfo[2].filename = ment->filename;
        }
 
-       di->diffcode = code;
+       di->diffcode.diffcode = code;
 
        myStruct->context->m_pCompareStats->IncreaseTotalItems();
        myStruct->pSemaphore->set();