You are on page 1of 10

WinMerge

PVS-Studio
:
: 28.03.2012
, ,
, .

PVS-Studio /++. ,
WinMerge.
" Visual
Studio 2010 PVS-Studio " [1].
WinMerge,
PVS-Studio. .
, :
,
, . .
:
1) , ,
, .
2) .

[2].
. ,
WinMerge, . ,
. , PVS-Studio
. .


N1
BOOL CCrystalEditView::
DoDropText (....)
{
...

UINT cbData = (UINT) ::GlobalSize (hData);


UINT cchText = cbData / sizeof(TCHAR) - 1;
if (cchText < 0)
return FALSE;
...
}
PVS-Studio: V547 Expression 'cchText < 0' is always false. Unsigned type
value is never < 0. Merge ccrystaleditview.cpp 1135
GlobalSize() 0. ,
.
. 'cchText' 'unsigned'. , "cchText
< 0" . , :
UINT cbData = (UINT) ::GlobalSize (hData);
if (cbData < sizeof(TCHAR))
return FALSE;
UINT cchText = cbData / sizeof(TCHAR) - 1;

N2
bool isopenbrace (TCHAR c)
{
return c == _T ('{') || c == _T ('(') ||
c == _T ('[') || c == _T ('<');
}

bool isclosebrace (TCHAR c)


{
return c == _T ('}') || c == _T ('}') ||
c == _T (']') || c == _T ('>');
}
PVS-Studio: V501 There are identical sub-expressions to the left and to the
right of the '||' operator: c == L'}' || c == L'}' Merge ccrystaleditview.cpp 1556

isclosebrace() 'c' '}'.


isopenbrace(), , 'c'
')'.

N3
static HRESULT safeInvokeA(....)
{
HRESULT h;
...
// set h to FAILED
h = -1;
...
}
PVS-Studio: V543 It is odd that value '-1' is assigned to the variable 'h' of
HRESULT type. Merge plugins.cpp 992
-1 , HRESULT,
.
HRESULT - 32- , :
, . HRESULT
, S_OK, E_FAIL, E_ABORT . HRESULT
, SUCCEEDED, FAILED.
"-1" . - ,
0x80004005L (Unspecified failure). ,
"WinError.h".
:
V543 It is odd that value '-1' is assigned to the variable 'h' of HRESULT type. Merge plugins.cpp 1033

N4
int TimeSizeCompare::CompareFiles(....)
{
UINT code = DIFFCODE::SAME;
...
if (di.left.size != di.right.size)

{
code &= ~DIFFCODE::SAME;
code = DIFFCODE::DIFF;
}
...
}
PVS-Studio: V519 The 'code' variable is assigned values twice successively.
Perhaps this is a mistake. Check lines: 79, 80. Merge timesizecompare.cpp 80
, , .
WinMerge .
:
1) , , : "code |=
DIFFCODE::DIFF;".
2) . .

N5
BOOL CEditDropTargetImpl::
OnDrop (....)
{
bool bDataSupported = false;

m_pOwner->HideDropIndicator ();

if ((!m_pOwner) ||
(!(m_pOwner->QueryEditable ())) ||
(m_pOwner->GetDisableDragAndDrop ()))
...
}
PVS-Studio: V595 The 'm_pOwner' pointer was utilized before it was verified
against nullptr. Check lines: 1033, 1035. Merge ccrystaleditview.cpp 1033
"if ((!m_pOwner) ....)" 'm_pOwner' .
, ,

'm_pOwner->HideDropIndicator()'. ,
.

N6
BCMenu *BCMenu::FindMenuOption(int nId, UINT& nLoc)
{
...
nLoc = -1;
...
}

BOOL BCMenu::ModifyODMenuW(....)
{
UINT nLoc;
...
BCMenu *psubmenu = FindMenuOption(nID,nLoc);
...
if (psubmenu && nLoc>=0)
mdata = psubmenu->m_MenuList[nLoc];
...
}
PVS-Studio: V547 Expression 'nLoc >= 0' is always true. Unsigned type value
is always >= 0. Merge bcmenu.cpp 1232
FindMenuOption() 'nLoc'
-1. 'nLoc' ,
0xFFFFFFFFu.
ModifyODMenuW(). "nLoc>=0" .
, , FindMenuOption() -1, .
:
V547 Expression 'nLoc >= 0' is always true. Unsigned type value is always >= 0. Merge bcmenu.cpp 1263
V547 Expression 'nLoc >= 0' is always true. Unsigned type value is always >= 0. Merge bcmenu.cpp 1285

V547 Expression 'nLoc >= 0' is always true. Unsigned type value is always >= 0. Merge bcmenu.cpp 1309
V547 Expression 'loc >= 0' is always true. Unsigned type value is always >= 0. Merge bcmenu.cpp 1561
V547 Expression 'nLoc >= 0' is always true. Unsigned type value is always >= 0. Merge bcmenu.cpp 2409

N7
CompareOptions, ,
. , , DiffutilsOptions.
, ,
, , .
PVS-Studio: V599 The virtual destructor is not present, although the
'CompareOptions' class contains virtual functions. Merge diffcontext.cpp 90
, .
, PVS-Studio
, . ,
, : V599. The virtual
destructor is not present, although the 'Foo' class contains virtual functions.

N8
static void StoreDiffData(....)
{
...
GetLog()->Write
(
CLogFile::LCOMPAREDATA,
_T("name=<%s>, leftdir=<%s>, rightdir=<%s>, code=%d"),
di.left.filename.c_str(),
di.left.path.c_str(),
di.right.path.c_str(), di.diffcode
);
pCtxt->m_pCompareStats->AddItem(di.diffcode.diffcode);
...
}

PVS-Studio: V510 The 'Write' function is not expected to receive class-type


variable as sixth actual argument. Merge dirscan.cpp 565
'di.diffcode' DIFFCODE. ,
:
CLogFile::LCOMPAREDATA, _T(...., di.diffcode.diffcode);

N9
static DIFFITEM *AddToList(....,
const DirItem * lent, const DirItem * rent,
....)
{
...
if (lent)
{
...
}
else
{
di->left.filename = rent->filename;
}

if (rent)
{
...
}
PVS-Studio: V595 The 'rent' pointer was utilized before it was verified against
nullptr. Check lines: 608, 611. Merge dirscan.cpp 608
'rent' .
. , "if (rent)" ,
.

N10
String FileFilterHelper::ParseExtensions(....) const
{
String strParsed;
String strPattern;
...
strParsed = _T("^");
strPattern = string_makelower(strPattern);
strParsed = strPattern;
...
}
PVS-Studio: V519 The 'strParsed' variable is assigned values twice
successively. Perhaps this is a mistake. Check lines: 339, 342. Merge filefilterhelper.cpp 342
'strParsed' .
. .

N11
void CLogFile::EnableLogging(BOOL bEnable)
{
...
Write(_T("Path: %s\n*******\n"), m_strLogPath);
...
}
PVS-Studio: V510 The 'Write' function is not expected to receive class-type
variable as second actual argument. Merge logfile.cpp 85
'm_strLogPath' std::wstring. , .
:
Write(_T("Path: %s\n*******\n"), m_strLogPath.c_str());

N12
void CMergeDoc::Computelinediff(

CCrystalTextView * pView1, CCrystalTextView * pView2,


....)
{
...
if (pView1->GetTextBufferEol(line) !=
pView1->GetTextBufferEol(line))
...
}
PVS-Studio: V501 There are identical sub-expressions 'pView1>GetTextBufferEol(line)' to the left and to the right of the '!=' operator. Merge mergedoclinediffs.cpp
216
'pView1'. , ,
:
if (pView1->GetTextBufferEol(line) !=
pView2->GetTextBufferEol(line))

N13
void CSplashWnd::OnPaint()
{
...
String text = LoadResString(IDS_SPLASH_DEVELOPERS);

// avoid dereference of empty strings and


// the NULL termiated character
if (text.length() >= 0)
{
...
}
PVS-Studio: V547 Expression 'text.length() >= 0' is always true. Unsigned
type value is always >= 0. Merge splash.cpp 262

"text.length() >= 0" . 'String' 'std::wstring'.


'std::wstring::length()' 0.

N14
void CPreferencesDlg::AddPage(CPropertyPage* pPage, ....)
{
...
m_tcPages.SetItemData(hti, (DWORD)pPage);
...
}
PVS-Studio: V205 Explicit conversion of pointer type to 32-bit integer type:
(DWORD) pPage Merge preferencesdlg.cpp 200
( ) 64- , ,
'pPage', .
, 32- 'DWORD'.
:
m_tcPages.SetItemData(hti, (DWORD_PTR)pPage);

.
. , PVS-Studio .
,
: http://www.viva64.com/ru/pvs-studio-download/.

,
" ,
" [3]. ,
.


1. . Visual Studio 2010
PVS-Studio .
http://www.viva64.com/ru/a/0073/
2. . . http://www.viva64.com/ru/b/0105/
3. . , .
http://www.viva64.com/ru/b/0132/