To get a trial key
fill out the form below
Team License (a basic version)
Enterprise License (an extended version)
* By clicking this button you agree to our Privacy Policy statement

Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

Free PVS-Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
Examples of errors detected by the V562…

Examples of errors detected by the V562 diagnostic

V562. Bool type value is compared with value of N. Consider inspecting the expression.


Spvolren

V562 It's odd to compare a bool type value with a value of -1: !(fp = fopen (filename, "wb")) == - 1. spvolren ppm.c 118


void ppmWrite(char *filename, PPMFile *ppmFile)
{
  ....
  FILE *fp;
  if (! (fp = fopen(filename, "wb")) == -1) {
    perror("opening image file failed");
    exit(1);
  }
  ....
}

ReactOS

V562 It's odd to compare 0 or 1 with a value of 4294967295. eventlog file.c 264


#define INVALID_SET_FILE_POINTER ((DWORD)-1)

BOOL LogfInitializeExisting(PLOGFILE LogFile)
{
  ....
  if (!SetFilePointer(LogFile->hFile, 0, NULL, FILE_BEGIN) ==
      INVALID_SET_FILE_POINTER)
  {
      DPRINT1("SetFilePointer() failed! %d\n", GetLastError());
      return FALSE;
  }
  ....
}

This is what should have been written here: if (SetFilePointer(LogFile->hFile, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER)


Blender

V562 It's odd to compare 0 or 1 with a value of 1: (base->object->actcol > 0) > (1). bf_editor_render render_preview.c 361


#define MAX2(x,y) ( (x)>(y) ? (x) : (y) )

static Scene *preview_prepare_scene(....)
{
  ....
  int actcol = MAX2(base->object->actcol > 0, 1) - 1;
  ....
}

Most likely this is what should be written here: int actcol = MAX2(base->object->actcol, 1) - 1;


Windows 8 Driver Samples

V562 It's odd to compare 0 or 1 with a value of 5: 0 < dwMaskSize < 5. nic_pm.c 825


VOID MPCreateProgrammableFilter(....)
{
  ....
  ASSERT (0 < dwMaskSize <5);
  ....
}

Haiku Operation System

V562 It's odd to compare 0 or 1 with a value of 0. cmp.c 300


#ifndef same_file
# define same_file(s, t) \
    ((((s)->st_ino == (t)->st_ino) \
     && ((s)->st_dev == (t)->st_dev)) \
     || same_special_file (s, t))
#endif

int
main (int argc, char **argv)
{
  ....
  if (0 < same_file (&stat_buf[0], &stat_buf[1])           // <=
      && same_file_attributes (&stat_buf[0], &stat_buf[1])
      && file_position (0) == file_position (1))
    return EXIT_SUCCESS;
  ....
}

Similar errors can be found in some other places:

  • V562 It's odd to compare 0 or 1 with a value of 0. cmp.c 313

NCBI Genome Workbench

V562 It's odd to compare a bool type value with a value of 0: (((status) & 0x7f) == 0) != 0. ncbi_process.cpp 111


bool CProcess::CExitInfo::IsExited(void) const
{
    EXIT_INFO_CHECK;
    if (state != eExitInfo_Terminated) {
        return false;
    }
#if   defined(NCBI_OS_UNIX)
    return WIFEXITED(status) != 0;
#elif defined(NCBI_OS_MSWIN)
    // The process always terminates with exit code
    return true;
#endif
}
return (((status) & 0x7f) == 0) != 0;

return (((status) & 0x7f) == 0) != 0;

Similar errors can be found in some other places:

  • V562 It's odd to compare a bool type value with a value of 0. ncbi_process.cpp 126

Haiku Operation System

V562 It's odd to compare a bool type value with a value of 18: 0x12 == IsProfessionalSpdif(). CEchoGals_mixer.cpp 533


typedef bool BOOL;

virtual BOOL IsProfessionalSpdif() { ... }

#define ECHOSTATUS_DSP_DEAD 0x12

ECHOSTATUS CEchoGals::ProcessMixerFunction(....)
{
  ....
  if ( ECHOSTATUS_DSP_DEAD == IsProfessionalSpdif() ) // <=
  {
    Status = ECHOSTATUS_DSP_DEAD;
  }
  else
  {
    pMixerFunction->Data.bProfSpdif = IsProfessionalSpdif();
  }
  ....
}

This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept