PVS-StudioWarnings

PVS-Studio warning V547 for Scilab

Nov 20th, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #define __GO_FIGURE__ 9
  2. #define __GO_UIMENU__ 21
  3.  
  4. int sci_uimenu(char *fname, unsigned long fname_len)
  5. {
  6.   ....
  7.   if (iParentType == __GO_FIGURE__ &&
  8.       iParentType == __GO_UIMENU__)
  9.   {
  10.     Scierror(999, _("%s: Wrong type for input argument #%d: ")
  11.              _("A '%s' or '%s' handle expected.\n"),
  12.              fname, 1, "Figure", "Uimenu");
  13.     return FALSE;
  14.   }
  15.   ....
  16. }
  17.  
  18. This is what should have been written here: iParentType != __GO_FIGURE__ && iParentType != __GO_UIMENU__
  19.  
  20. This suspicious code was found in Scilab project by PVS-Studio static code analyzer.
  21. Warning message is:
  22. V547 Expression 'iParentType == 9 && iParentType == 21' is always false. Probably the '||' operator should be used here. sci_uimenu.c 99
  23.  
  24. 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