PVS-StudioWarnings

PVS-Studio warning V547 for amtsdk

Nov 19th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. static char* _username = "";
  2. static char* _password = "";
  3. static char* _host = "";
  4. static char* _hostMask = "";
  5.  
  6. if (((_username == "") && (_password != "")) ||
  7.     ((_username != "") && (_password == "")))
  8.  
  9. This code is dangerous and incorrect. But sometimes it will work - when the whole code is in one module (one *.obj). The compiler will create only one empty string in memory.
  10.  
  11. This suspicious code was found in amtsdk project by PVS-Studio static code analyzer.
  12. Warning message is:
  13. V547 Expression '_username == ""' is always false. To compare strings you should use strcmp() function. Discovery discoverysample.cpp 184
  14.  
  15. 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