Examples of errors detected by the V559 diagnostic

V559. Suspicious assignment inside the condition expression of 'if/while/for' operator.


Miranda IM

V559 Suspicious assignment inside the condition expression of 'if' operator: ret = 0. clist_mw clcidents.c 179


int FindItem(....)
{
  ...
  int ret;
  ret=FindItem(hwnd,dat,hItem,
               (struct ClcContact ** )&z,
               (struct  ClcGroup** )&isv,NULL);
  if (ret=0) {return (0);}
  ...
}

This is what should have been written here: if (ret==0) {return (0);}


Miranda IM

V559 Suspicious assignment inside the condition expression of 'if' operator: Drawing->type = 1. clist_mw clcpaint.c 548


void InternalPaintClc(HWND hwnd,struct ClcData *dat,
                      HDC hdc,RECT *rcPaint)
{
  ...
  if (Drawing->type=CLCIT_CONTACT)
  ...
}

Miranda IM

V559 Suspicious assignment inside the condition expression of 'if' operator: ft->ft_magic = 0x4F. icqoscar8 icq_proto.cpp 666


int __cdecl CIcqProto::FileCancel( ... )
{
  ...
  if (dwUin && ft->ft_magic == FT_MAGIC_ICQ)
  {
    ...
  }
  else if (ft->ft_magic = FT_MAGIC_OSCAR)
  {
    ...
  }
  ...
}

This is what should have been written here: else if (ft->ft_magic == FT_MAGIC_OSCAR)


Intel AMT SDK

V559 Suspicious assignment inside the condition expression of 'if' operator: status = true. AgentPresenceAPIConsole agentpresenceapiconsole.cpp 530


bool SetCBPolicy(....)
{
  ...
  if(status = true)
  {
    PrintSuccess();
  }

  return status;
}

This is what should have been written here: if(status == true)

Identical errors can be found in some other places:

  • V559 Suspicious assignment inside the condition expression of 'if' operator: status = true. CircuitBreaker circuitbreakersample.cpp 1637

Data Distribution Service

V559 Suspicious assignment inside the condition expression of 'if' operator: dsqp.service_cleanup_delay.sec = 4. ut_parameterlistconverter.cpp 1295


int
ACE_TMAIN(int, ACE_TCHAR*[])
{
  ....
  TEST_ASSERT(dsqp.service_cleanup_delay.sec = 4);
  TEST_ASSERT(dsqp.service_cleanup_delay.nanosec = 2000);
  TEST_ASSERT(dsqp.history_kind == KEEP_LAST_HISTORY_QOS);
  TEST_ASSERT(dsqp.history_depth == 172);
  TEST_ASSERT(dsqp.max_samples == 389);
  TEST_ASSERT(dsqp.max_instances == 102);
  TEST_ASSERT(dsqp.max_samples_per_instance == 20);
  ....
}

Identical errors can be found in some other places:

  • V559 Suspicious assignment inside the condition expression of 'if' operator. ut_parameterlistconverter.cpp 1296

Scilab

V559 Suspicious assignment inside the condition expression of 'if' operator: status = 1. set_view_property.c 61


int set_view_property(....)
{
  BOOL status = FALSE;
  ....
  status = setGraphicObjectProperty(
    pobjUID, __GO_VIEW__, &viewType, jni_int, 1);

  if (status = TRUE)
  {
    return SET_PROPERTY_SUCCEED;
  }
  else
  {
    Scierror(999, _("'%s' property does not exist ")
      _("for this handle.\n"), "view");
    return  SET_PROPERTY_ERROR ;
  }
  ....
}

Miranda NG

V559 Suspicious assignment inside the condition expression of 'if' operator: k = 15. NimContact contactinfo.cpp 339


#define MAX_REPLACES 15

INT_PTR CALLBACK DlgProcCopy(....)
{
  ....
  if (string == newString[k])
    k--;
  if (k = MAX_REPLACES) break;
  string = oldString[++k];
  i+=2;
  ....
}

Miranda NG

V559 Suspicious assignment inside the condition expression of 'if' operator: Order = - - 1. NewAwaySys msgtree.cpp 677


CBaseTreeItem* CMsgTree::GetNextItem(....)
{
  ....
  int Order = TreeCtrl->hItemToOrder(TreeView_GetNextItem(....));
  if (Order =- -1)
    return NULL;
  ....
}

The GTK+ Project

V559 Suspicious assignment inside the condition expression of 'if' operator. gdkselection-x11.c 741


gboolean
gdk_x11_display_utf8_to_compound_text (....)
{
  ....
  GError *error = NULL;
  ....
  if (!(error->domain = G_CONVERT_ERROR &&
        error->code == G_CONVERT_ERROR_ILLEGAL_SEQUENCE))
  ....
}

Serious Engine 1 v.1.10

V559 Suspicious assignment inside the condition expression of 'if' operator: pwndView = 0. mainfrm.cpp 697


void CMainFrame::OnCancelMode()
{
  // switches out of eventual direct screen mode
  CWorldEditorView *pwndView = (....)GetActiveView();
  if (pwndView = NULL) {                             // <=
    // get the MDIChildFrame of active window
    CChildFrame *pfrChild = (....)pwndView->GetParentFrame();
    ASSERT(pfrChild!=NULL);
  }
  CMDIFrameWnd::OnCancelMode();
}

Identical errors can be found in some other places:

  • V559 Suspicious assignment inside the condition expression of 'if' operator: pwndView = 0. mainfrm.cpp 710

Serious Engine 1 v.1.10

V559 Suspicious assignment inside the condition expression of 'if' operator: _strModURLSelected = "". menu.cpp 1188


CTString _strModURLSelected;

void JoinNetworkGame(void)
{
  ....
  char strModURL[256] = {0};
  _pNetwork->ga_strRequiredMod.ScanF(...., &strModURL);
  _fnmModSelected = CTString(strModName);
  _strModURLSelected = strModURL; // <=
  if (_strModURLSelected="") {    // <=
    _strModURLSelected = "http://www.croteam.com/mods/Old";
  }
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;