Вы находитесь на странице: 1из 9

Notepad++

:
: 13.02.2012
, Notepad++ PVS-Studio. ,
PVS-Studio , Notepad++
.

, Notepad++ 31 2012.
PVS-Studio 4.54.

, . , - . , . .
, Notepad++
PVS-Studio . -
Notepad++,
PVS-Studio .
,
.
, , ,
_iContMap. :
memset(_iContMap, -1, CONT_MAP_MAX);

:
memset(_iContMap, -1, CONT_MAP_MAX * sizeof(int));

, :
bool isPointValid() {
return _isPointXValid && _isPointXValid;
};
PVS-Studio:
V501 There are identical sub-expressions to the left and to the right of the '&&' operator: _isPointXValid
&& _isPointXValid Notepad++ parameters.h 166
, .
, PVS-Studio :
, , ,
. ,
opensource-.


N1.
int encodings[] = {
1250,
1251,
1252,
....
};

BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(


UINT Message, WPARAM wParam, LPARAM)
{
...
for (int i = 0 ; i <= sizeof(encodings)/sizeof(int) ; i++)
{
int cmdID = em->getIndexFromEncoding(encodings[i]);
...
}

PVS-Studio:
V557 Array overrun is possible. The value of 'i' index could reach 46. Notepad++ preferencedlg.cpp 984
"encodings".
.
. , "<=" "<". :
for (int i = 0 ; i < sizeof(encodings)/sizeof(int) ; i++)

N2.
typedef struct tagTVITEMA {
...
LPSTR

pszText;

...
} TVITEMA, *LPTVITEMA;

#define TVITEM TVITEMA

HTREEITEM TreeView::addItem(...)
{
TVITEM tvi;
...
tvi.cchTextMax =
sizeof(tvi.pszText)/sizeof(tvi.pszText[0]);
...
}
PVS-Studio:
V514 Dividing sizeof a pointer 'sizeof (tvi.pszText)' by another value. There is a probability of logical
error presence. Notepad++ treeview.cpp 88
"sizeof(tvi.pszText)/sizeof(tvi.pszText[0])".
. .
, .

N3. ,
size_t Printer::doPrint(bool justDoIt)
{
...
TCHAR headerM[headerSize] = TEXT("");
...
if (headerM != '\0')
...
}
PVS-Studio:
V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant: *headerM !=
'\0'. Notepad++ printer.cpp 380
. '\0'.
, . :
if (*headerM != '\0')

:
V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant: *headerR !=
'\0'. Notepad++ printer.cpp 392

N4.
DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
{
...
const char *text2display = ...;
...
if (text2display[i] == ' ' && text2display[i] == '.')
...
}
PVS-Studio:
V547 Expression is always false. Probably the '||' operator should be used here. Notepad++
notepad_plus.cpp 4967

(text2display[i] == ' ' && text2display[i] == '.') .


.
:
if (text2display[i] == ' ' || text2display[i] == '.')

:
V547 Expression is always false. Probably the '||' operator should be used here. Notepad++
notepad_plus.cpp 5032

N5.
int Notepad_plus::getHtmlXmlEncoding(....) const
{
...
if (langT != L_XML && langT != L_HTML && langT == L_PHP)
return -1;
...
}
PVS-Studio:
V590 Consider inspecting this expression. The expression is excessive or contains a misprint. Notepad++
notepad_plus.cpp 853
. :
if (langT == L_PHP)
, . .
:
if (langT != L_XML && langT != L_HTML && langT != L_PHP)

N6.
TCHAR GetASCII(WPARAM wParam, LPARAM lParam)
{
...
result=ToAscii(wParam,(lParam >> 16) && 0xff,
keys,&dwReturnedValue,0);

...
}
PVS-Studio:
V560 A part of conditional expression is always true: 0xff. Notepad++ babygrid.cpp 694
'lParam'. - ,
. , '&&' '&'. :
result=ToAscii(wParam,(lParam >> 16) & 0xff,
keys,&dwReturnedValue,0);

N7.
#define SCE_T3_BRACE 20
static inline bool IsAnOperator(const int style) {
return style == SCE_T3_OPERATOR || SCE_T3_BRACE;
}
PVS-Studio:
V560 A part of conditional expression is always true: 20. lextads3.cxx 700
IsAnOperator() 'true'. :
return style == SCE_T3_OPERATOR ||
style == SCE_T3_BRACE;

N8. ,
static void ColouriseVHDLDoc(....)
{
...
} else if (sc.Match('-', '-')) {
sc.SetState(SCE_VHDL_COMMENT);
sc.Forward();
} else if (sc.Match('-', '-')) {
if (sc.Match("--!"))
sc.SetState(SCE_VHDL_COMMENTLINEBANG);

else
sc.SetState(SCE_VHDL_COMMENT);
}
...
}
PVS-Studio:
V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error
presence. Check lines: 130, 133. lexvhdl.cxx 130
(sc.Match('-', '-')) , .
, "--!"
. , :
static void ColouriseVHDLDoc(....)
{
...
} else if (sc.Match('-', '-')) {
if (sc.Match("--!"))
sc.SetState(SCE_VHDL_COMMENTLINEBANG);
else
sc.SetState(SCE_VHDL_COMMENT);
}
...
}

N9.
, , .
:
void Gripper::doTabReordering(POINT pt)
{
...
else if (_hTab == hTabOld)
{

/* delete item on switch between tabs */


::SendMessage(_hTab, TCM_DELETEITEM, iItemOld, 0);
}
else
{
if (_hTab == hTabOld)
{
/* delete item on switch between tabs */
::SendMessage(_hTab, TCM_DELETEITEM, iItemOld, 0);
}
}
...
}
PVS-Studio:
V571 Recurring check. The 'if (_hTab == hTabOld)' condition was already verified in line 478. Notepad++
gripper.cpp 485
.
, . 'mainVerStr' 'auxVerStr'
, , :
LRESULT Notepad_plus::process(....)
{
...
TCHAR mainVerStr[16];
TCHAR auxVerStr[16];
...
if (mainVerStr)
mainVer = generic_atoi(mainVerStr);
if (auxVerStr)
auxVer = generic_atoi(auxVerStr);
...

}
:
mainVer = generic_atoi(mainVerStr);
auxVer = generic_atoi(auxVerStr);
, , Notepad++ :
V600 Consider inspecting the condition. The 'mainVerStr' pointer is always not equal to NULL.
Notepad++ nppbigswitch.cpp 938
V600 Consider inspecting the condition. The 'auxVerStr' pointer is always not equal to NULL. Notepad++
nppbigswitch.cpp 940
V600 Consider inspecting the condition. The 'intStr' pointer is always not equal to NULL. Notepad++
preferencedlg.cpp 1871
V600 Consider inspecting the condition. The 'intStr' pointer is always not equal to NULL. Notepad++
userdefinedialog.cpp 222
V600 Consider inspecting the condition. The 'intStr' pointer is always not equal to NULL. Notepad++
wordstyledlg.cpp 539

, ,
. ,
.
, - ?
"memset(_iContMap, -1, CONT_MAP_MAX)" .
PVS-Studio,
. -,
. -, .
. PVS-Studio
.
,
. warnings, .
warnings , ? .
,
.
? .
, . ,
,
.