Advertisement
PVS-StudioWarnings

PVS-Studio warning V545 for QT

Nov 24th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. STDMETHODIMP QEnumPins::QueryInterface(const IID &iid,void **out)
  2. {
  3.   ...
  4.   if (S_OK)
  5.     AddRef();
  6.   return hr;
  7. }
  8.  
  9. It works on a sheer luck. S_OK is 0, by the way. That is, we don't perform AddRef().
  10. This is what should have been written here: if (hr == S_OK).
  11.  
  12. This suspicious code was found in QT project by PVS-Studio static code analyzer.
  13. Warning message is:
  14. V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value '(HRESULT) 0L'. The SUCCEEDED or FAILED macro should be used instead. phonon_ds9 qbasefilter.cpp 60
  15.  
  16. 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
Advertisement