Examples of errors detected by the V521 diagnostic.


V521. Such expressions using the ',' operator are dangerous. Make sure the expression is correct.


G3D Content Pak

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '0, 0' is correct. graphics3D anyval.cpp 275


void AnyVal::serialize(G3D::TextOutput& t) const {
  ...
  const Matrix3& m = *(Matrix3*)m_value;
  ...
  t.printf("%10.5f, %10.5f, %10.5f,\n"
           "%10.5f, %10.5f, %10.5f,\n"
           "%10.5f, %10.5f, %10.5f)",
           m[0, 0], m[0, 1], m[0, 2],
           m[1, 0], m[1, 1], m[1, 2],
           m[2, 0], m[2, 1], m[2, 2]);
  ...
}

This is what should have been written here: ...., m[0][0], m[0][1], ....


Lugaru

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'bleedx = 0, bleedy' is correct. Lugaru person.cpp 7815


Person::Person()
{
  ...
  bleeding = 0;
  bleedx = 0,bleedy;
  direction = 0;
  ...
}

This is what should have been written here: bleedy = 0;


Quake-III-Arena

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. bspc l_bsp_q1.c 136


void Q1_AllocMaxBSP(void)
{
  ...
  q1_allocatedbspmem +=
    Q1_MAX_MAP_CLIPNODES * sizeof(q1_dclipnode_t);
  ...
  q1_allocatedbspmem +=
    Q1_MAX_MAP_EDGES , sizeof(q1_dedge_t);          // <=
  ...
  q1_allocatedbspmem +=
    Q1_MAX_MAP_MARKSURFACES * sizeof(unsigned short);
  ...
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. bspc l_bsp_hl.c 154

IPP Samples

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. vc1_dec umc_vc1_dec_mb_com.cpp 370


void GetIntraDCPredictors(VC1Context* pContext)
{
  DCPred.DC[13] = pC->DCBlkPred[5].DC,QurrQuant;
  ...
}

IPP Samples

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. speech usc_dtmf.c 309


static int DTMF_16s(const Ipp16s *pBuffer, int nbytes,
                    USC_ToneID *toneRes,
                    DTMFState_16s *pIppTDParams)
{
  ...
  for (i = pIppTDParams->dtmf_fs, j = 0;
       i < dtmf_frame_size+pIppTDParams->dtmf_fs, j < nbytes;
       i++, j++)
  ...
}

The && operator should be used in the loop condition.


Trans-Proteomic Pipeline

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. tpplib peptide.cpp 191


bool Peptide::operator==(Peptide& p) {
  ...
  for (i = 0, j = 0;
       i < this->stripped.length(), j < p.stripped.length();
       i++, j++) {
  ...
}

The && operator should be used in the loop condition.

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. tpplib peptide.cpp 243

Visualization Toolkit (VTK)

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'this->Internal->TableArrays[i], name' is correct. vtkIO vtksesamereader.cxx 352


int vtkSESAMEReader::GetTableArrayStatus(const char* name)
{
  ...
  for(i=0; i<numArrays; i++)
  {
    if(this->Internal->TableArrays[i], name)     // <=
    {
      return this->Internal->TableArrayStatus[i];
    }
  }
  return 0;
}

OpenSSL

V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'al = 2, 50' is correct. s3_clnt.c 1714


#define SSL3_AL_FATAL 2
#define SSL_AD_DECODE_ERROR 50

int ssl3_get_new_session_ticket(SSL *s)
{
  int al;
  ....
  al = SSL3_AL_FATAL, SSL_AD_DECODE_ERROR;
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'al = 2, 50' is correct. s3_clnt.c 1724

Trans-Proteomic Pipeline

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 504


double SpectraSTPeakList::calcDot(SpectraSTPeakList* other) {
  ....
  for (i = this->m_bins->begin(), j = other->m_bins->begin();
       i != this->m_bins->end(), j != other->m_bins->end();
       i++, j++) {
    d = (*i) * (*j);
    dot += d;
  }
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 516
  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 529
  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. spectrastpeaklist.cpp 592
  • And 3 additional diagnostic messages.

CryEngine 3 SDK

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '"%s:", currentSeat->GetSeatName()' is correct. flowvehiclenodes.cpp 662


virtual void ProcessEvent( .... )
{
  ....
  string pMessage = ("%s:", currentSeat->GetSeatName());
  ....
}

This is what should have been written here: string pMessage = string().Format("%s:", currentSeat->GetSeatName());

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. flowvehiclenodes.cpp 672

Grassroots DICOM library (GDCM)

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. gdcmsorter.cxx 82


bool Sorter::StableSort(
  std::vector<std::string> const & filenames)
{
  ....
  std::vector< SmartPointer<FileWithName> >::iterator
    it2 = filelist.begin();

  for( Directory::FilenamesType::const_iterator it =
         filenames.begin();
       it != filenames.end(), it2 != filelist.end();
       ++it, ++it2)
  {
  ....
}

Similar errors can be found in some other places:

  • V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. gdcmsorter.cxx 123

Oracle VM Virtual Box

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. applianceimplimport.cpp 3943


void Appliance::i_importMachines(....)
{
  ....
  /* Iterate through all virtual systems of that appliance */
  size_t i = 0;
  for (it = reader.m_llVirtualSystems.begin(),
       it1 = m->virtualSystemDescriptions.begin();
       it != reader.m_llVirtualSystems.end(),         // <=
       it1 != m->virtualSystemDescriptions.end();
       ++it, ++it1, ++i)
  {....}
  ....
}

Unreal Engine 4

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. unrealaudiodevicewasapi.cpp 128


static void GetArrayOfSpeakers(....)
{
  Speakers.Reset();
  uint32 ChanCount = 0;
  // Build a flag field of the speaker outputs of this device
  for (uint32 SpeakerTypeIndex = 0;
       SpeakerTypeIndex < ESpeaker::SPEAKER_TYPE_COUNT,    // <=
       ChanCount < NumChannels; ++SpeakerTypeIndex)
  {
    ....
  }

  check(ChanCount == NumChannels);
}

Oracle VM Virtual Box

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. vboxmpwddm.cpp 1083


NTSTATUS DxgkDdiStartDevice(...)
{
  ....
  if ( ARGUMENT_PRESENT(MiniportDeviceContext) &&
        ARGUMENT_PRESENT(DxgkInterface) &&
        ARGUMENT_PRESENT(DxgkStartInfo) &&
        ARGUMENT_PRESENT(NumberOfVideoPresentSources), // <=
        ARGUMENT_PRESENT(NumberOfChildren)
        )
  {
    ....
  }
  ....
}

ReactOS

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. cmdcons.c 430


static INT CommandDumpSector(....)
{
   ....
   SectorCount.QuadPart = DiskGeometry.Cylinders.QuadPart *
                          DiskGeometry.TracksPerCylinder,  // <=
                          DiskGeometry.SectorsPerTrack;
   ....
}

CryEngine V

V521 Such expressions using the ',' operator are dangerous. Make sure the expression '!sWords[iWord].empty(), iWord ++' is correct. TacticalPointSystem.cpp 3243


bool CTacticalPointSystem::Parse(....) const
{
  string sInput(sSpec);
  const int MAXWORDS = 8;
  string sWords[MAXWORDS];

  int iC = 0, iWord = 0;
  for (; iWord < MAXWORDS; !sWords[iWord].empty(), iWord++) // <=
  {
    sWords[iWord] = sInput.Tokenize("_", iC);
  }
  ....
}

CryEngine V

V521 Such expressions using the ',' operator are dangerous. Make sure the expression is correct. HommingSwarmProjectile.cpp 187


void CHommingSwarmProjectile::HandleEvent(....)
{
  ....
  explodeDesc.normal = -pCollision->n,pCollision->vloc[0];
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++ and C#

goto PVS-Studio;