Pour obtenir une clé
d'essai remplissez le formulaire ci-dessous
Demandez des tariffs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
RUB
* En cliquant sur ce bouton, vous acceptez notre politique de confidentialité

Free PVS-Studio license for Microsoft MVP specialists
To get the licence for your open-source project, please fill out this form
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

I am interested to try it on the platforms:
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

Votre message a été envoyé.

Nous vous répondrons à


Si vous n'avez toujours pas reçu de réponse, vérifiez votre dossier
Spam/Junk et cliquez sur le bouton "Not Spam".
De cette façon, vous ne manquerez la réponse de notre équipe.

>
>
>
Examples of errors detected by the V545…

Examples of errors detected by the V545 diagnostic

V545. Conditional expression of 'if' statement is incorrect for the HRESULT type value 'Foo'. The SUCCEEDED or FAILED macro should be used instead.


VirtualDub

V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value 'AVIStreamInfoA(pas, & asi, sizeof asi)'. The SUCCEEDED or FAILED macro should be used instead. VirtualDub avireadhandlertunnelw32.cpp 230


#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE

STDAPI AVIStreamInfoA (PAVISTREAM pavi, LPAVISTREAMINFOA psi,
                       LONG lSize);

#define AVIStreamInfo AVIStreamInfoA

VDPosition AVIReadTunnelStream::TimeToPosition(VDTime timeInUs) {
  AVISTREAMINFO asi;
  if (AVIStreamInfo(pas, &asi, sizeof asi))
    return 0;

  return VDRoundToInt64(timeInUs * (double)asi.dwRate /
           (double)asi.dwScale * (1.0 / 1000000.0));
}

Similar errors can be found in some other places:

  • V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value 'AVIStreamInfoA(pas, & asi, sizeof asi)'. The SUCCEEDED or FAILED macro should be used instead. VirtualDub avireadhandlertunnelw32.cpp 238
  • V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value 'hr'. The SUCCEEDED or FAILED macro should be used instead. VirtualDub avireadhandlertunnelw32.cpp 335
  • V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value 'err'. The SUCCEEDED or FAILED macro should be used instead. VirtualDub inputfileavi.cpp 440
  • And 1 additional diagnostic messages.

Qt

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


STDMETHODIMP QEnumPins::QueryInterface(const IID &iid,void **out)
{
  ....
  if (S_OK)
    AddRef();
  return hr;
}

It works on a sheer luck. S_OK is 0, by the way. That is, we don't perform AddRef(). This is what should have been written here: if (hr == S_OK).


LibreOffice

V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value 'nRC'. The SUCCEEDED or FAILED macro should be used instead. winlayout.cxx 1115


bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs )
{
  ....
  HRESULT nRC = ScriptItemize(....);
  if( !nRC ) // break loop when everything is correctly itemized
    break;
  ....
}

Apache HTTP Server

V545 Such conditional expression of 'if' operator is incorrect for the HRESULT type value 'SHGetMalloc(& pMalloc)'. The SUCCEEDED or FAILED macro should be used instead. apachemonitor.c 915


#define SHSTDAPI EXTERN_C DECLSPEC_IMPORT HRESULT STDAPICALLTYPE

SHSTDAPI SHGetMalloc(_Outptr_ IMalloc **ppMalloc);

LRESULT CALLBACK ConnectDlgProc(....)
{
  ....
  if (SHGetMalloc(&pMalloc)) {             // <=
   pMalloc->lpVtbl->Free(pMalloc, il);
   pMalloc->lpVtbl->Release(pMalloc);
  }
  ....
}

ANGLE

V545 CWE-253 Such conditional expression of 'if' statement is incorrect for the HRESULT type value '(HRESULT) 0x8007000EL'. The SUCCEEDED or FAILED macro should be used instead. renderer11.cpp 4048


typedef _Return_type_success_(return >= 0) long HRESULT;
#define _HRESULT_TYPEDEF_(_sc) ((HRESULT)_sc)
#define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000EL)

gl::Error Renderer11::mapResource(....)
{
  HRESULT hr = mDeviceContext->Map(resource, subResource,
                                   mapType, mapFlags,
                                   mappedResource);
  if (FAILED(hr))
  {
    ....
    if (E_OUTOFMEMORY)
    {
      glError = gl::OutOfMemory() <<
                genericFailureMessage <<
                gl::FmtHR(hr);
    }
    return glError;
  }
  return gl::NoError();
}

Apparently, the correct condition must be as follows: if (hr == E_OUTOFMEMORY)


Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter