Examples of errors detected by the V549 diagnostic.


V549. The 'first' argument of 'Foo' function is equal to the 'second' argument.


Open Metronome

V549 The first argument of '_swab' function matches it's the second argument. metronome metblinker.cpp 117


CMetBlinker::CMetBlinker(....)
{
  ...
  _swab((char*)&*m_aaActualBitmapBits[i].begin(),
        (char*)&*m_aaActualBitmapBits[i].begin(),
        NumberOfPixels/8);
  ...
}

ReactOS

V549 The first argument of 'strcmp' function matches it's the second argument. stlport locale.cpp 211


static void _Stl_loc_combine_names(_Locale_impl* L,
  const char* name1, const char* name2,
  locale::category c)
{
  if ((c & locale::all) == 0 ||
      strcmp(name1, name1) == 0)
  ...
}

This is what should have been written here: strcmp(name1, name2)


Chromium

V549 The first argument of 'memcmp' function is equal to the second argument. entry_unittest.cc 393


void DiskCacheEntryTest::ExternalSyncIOBackground(....) {
  ....
  scoped_refptr<net::IOBuffer>
    buffer1(new net::IOBuffer(kSize1));
  scoped_refptr<net::IOBuffer>
    buffer2(new net::IOBuffer(kSize2));
  ....
  EXPECT_EQ(0, memcmp(buffer2->data(), buffer2->data(), 10000));
  ....
}

CryEngine 3 SDK

V549 The first argument of 'stricmp' function is equal to the second argument. ishader.h 2089


inline bool operator != (const SEfResTexture &m) const
{
  if (stricmp(m_Name.c_str(), m_Name.c_str()) != 0 ||
      m_TexFlags != m.m_TexFlags ||
      m_bUTile != m.m_bUTile ||
      m_bVTile != m.m_bVTile ||
      m_Filter != m.m_Filter ||
      m_Ext != m.m_Ext ||
      m_Sampler != m.m_Sampler)
    return true;
  return false;
}

Micro-Manager

V549 The first argument of 'strcmp' function is equal to the second argument. XLedDev.cpp 119


int XLedDev::Initialize()
{
  ....
  if (strcmp(
    XLed::Instance()->GetXLedStr(XLed::XL_WLedDevName +
                                 m_nLedDevNumber).c_str(),
    XLed::Instance()->GetXLedStr(XLed::XL_WLedDevName +
                                 m_nLedDevNumber).c_str()
            ) != 0)
  ....
}

Miranda NG

V549 The first argument of 'memcpy' function is equal to the second argument. NimContact http.cpp 46


int InternetDownloadFile (char *szUrl)
{
  ....
  CopyMemory(nlhr.headers,nlhr.headers,
             sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
  ....
}

Miranda NG

V549 The first argument of 'wcscpy' function is equal to the second argument. Spamotron utils.cpp 218


TCHAR* get_response(TCHAR* dst, unsigned int dstlen, int num)
{
  ....
  TCHAR *tmp, *src = NULL;
  ....
  src = (TCHAR*)malloc(MAX_BUFFER_LENGTH * sizeof(TCHAR));
  ....
  _tcscpy(src, src);
  ....
}

The GTK+ Project

V549 The first argument of 'strcmp' function is equal to the second argument. gtkrc.c 1400


GtkStyle *
gtk_rc_get_style_by_paths (....)
{
  ....
  pos = gtk_widget_path_append_type (path, component_type);
  if (component_name != NULL &&
      strcmp (component_name, component_name) != 0)    // <=
    gtk_widget_path_iter_set_name (path, pos, component_name);
  ....
}

GDB

V549 The first argument of 'memcmp' function is equal to the second argument. psymtab.c 1580


static int
psymbol_compare (const void *addr1, const void *addr2,
                 int length)
{
  struct partial_symbol *sym1 = (struct partial_symbol *) addr1;
  struct partial_symbol *sym2 = (struct partial_symbol *) addr2;

  return (memcmp (&sym1->ginfo.value, &sym1->ginfo.value,
                  sizeof (sym1->ginfo.value)) == 0
          && sym1->ginfo.language == sym2->ginfo.language
          && PSYMBOL_DOMAIN (sym1) == PSYMBOL_DOMAIN (sym2)
          && PSYMBOL_CLASS (sym1) == PSYMBOL_CLASS (sym2)
          && sym1->ginfo.name == sym2->ginfo.name);
}

Linux Kernel

V549 The first argument of 'memcpy' function is equal to the second argument. wilc_wfi_cfgoperations.c 1345


static int del_pmksa(struct wiphy *wiphy,
                     struct net_device *netdev,
                     struct cfg80211_pmksa *pmksa)
{
  ....
  for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
    memcpy(priv->pmkid_list.pmkidlist[i].bssid,
           priv->pmkid_list.pmkidlist[i + 1].bssid,
           ETH_ALEN);
    memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
           priv->pmkid_list.pmkidlist[i].pmkid,
           PMKID_LEN);
  }
  ....
}

CryEngine V

V549 The first argument of 'memcpy' function is equal to the second argument. ObjectsTree_Serialize.cpp 1135


void COctreeNode::LoadSingleObject(....)
{
  ....
  float* pAuxDataDst = pObj->GetAuxSerializationDataPtr(....);
  const float* pAuxDataSrc = StepData<float>(....);
  memcpy(pAuxDataDst, pAuxDataDst, min(....) * sizeof(float));
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;