PVS-StudioWarnings

PVS-Studio warning V525 for Notepad++

Nov 13th, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.96 KB | None | 0 0
  1. #define IDC_KEYWORD1_ITALIC_CHECK (IDC_KEYWORD1 + 7)
  2. #define IDC_KEYWORD3_BOLD_CHECK (IDC_KEYWORD3 + 6)
  3.  
  4. void KeyWordsStyleDialog::updateDlg()
  5. {
  6.   ...
  7.   Style & w1Style =
  8.     _pUserLang->_styleArray.getStyler(STYLE_WORD1_INDEX);
  9.   styleUpdate(w1Style, _pFgColour[0], _pBgColour[0],
  10.     IDC_KEYWORD1_FONT_COMBO, IDC_KEYWORD1_FONTSIZE_COMBO,
  11.     IDC_KEYWORD1_BOLD_CHECK, IDC_KEYWORD1_ITALIC_CHECK,
  12.     IDC_KEYWORD1_UNDERLINE_CHECK);
  13.  
  14.   Style & w2Style =
  15.     _pUserLang->_styleArray.getStyler(STYLE_WORD2_INDEX);
  16.   styleUpdate(w2Style, _pFgColour[1], _pBgColour[1],
  17.     IDC_KEYWORD2_FONT_COMBO, IDC_KEYWORD2_FONTSIZE_COMBO,
  18.     IDC_KEYWORD2_BOLD_CHECK, IDC_KEYWORD2_ITALIC_CHECK,
  19.     IDC_KEYWORD2_UNDERLINE_CHECK);
  20.  
  21.   Style & w3Style =
  22.     _pUserLang->_styleArray.getStyler(STYLE_WORD3_INDEX);
  23.   styleUpdate(w3Style, _pFgColour[2], _pBgColour[2],
  24.     IDC_KEYWORD3_FONT_COMBO, IDC_KEYWORD3_FONTSIZE_COMBO,
  25.     IDC_KEYWORD3_BOLD_CHECK, IDC_KEYWORD3_BOLD_CHECK,
  26.     IDC_KEYWORD3_UNDERLINE_CHECK);
  27.  
  28.   Style & w4Style =
  29.     _pUserLang->_styleArray.getStyler(STYLE_WORD4_INDEX);
  30.   styleUpdate(w4Style, _pFgColour[3], _pBgColour[3],
  31.     IDC_KEYWORD4_FONT_COMBO, IDC_KEYWORD4_FONTSIZE_COMBO,
  32.     IDC_KEYWORD4_BOLD_CHECK, IDC_KEYWORD4_ITALIC_CHECK,
  33.     IDC_KEYWORD4_UNDERLINE_CHECK);
  34.   ...
  35. }
  36.  
  37. This code was most likely being written through the Copy-Paste method. It resulted in using IDC_KEYWORD3_BOLD_CHECK instead of IDC_KEYWORD3_ITALIC_CHECK. The warning looks a bit strange, telling us about the numbers '7', '7', '6', '7'. Unfortunately, a clearer message cannot be generated.
  38.  
  39. This suspicious code was found in Notepad++ project by PVS-Studio static code analyzer.
  40. Warning message is:
  41. V525 The code containing the collection of similar blocks. Check items '7', '7', '6', '7' in lines 576, 580, 584, 588
  42.  
  43. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment