Examples of errors detected by the V530 diagnostic.

V530. The return value of function 'Foo' is required to be utilized.


TortoiseSVN

V530 The return value of function 'empty' is required to be utilized. contextmenu.cpp 434

V530 The return value of function 'remove' is required to be utilized. contextmenu.cpp 442


STDMETHODIMP CShellExt::Initialize(....)
{
  ...
  ignoredprops.empty();
  for (int p=0; p<props.GetCount(); ++p)
  {
    if (props.GetItemName(p).
          compare(SVN_PROP_IGNORE)==0)
    {
      std::string st = props.GetItemValue(p);
      ignoredprops = UTF8ToWide(st.c_str());
      // remove all escape chars ('\\')
      std::remove(ignoredprops.begin(),
                  ignoredprops.end(), '\\');
      break;
    }
  }
  ...
}

The std::remove function does not remove elements from the container. It only shifts the elements and brings the iterator back to the beginning of the trash. Suppose we have the vector<int> container that contains elements 1,2,3,1,2,3,1,2,3. If we execute the code "remove( v.begin(), v.end(), 2 )", the container will contain elements 1,3,1,3,?,?,?, where ? is some trash. The function will bring the iterator back to the first senseless element, so if we want to remove these trash elements, we must write the code this way: "v.erase(remove(v.begin(), v.end(), 2), v.end())".


TortoiseSVN

V530 The return value of function 'empty' is required to be utilized. mailmsg.cpp 40


CMailMsg& CMailMsg::SetFrom(string sAddress,
                            string sName)
{
   if (initIfNeeded())
   {
      // only one sender allowed
      if (m_from.size())
         m_from.empty();
      m_from.push_back(TStrStrPair(sAddress,sName));
   }
   return *this;
}

This is what should have been written here: m_from.clear();


TortoiseSVN

V530 The return value of function 'empty' is required to be utilized. mailmsg.cpp 54


CMailMsg& CMailMsg::SetTo(string sAddress,
                          string sName)
{
   if (initIfNeeded())
   {
      // only one recipient allowed
      if (m_to.size())
         m_to.empty();

      m_to.push_back(TStrStrPair(sAddress,sName));
   }
   return *this;
}

This is what should have been written here: m_to.clear();


WinMerge

V530 The return value of function 'empty' is required to be utilized.


/**
* @brief Get the file names on both sides for specified item.
* @note Return empty strings if item is special item.
*/
void CDirView::GetItemFileNames(int sel,
  String& strLeft, String& strRight) const
{
  UINT_PTR diffpos = GetItemKey(sel);
  if (diffpos == (UINT_PTR)SPECIAL_ITEM_POS)
  {
    strLeft.empty();
    strRight.empty();
  }
  else
  {
     ...
  }
}

This is what should have been written here: strLeft.clear(); strRight.clear();


WinMerge

V530 The return value of function 'empty' is required to be utilized.


/**
* @brief Clear variant's value (reset to defaults).
*/
void VariantValue::Clear()
{
  m_vtype = VT_NULL;
  m_bvalue = false;
  m_ivalue = 0;
  m_fvalue = 0;
  m_svalue.empty();
  m_tvalue = 0;
}

This is what should have been written here: m_svalue.clear();


EchoVNC

V530 The return value of function 'empty' is required to be utilized. miniWinVNC parsecmdline.cpp 367


bool CParseCmdLine::CheckParameter(..., std::string& rStrForSave)
{
  ...
  rStrForSave.empty();
  ...
}

This is what should have been written here: rStrForSave.clear();


EchoVNC

V530 The return value of function 'empty' is required to be utilized. AskParameter wndproc.cpp 163


struct ST_DATA
{
  ...
  std::string m_szImagePath;
  ...
};

void Install_and_Run_MainFiles(const char* szPath)
{
  ...
  if (!WriteTmpBanner(ser, szPath))
  {
    ser.m_data.m_szImagePath.empty();
  }
  ...
}

This is what should have been written here: ser.m_data.m_szImagePath.clear();


IPP Samples

V530 The return value of function 'remove' is required to be utilized. h264_dec umc_h264_thread.cpp 226


void H264ThreadGroup::RemoveThread(H264Thread * thread)
{
    AutomaticUMCMutex guard(m_mGuard);
    std::remove(m_threads.begin(), m_threads.end(), thread);
}

The std::remove function does not remove elements from the container. It only shifts the elements and brings the iterator back to the beginning of the trash. Suppose we have the vector<int> container that contains elements 1,2,3,1,2,3,1,2,3. If we execute the code "remove( v.begin(), v.end(), 2 )", the container will contain elements 1,3,1,3,?,?,?, where ? is some trash. The function will bring the iterator back to the first senseless element, so if we want to remove these trash elements, we must write the code this way: "v.erase(remove(v.begin(), v.end(), 2), v.end())".


Nmap Security Scanner

V530 The return value of function 'empty' is required to be utilized. nping nepcontext.cc 562


/** Deletes all previous field specifiers.
  * This should be used when dealing
  * with clients that send multiple NEP_PACKET_SPEC messages,
  * so only the last PacketSpec is taken into account. */
int NEPContext::resetClientFieldSpecs(){
  this->fspecs.empty();
  return OP_SUCCESS;
} /* End of resetClientFieldSpecs() */

What a nice comment. It's a pity that the code does quite a different thing. This is what should have been written here: this->fspecs.clear();


Chromium

V530 The return value of function 'empty' is required to be utilized. chrome_frame_ie protocol_sink_wrap.cc 399


std::wstring url_;

HRESULT ProtData::ReportProgress(IInternetProtocolSink* delegate,
                                 ULONG status_code,
                                 LPCWSTR status_text)
{
  ...
  case BINDSTATUS_REDIRECTING:
    url_.empty();
    if (status_text)
      url_ = status_text;
    break;
  ...
}

This is what should have been written here: url_.clear();


Chromium

V530 The return value of function 'empty' is required to be utilized. chrome_frame_npapi np_proxy_service.cc 293


bool NpProxyService::GetProxyValueJSONString(std::string* output)
{
  DCHECK(output);
  output->empty();
  ...
}

This is what should have been written here: output->clear();


Intel AMT SDK

V530 The return value of function 'empty' is required to be utilized. AMTredirection mcsol.cpp 443


bool MCSOL::_createHTLink()
{
  ...
  string HTcmd = TERM_CMD;
  ...
  HTcmd.empty();
  ...
}

This is what should have been written here: HTcmd.clear();


Intel AMT SDK

V530 The return value of function 'empty' is required to be utilized. EventLogReader cimclass.h 153


void CimClassContainer::Clear()
{
  for(unsigned int i = 0; i < vec.size(); i++)
  {
    delete vec[i];
    vec[i] = NULL;
  }
  vec.empty();
}

This is what should have been written here: vec.clear();


ReactOS

V530 The return value of function 'wcscmp' is required to be utilized. msdmo dmoreg.c 617


  if (ERROR_SUCCESS == hres)
  {
    Names[count] = HeapAlloc(GetProcessHeap(), 0,
                             strlenW(szValue) + 1);
    if (Names[count])
       strcmpW(Names[count], szValue);
  }

It's strange that the result of calling the strcmpW() function is not used in any way.


Battle for Wesnoth

V530 The return value of function 'back' is required to be utilized. wesnoth menu_events.cpp 91


gui::dialog_button_action::RESULT
delete_recall_unit::button_pressed(int menu_selection)
{
  const std::vector<std::pair<int, int> >& param =
    std::vector<std::pair<int, int> >();
  param.back();
  const size_t index = size_t(filter_.get_index(menu_selection));
  ...
}

It's strange that the result of calling the param.back() function is not used in any way.


wxWidgets

V530 The return value of function 'empty' is required to be utilized. base translation.cpp 989


bool wxMsgCatalogFile::LoadData(....)
{
  ...
  wxString m_charset;
  ...
  if ( m_charset == wxS("CHARSET") )
  {
    m_charset.empty();
  }
  ...
}

This is what should have been written here: m_charset.clear();


wxWidgets

V530 The return value of function 'empty' is required to be utilized. base registry.cpp 329


wxString m_strKey;

void wxRegKey::SetHkey(WXHKEY hKey)
{
  ...

  // reset old data
  m_strKey.empty();
  m_dwLastError = 0;
}

This is what should have been written here: m_strKey.clear();


Visualization Toolkit (VTK)

V530 The return value of function 'empty' is required to be utilized. vtkRendering vtklabelhierarchy.cxx 425


std::vector<int> Path;

void vtkLabelHierarchyFrustumIterator::Next()
{
  ...
  this->Path.empty();
  ...
}

This is what should have been written here: this->Path.clear();


MongoDB

V530 The return value of function 'remove' is required to be utilized. cmdline.cpp 106

V530 The return value of function 'remove' is required to be utilized. cmdline.cpp 107


void CmdLine::parseConfigFile( istream &f, stringstream &ss ) {
  ....
  f.getline(line, MAX_LINE_LENGTH);
  s = line;
  std::remove(s.begin(), s.end(), ' ');
  std::remove(s.begin(), s.end(), '\t');
  boost::to_upper(s);
  ....
}

The std::remove function does not remove elements from the container. It only shifts the elements and brings the iterator back to the beginning of the trash. Suppose we have the vector<int> container that contains elements 1,2,3,1,2,3,1,2,3. If we execute the code "remove( v.begin(), v.end(), 2 )", the container will contain elements 1,3,1,3,?,?,?, where ? is some trash. The function will bring the iterator back to the first senseless element, so if we want to remove these trash elements, we must write the code this way: "v.erase(remove(v.begin(), v.end(), 2), v.end())".


ReactOS

V530 The return value of function 'wcscmp' is required to be utilized. dmoreg.c 621


#define strcmpW(s1,s2) wcscmp((s1),(s2))

static HRESULT WINAPI IEnumDMO_fnNext(....)
{
  ....
  if (Names[count])
    strcmpW(Names[count], szValue);
  ....
}

Chromium

V530 The return value of function 'remove_if' is required to be utilized. shortcuts_provider.cc 136


void ShortcutsProvider::DeleteMatchesWithURLs(
  const std::set<GURL>& urls)
{
  std::remove_if(matches_.begin(),
                 matches_.end(),
                 RemoveMatchPredicate(urls));
  listener_->OnProviderUpdate(true);
}

Multi Theft Auto

V530 The return value of function 'empty' is required to be utilized. cperfstat.functiontiming.cpp 197


std::map < SString, SFunctionTimingInfo > m_TimingMap;

void CPerfStatFunctionTimingImpl::DoPulse ( void )
{
  ....
  // Do nothing if not active
  if ( !m_bIsActive )
  {
    m_TimingMap.empty ();
    return;
  }
  ....
}

Multi Theft Auto

V530 The return value of function 'empty' is required to be utilized. cclientcolsphere.cpp 34


void CreateSphereFaces (
  std::vector < SFace >& faceList, int iIterations )
{
  int numFaces = (int)( pow ( 4.0, iIterations ) * 8 );
  faceList.empty ();
  faceList.reserve ( numFaces );
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'empty' is required to be utilized. cresource.cpp 132
  • V530 The return value of function 'empty' is required to be utilized. cresource.cpp 139
  • V530 The return value of function 'empty' is required to be utilized. cresource.cpp 147

Trans-Proteomic Pipeline

V530 The return value of function 'empty' is required to be utilized. tag.cxx 72

V530 The return value of function 'empty' is required to be utilized. tag.cxx 73


static void clearTagNames() {
   std::vector<const char *>ptrs;
   for (tagname_set::iterator i = tagnames.begin();
        i!=tagnames.end();i++) {
      ptrs.push_back(*i);
   }
   for (tagname_set::iterator j = attrnames.begin();
        j!=attrnames.end();j++) {
      ptrs.push_back(*j);
   }
   tagnames.empty();
   attrnames.empty();
   for (size_t n=ptrs.size();n--;) {
      delete [] (char *)(ptrs[n]); // cast away const
   }
}

QuantLib

V530 The return value of function 'empty' is required to be utilized. commoditycurve.cpp 70

V530 The return value of function 'empty' is required to be utilized. commoditycurve.cpp 71


void CommodityCurve::setPrices(std::map<Date, Real>& prices) {
  QL_REQUIRE(prices.size()>1, "too few prices");

  dates_.empty();
  data_.empty();

  for (std::map<Date, Real>::const_iterator i = prices.begin();
       i != prices.end(); i++)
  {
    dates_.push_back(i->first);
    data_.push_back(i->second);
  }
  ....
}

This is what should have been written here: dates_.clear(); data_.clear();


QuantLib

V530 The return value of function 'empty' is required to be utilized. energycommodity.cpp 152


void EnergyCommodity::calculateSecondaryCostAmounts(
  const CommodityType& commodityType,
  Real totalQuantityValue,
  const Date& evaluationDate) const
{
  secondaryCostAmounts_.empty();
  ....
}

QuantLib

V530 The return value of function 'remove' is required to be utilized. recursivecdoengine.hpp 172


template <class CDOEngine, class copulaT>
void RecursiveCdoEngine<CDOEngine, copulaT>::initialize() const {
  ....
  std::remove(lgds.begin(), lgds.end(), 0.);
  ....
}

The std::remove function does not remove elements from the container. It only shifts the elements and brings the iterator back to the beginning of the trash. Suppose we have the vector<int> container that contains elements 1,2,3,1,2,3,1,2,3. If we execute the code "remove( v.begin(), v.end(), 2 )", the container will contain elements 1,3,1,3,?,?,?, where ? is some trash. The function will bring the iterator back to the first senseless element, so if we want to remove these trash elements, we must write the code this way: "lgds.erase(std::remove(lgds.begin(), lgds.end(), 0.), lgds.end());".


Firebird

V530 The return value of function 'fgetpos' is required to be utilized. inputdevices.cpp 118


void InputDevices::indev::getPos(fpos_t* out) const
{
  fb_assert(out);
  fb_assert(indev_fpointer);
  fgetpos(indev_fpointer, out);
}

Synergy

V530 The return value of function 'empty' is required to be utilized. cipcserver.cpp 69


typedef std::list<CIpcClientProxy*> CClientList;
CClientList      m_clients;

CIpcServer::~CIpcServer()
{
  ....
  m_clients.empty();
  ....
}

Micro-Manager

V530 The return value of function 'c_str' is required to be utilized. ZeissCAN.cpp 1553


int HalogenLamp::SetIntensity(long intensity)
{
  ....
  command_stream.str().c_str();
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'c_str' is required to be utilized. ZeissCAN.cpp 2800

Unreal Engine 4

V530 The return value of function 'Memcmp' is required to be utilized. d3d11statecacheprivate.h 547


D3D11_STATE_CACHE_INLINE void GetBlendState(
  ID3D11BlendState** BlendState, float BlendFactor[4],
  uint32* SampleMask)
{
  ....
  FMemory::Memcmp(BlendFactor, CurrentBlendFactor,
                  sizeof(CurrentBlendFactor));
  ....
}

This is what should have been written here: FMemory::Memcpy


Qt

V530 The return value of function 'toLower' is required to be utilized. main.cpp 72


int main(int argc, char **argv)
{
  ....
  QByteArray arg(argv[a]);
  ....
  arg = arg.mid(1);
  arg.toLower();
  if (arg == "o")
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'toLower' is required to be utilized. main.cpp 1522

ITK

V530 The return value of function 'empty' is required to be utilized. itkpatchbaseddenoisingimagefilter.hxx 85

V530 The return value of function 'empty' is required to be utilized. itkpatchbaseddenoisingimagefilter.hxx 86


template <typename TInputImage, typename TOutputImage>
void
PatchBasedDenoisingImageFilter<TInputImage, TOutputImage>
::EmptyCaches()
{
  for (unsigned int threadId = 0;
       threadId < m_ThreadData.size(); ++threadId)
    {
    SizeValueType cacheSize = ....;
    for (SizeValueType c = 0; c < cacheSize; ++c)
      {
      delete m_ThreadData[threadId].eigenValsCache[c];
      delete m_ThreadData[threadId].eigenVecsCache[c];
      }
    m_ThreadData[threadId].eigenValsCache.empty();
    m_ThreadData[threadId].eigenVecsCache.empty();
    }
}

ITK

V530 The return value of function 'remove' is required to be utilized. itkge5imageio.cxx 297


GEImageHeader *
GE5ImageIO::ReadHeader(const char  *FileNameToRead)
{
  ....
  std::string tmpId(buffer+VOff(84,88), 13);
  std::remove(tmpId.begin(), tmpId.end(), '-');
  ....
}

ITK

V530 The return value of function 'empty' is required to be utilized. itkvideofilewriter.hxx 334


std::vector<SizeValueType>   m_Dimensions;

template< typename TInputVideoStream >
bool
VideoFileWriter< TInputVideoStream >
::InitializeOutputParameters()
{
  ....
  m_Dimensions.empty();
  ....
}

Spring Engine

V530 The return value of function 'size' is required to be utilized. assimp b3dimporter.cpp 536


void B3DImporter::ReadBB3D( aiScene *scene ){
  _textures.clear();
  _materials.size();     // <=
  _vertices.clear();
  _meshes.clear();
  ....
}

Doxygen

V530 The return value of function 'toupper' is required to be utilized. classdef.cpp 1963


int toupper (int __c);

void ClassDef::writeDocumentationContents(....)
{
  QCString pageType = " ";
  pageType += compoundTypeString();
  toupper(pageType.at(1));
  ....
}

FreeSWITCH

V530 The return value of function 'LoadLibraryExA' is required to be utilized. switch_dso.c 42


SWITCH_DECLARE(switch_dso_lib_t) switch_dso_open(....)
{
  HINSTANCE lib;

  lib = LoadLibraryEx(path, NULL, 0);

  if (!lib) {
    LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
  }

  if (!lib) {
    DWORD error = GetLastError();
    *err = switch_mprintf("dll open error [%ul]\n", error);
  }

  return lib;
}

Mozilla Thunderbird

V530 The return value of function 'getenv' is required to be utilized. nswindowswmain.cpp 134


int wmain(int argc, WCHAR **argv)
{
  ....
  // Force creation of the multibyte _environ variable.
  getenv("PATH");
  int result = main(argc, argvConverted, _environ);
  ....
}

Wine Is Not an Emulator

V530 The return value of function 'DSCF_AddRef' is required to be utilized. dsound_main.c 760


static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
{
    return 2;
}

HRESULT WINAPI DllGetClassObject(....)
{
  ....
  while (NULL != DSOUND_CF[i].rclsid) {
    if (IsEqualGUID(rclsid, DSOUND_CF[i].rclsid)) {
      DSCF_AddRef(&DSOUND_CF[i].IClassFactory_iface);  // <=
      *ppv = &DSOUND_CF[i];
      return S_OK;
    }
    i++;
  }
  ....
}

Computational Network Toolkit

V530 The return value of function 'empty' is required to be utilized. utterancesourcemulti.h 340


template <class UTTREF>
std::vector<shiftedvector<....>>getclassids(const UTTREF &uttref)
{
  std::vector<shiftedvector<....>> allclassids;
  allclassids.empty();  // <=
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'empty' is required to be utilized. utterancesourcemulti.h 364

OpenToonz

V530 The return value of function 'toUpper' is required to be utilized. sceneviewerevents.cpp 847


void SceneViewer::keyPressEvent(QKeyEvent *event)
{
  ....
  QString text = event->text();
  if ((event->modifiers() & Qt::ShiftModifier))
    text.toUpper();
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'left' is required to be utilized. tfarmserver.cpp 569
  • V530 The return value of function 'ftell' is required to be utilized. tiio_bmp.cpp 804
  • V530 The return value of function 'accumulate' is required to be utilized. bendertool.cpp 374

ReactOS

V530 The return value of function 'GetWindow' is required to be utilized. oleobject.c 113


#define IOleInPlaceSite_GetWindow(This,phwnd)\
    ( (This)->lpVtbl -> GetWindow(This,phwnd) )

static void create_shell_embedding_hwnd(WebBrowser *This)
{
  HWND parent = NULL;
  ....
  if(SUCCEEDED(hres)) {
      IOleInPlaceSite_GetWindow(inplace, &parent); // <=
      IOleInPlaceSite_Release(inplace);
  }
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'GetWindow' is required to be utilized. oleobject.c 185

Open X-Ray Engine

V530 The return value of function 'empty' is required to be utilized. actor_network.cpp 657


BOOL CActor::net_Spawn(CSE_Abstract* DC)
{
  ....
  m_States.empty();
  ....
}

Identical errors can be found in some other places:

  • V530 The return value of function 'unique' is required to be utilized. uidragdroplistex.cpp 780

Casablanca

V530 The return value of function 'release' is required to be utilized. cpprestsdk140 http_server_api.cpp 64


std::unique_ptr<http_server>
  http_server_api::s_server_api((http_server*)nullptr);

void http_server_api::unregister_server_api()
{
  pplx::extensibility::scoped_critical_section_t lock(s_lock);

  if (http_server_api::has_listener())
  {
    throw http_exception(_XPLATSTR("Server API ..... attached"));
  }

  s_server_api.release();
}

CodeLite

V530 The return value of function 'empty' is required to be utilized. tokenizer.cpp 56


StringTokenizer::StringTokenizer(const wxString& str,
                const wxString& strDelimiter,
                const bool &bAllowEmptyTokens /* false */)
{
  ....
  wxString token;
  while( nEnd != -1 )
  {
    if( nEnd != nStart)
      token = str.substr(nStart, nEnd-nStart);
    else
      token.empty();                                       // <=

    if(!token.empty())
      m_tokensArr.push_back(token);
    ....
  }
}

Clang

V530 The return value of function 'release' is required to be utilized. VerifyDiagnosticConsumer.cpp 46


std::unique_ptr<DiagnosticConsumer> takeClient()
  { return std::move(Owner); }

VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer() {
  ....
  SrcManager = nullptr;
  CheckDiagnostics();
  Diags.takeClient().release();
}

CryEngine V

V530 The return value of function 'release' is required to be utilized. ClipVolumes.cpp 492


vector<unique_ptr<CFullscreenPass>> m_jitteredDepthPassArray;

void CClipVolumesStage::PrepareVolumetricFog()
{
  ....
  for (int32 i = 0; i < m_jitteredDepthPassArray.size(); ++i)
  {
    m_jitteredDepthPassArray[i].release();
  }

  m_jitteredDepthPassArray.resize(depth);

  for (int32 i = 0; i < depth; ++i)
  {
    m_jitteredDepthPassArray[i] = CryMakeUnique<....>();
    m_jitteredDepthPassArray[i]->SetViewport(viewport);
    m_jitteredDepthPassArray[i]->SetFlags(....);
  }
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;