Examples of errors detected by the V560 diagnostic

<< Return to list of all diagnostics

V560. A part of conditional expression is always true/false.


Lugaru

V560 A part of conditional expression is always true: 3. Lugaru person.cpp 2472


void Person::DoAnimations(){
  ...
  if(findDistancefast(
    &coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&
    animation[victim->targetanimation].height!=lowheight){
  ...
}

This is not an error, but 3 is obviously unnecessary.


Notepad++

V560 A part of conditional expression is always true: 0xff. notepadPlus babygrid.cpp 694


TCHAR GetASCII(WPARAM wParam, LPARAM lParam)
{
  ...
  result=ToAscii(wParam,(lParam >> 16) && 0xff,
                 keys,&dwReturnedValue,0);
  ...
}

This is what should have been written here: &.


PCSX2

V560 A part of conditional expression is always true: 2. pcsx2 debugger.cpp 321


LRESULT CALLBACK IOP_DISASM(HWND hDlg, UINT message,
                        WPARAM wParam, LPARAM lParam)
{
  ...
  switch(LOWORD(wParam))
  {
    case (IDOK || IDCANCEL):
      EndDialog(hDlg,TRUE);
      return(TRUE);
      break;
  }
  ...
}

Most likely this is what should be written here: case IDOK: case IDCANCEL:


Stickies

V560 A part of conditional expression is always true: (0x02000000L). stickies document.cpp 106

V560 A part of conditional expression is always true: (0x04000000L). stickies document.cpp 112


#define REO_INPLACEACTIVE  (0x02000000L)
#define REO_OPEN           (0x04000000L)

CDocument::~CDocument()
{
  ...
  if (reObj.dwFlags && REO_INPLACEACTIVE)
    m_pRichEditOle->InPlaceDeactivate();

  if(reObj.dwFlags && REO_OPEN)
    hr = reObj.poleobj->Close(OLECLOSE_NOSAVE);
  ...
}

This is what should have been written here: &.


PCRE

V560 A part of conditional expression is always true: 0x04. Regex pcre.c 2887


#define ctype_digit   0x04

static BOOL
compile_branch(....)
{
  ...
  else if ((digitab[ptr[1]] && ctype_digit) != 0)
  ...
}

This is what should have been written here: &.


WinDjView

V560 A part of conditional expression is always true: 0xA. WinDjView xmlparser.cpp 45


inline bool IsValidChar(int c)
{
  return c == 0x9 || 0xA || c == 0xD ||
         c >= 0x20 && c <= 0xD7FF ||
         c >= 0xE000 && c <= 0xFFFD ||
         c >= 0x10000 && c <= 0x10FFFF;
}

Miranda IM

V560 A part of conditional expression is always false: 0. clist_modern modern_clui.cpp 2979


LRESULT CLUI::OnDrawItem( UINT msg, WPARAM wParam,
                          LPARAM lParam )
{
  ...
  DrawState(dis->hDC,NULL,NULL,(LPARAM)hIcon,0,
    dis->rcItem.right+dis->rcItem.left-
    GetSystemMetrics(SM_CXSMICON))/2+dx,
    (dis->rcItem.bottom+dis->rcItem.top-
    GetSystemMetrics(SM_CYSMICON))/2+dx,
    0,0,
    DST_ICON|
    (dis->itemState&ODS_INACTIVE&&FALSE?
     DSS_DISABLED:DSS_NORMAL));
  ...
}

There are some conditions which are always true or wrong. Most likely this was made on purpose (to disable some code branches), but in some fragments it looks strange. You may easily forget of fragments like this, for instance. By the way, this code is formatted. It's just one string in the program. How are you going to find this FALSE later?..


Miranda IM

V560 A part of conditional expression is always true: 0x01000. tabsrmm tools.cpp 1023


#define GC_UNICODE 0x01000

DWORD dwFlags;

UINT CreateGCMenu(....)
{
  ...
  if (iIndex == 1 && si->iType != GCW_SERVER &&
      !(si->dwFlags && GC_UNICODE)) {
  ...
}

This is what should have been written here: (si->dwFlags & GC_UNICODE)


Miranda IM

V560 A part of conditional expression is always true: 0x29. icqoscar8 fam_03buddy.cpp 632


void CIcqProto::handleUserOffline(BYTE *buf, WORD wLen)
{
  ...
  else if (wTLVType = 0x29 && wTLVLen == sizeof(DWORD))
  ...
}

This is what should have been written here: wTLVType == 0x29


QT

V560 A part of conditional expression is always true: 0x20000000. QtCore qcoreapplication_win.cpp 870

V560 A part of conditional expression is always true: 0x40000000. QtCore qcoreapplication_win.cpp 871

V560 A part of conditional expression is always true: 0x80000000. QtCore qcoreapplication_win.cpp 872


QString decodeMSG(const MSG& msg)
{
  ...
  int repCount     = (lKeyData & 0xffff);        // Bit 0-15
  int scanCode     = (lKeyData & 0xf0000) >> 16; // Bit 16-23
  bool contextCode = (lKeyData && 0x20000000);   // Bit 29
  bool prevState   = (lKeyData && 0x40000000);   // Bit 30
  bool transState  = (lKeyData && 0x80000000);   // Bit 31
  ...
}

This place is not crucial, but still needs paying attention to.


QT

V560 A part of conditional expression is always true: 0x00000001. QtMultimedia qaudiodeviceinfo_win32_p.cpp 322

V560 A part of conditional expression is always true: 0x00000002. QtMultimedia qaudiodeviceinfo_win32_p.cpp 323

V560 A part of conditional expression is always true: 0x00000010. QtMultimedia qaudiodeviceinfo_win32_p.cpp 324

V560 A part of conditional expression is always true: 0x00000020. QtMultimedia qaudiodeviceinfo_win32_p.cpp 325

V560 A part of conditional expression is always true: 0x00000100. QtMultimedia qaudiodeviceinfo_win32_p.cpp 326

V560 A part of conditional expression is always true: 0x00000200. QtMultimedia qaudiodeviceinfo_win32_p.cpp 327

V560 A part of conditional expression is always true: 0x00001000. QtMultimedia qaudiodeviceinfo_win32_p.cpp 329

V560 A part of conditional expression is always true: 0x00002000. QtMultimedia qaudiodeviceinfo_win32_p.cpp 330

V560 A part of conditional expression is always true: 0x00010000. QtMultimedia qaudiodeviceinfo_win32_p.cpp 331

V560 A part of conditional expression is always true: 0x00020000. QtMultimedia qaudiodeviceinfo_win32_p.cpp 332


#define WAVE_FORMAT_1M08       0x00000001
#define WAVE_FORMAT_1S08       0x00000002
...

void QAudioDeviceInfoInternal::updateLists()
{
  ...
  DWORD fmt;
  ...
  if((fmt && WAVE_FORMAT_1M08)
     || (fmt && WAVE_FORMAT_1S08)
     || (fmt && WAVE_FORMAT_2M08)
     || (fmt && WAVE_FORMAT_2S08)
     || (fmt && WAVE_FORMAT_4M08)
     || (fmt && WAVE_FORMAT_4S08)
  #ifndef Q_OS_WINCE
     || (fmt && WAVE_FORMAT_48M08)
     || (fmt && WAVE_FORMAT_48S08)
     || (fmt && WAVE_FORMAT_96M08)
     || (fmt && WAVE_FORMAT_96S08)
  #endif
  )
  ...
}

libmng

V560 A part of conditional expression is always true: 0xFF. qmng libmng_pixels.c 14670


mng_retcode mng_promote_g8_g16 (mng_datap pData)
{
  ...
  mng_uint16 iW;
  ...
  *pDstline     = (mng_uint8)(iW >> 8);
  *(pDstline+1) = (mng_uint8)(iW && 0xFF);
  ...
}

This is what should have been written here: *(pDstline+1) = (mng_uint8)(iW & 0xFF);

Identical errors can be found in some other places:

  • V560 A part of conditional expression is always true: 0xFF. qmng libmng_pixels.c 14788
  • V560 A part of conditional expression is always true: 0xFF. qmng libmng_pixels.c 14909
  • V560 A part of conditional expression is always true: 0xFF. qmng libmng_pixels.c 15043
  • And 21 additional diagnostic messages.

Apache HTTP Server

V560 A part of conditional expression is always true: 0x04. pcre pcre.c 3366


static BOOL
compile_branch(....)
{
  ...
  else if ((digitab[ptr[1]] && ctype_digit) != 0)
  ...
}

This is what should have been written here: else if ((digitab[ptr[1]] & ctype_digit) != 0)


Fireflies

V560 A part of conditional expression is always true: embedded_block != first_block. Fireflies concurrent_hash_map.h 1299


static size_type const embedded_block = 1;
static size_type const first_block = 8;

template
<typename Key, typename T, typename HashCompare, typename A>
void concurrent_hash_map<Key,T,HashCompare,A>::clear() {
  ...
  else if(s == embedded_block && embedded_block != first_block)
  ...
}

ReactOS

V560 A part of conditional expression is always true: ACO_AUTOSUGGEST. shell32 autocomplete.c 451


enum _tagAUTOCOMPLETEOPTIONS
{
  ACO_AUTOSUGGEST = 0x1,
  ...
}

static LRESULT APIENTRY ACEditSubclassProc()
{
  ...
  if ((This->options && ACO_AUTOSUGGEST) &&
      ((HWND)wParam != This->hwndListBox))
  ...
}

&& and & are mixed up. This is what should have been written here: if ((This->options & ACO_AUTOSUGGEST) &&.


ReactOS

V560 A part of conditional expression is always true: 2. netshell lanstatusui.c 182


VOID
UpdateLanStatus(HWND hwndDlg,  LANSTATUSUI_CONTEXT * pContext)
{
  ...
  else if (IfEntry.dwOperStatus ==
    MIB_IF_OPER_STATUS_UNREACHABLE ||
      MIB_IF_OPER_STATUS_DISCONNECTED)
  ...
}

|| and | are mixed up.


ReactOS

V560 A part of conditional expression is always true: 10035L. adns transmit.c 203


void adns__querysend_tcp(adns_query qu, struct timeval now) {
  ...
  if (!(errno == EAGAIN || EWOULDBLOCK ||
        errno == EINTR || errno == ENOSPC ||
        errno == ENOBUFS || errno == ENOMEM)) {
  ...
}

A comparison is missing. This is what should have been written here: ... || errno == EWOULDBLOCK || ...


Notepad++

V560 A part of conditional expression is always true: 20. lextads3.cxx 700

V560 A part of conditional expression is always true: 20. wxscintilla lextads3.cxx 701


static inline bool IsAnOperator(const int style) {
  return style == SCE_T3_OPERATOR || SCE_T3_BRACE;
}

This is what should have been written here: return style == SCE_T3_OPERATOR || style == SCE_T3_BRACE;


DeSmuME

V560 A part of conditional expression is always true: !found_break. DeSmuME_VS2005 gdbstub.cpp 1002


INLINE static int check_breaks_gdb(....) {
  int found_break = 0;
  ...
  while ( bpoint != NULL && !found_break) {
    ...
    found_break not used inside loop
    ...
  }
  return found_break;
}

MongoDB

V560 A part of conditional expression is always false: it > 20. d_migrate.cpp 565

V560 A part of conditional expression is always true: it % 10 == 0. d_migrate.cpp 565


void doRemove( OldDataCleanup& cleanup ) {
  int it = 0;
  while ( true ) {
    if ( it > 20 && it % 10 == 0 )
    {
      scoped_lock ll(_workLock);
      if ( ! _active ) {
        cleanup.doRemove();
        return;
      }
    }
    sleepmillis( 1000 );
  }
}

'it' doesn't change.


ffdshow

V560 A part of conditional expression is always true: 0x2. ffdshowremoteapi.cpp 314


#define ROTFLAGS_REGISTRATIONKEEPSALIVE 0x1
#define ROTFLAGS_ALLOWANYCLIENT 0x2

virtual HRESULT STDMETHODCALLTYPE Register(DWORD grfFlags, ....);

LRESULT CALLBACK Tremote::remoteWndProc(
  HWND hwnd, UINT msg, WPARAM wprm, LPARAM lprm)
{
  ....
  pROT->Register(
    ROTFLAGS_REGISTRATIONKEEPSALIVE && ROTFLAGS_ALLOWANYCLIENT,
        (IUnknown*)pGraph, pMoniker, &pdwROT);
  ....
}

This is what should have been written here: ROTFLAGS_REGISTRATIONKEEPSALIVE & ROTFLAGS_ALLOWANYCLIENT


libmng

V560 A part of conditional expression is always true: 0xFF. libmng_pixels.c 15540

V560 A part of conditional expression is always true: 0xFF. libmng_pixels.c 15542

V560 A part of conditional expression is always true: 0xFF. libmng_pixels.c 15544


mng_retcode mng_promote_idx8_rgb16 (mng_datap pData)
{
  ....
  *(pDstline+1)   = (mng_uint8)(iR && 0xFF);
  *(pDstline+2)   = (mng_uint8)(iG >> 8);
  *(pDstline+3)   = (mng_uint8)(iG && 0xFF);
  *(pDstline+4)   = (mng_uint8)(iB >> 8);
  *(pDstline+5)   = (mng_uint8)(iB && 0xFF);
  ....
}

CxImage

V560 A part of conditional expression is always true: (p->height = 2760). libdcr.c 7479


void DCR_CLASS dcr_identify(DCRAW* p)
{
  ....
  if (--p->height == 2798 && (p->height = 2760))
    p->top_margin = 15;
  ....
}

NetDefender Firewall

V560 A part of conditional expression is always false: nIdDll. pphtmldrawer.cpp 2723


SIZE CPPHtmlDrawer::DrawHtmlString (
  CPPString & sHtml, LPCRECT lpRect)
{
  ....
  nIdRes = 0;
  nIdDll = 0;
  while (nIndex < sProperties.GetLength())
  {
    ....
    if (sParameter == _T("idres"))
      nIdRes = GetLengthUnit(sValue, nIdRes);
    else if (sParameter == _T("iddll"))
      nIdRes = GetLengthUnit(sValue, nIdDll);
    ....
  }
  if (nIdRes || nIdDll)
  ....
}

Most likely this is what should be written here: nIdDll = GetLengthUnit(sValue, nIdDll);


<< Return to list of all diagnostics