Examples of errors detected by the V560 diagnostic.


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.


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);

Similar 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


#define SCE_T3_OPERATOR 5
#define SCE_T3_BRACE 20

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);


Multi Theft Auto

V560 A part of conditional expression is always true: 0xff. c3dmarkersa.cpp 78

V560 A part of conditional expression is always true: 0xff. c3dmarkersa.cpp 79

V560 A part of conditional expression is always true: 0xff. c3dmarkersa.cpp 80

V560 A part of conditional expression is always true: 0xff. c3dmarkersa.cpp 81


SColor C3DMarkerSA::GetColor()
{
  DEBUG_TRACE("RGBA C3DMarkerSA::GetColor()");
  // From ABGR
  unsigned long ulABGR = this->GetInterface()->rwColour;
  SColor color;
  color.A = ( ulABGR >> 24 ) && 0xff;
  color.B = ( ulABGR >> 16 ) && 0xff;
  color.G = ( ulABGR >> 8 ) && 0xff;
  color.R = ulABGR && 0xff;
  return color;
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: 0xff. ccheckpointsa.cpp 81
  • V560 A part of conditional expression is always true: 0xff. ccheckpointsa.cpp 82
  • V560 A part of conditional expression is always true: 0xff. ccheckpointsa.cpp 83
  • And 1 additional diagnostic messages.

LibRaw

V560 A part of conditional expression is always true: ((imgdata.color.maximum) = 0xfff). dcraw_common.cpp 8496


void CLASS identify()
{
  ....
  if (!load_raw && (maximum = 0xfff))
  ....
}

Scilab

V560 A part of conditional expression is always false: (m1 != n1). sci_playsound.c 66

V560 A part of conditional expression is always true: (n1 != 1). sci_playsound.c 66


int sci_Playsound (char *fname,unsigned long fname_len)
{
  ....
  int m1 = 0, n1 = 0;
  ....
  if ( (m1 != n1) && (n1 != 1) )
  {
    Scierror(999,_("%s: Wrong size for input argument #%d: ")
                 _("A string expected.\n"),fname,1);
    return 0;
  }
  sciErr = getMatrixOfWideString(pvApiCtx, piAddressVarOne,
             &m1,&n1,&lenStVarOne, NULL);
  ....
}

OGDF

V560 A part of conditional expression is always true: 0xffffffff. hashing.h 255


//! Specialized default hash function for pointer types.
template<> class DefHashFunc<void *> {
  public:
  size_t hash(const void * &key) const
    { return size_t(key && 0xffffffff); }
};

OpenMW

V560 A part of conditional expression is always true: UpperCharState_UnEquipingWeap. openmw character.cpp 949


enum UpperBodyCharacterState
{
  UpperCharState_Nothing,
  UpperCharState_EquipingWeap,
  UpperCharState_UnEquipingWeap,
  ....
};

bool CharacterController::updateWeaponState()
{
  ....
  if((weaptype != WeapType_None ||
      UpperCharState_UnEquipingWeap) && animPlaying)
  ....
}

OpenJPEG

V560 A part of conditional expression is always true: RLCP. pi.c 1708


typedef enum PROG_ORDER {
  PROG_UNKNOWN = -1,
  LRCP = 0,
  RLCP = 1,
  RPCL = 2,
  PCRL = 3,
  CPRL = 4
} OPJ_PROG_ORDER;

OPJ_INT32 pi_check_next_level(....)
{
  ....
  case 'P':
    switch(tcp->prg)
    {
      case LRCP||RLCP:
        if(tcp->prc_t == tcp->prcE){
          l=pi_check_next_level(i-1,cp,tileno,pino,prog);
  ....
}

Most likely this is what should be written here: case LRCP: .... case RLCP: ....


Miranda NG

V560 A part of conditional expression is always true: 0x0040. TopToolBar toolbar.cpp 307


#define TTBBF_ISLBUTTON      0x0040

INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam)
{
  ....
  if (!(but->dwFlags && TTBBF_ISLBUTTON) &&
      nameexists(but->name))
    return -1;
  ....
}

Spring Engine

V560 A part of conditional expression is always true: 0xFFFF. engine-dedicated%engine-headless%engine-legacy%unitsync cpuid.cpp 144


void CpuId::getMasksIntelLeaf11Enumerate()
{
  ....
  if ((ebx && 0xFFFF) == 0)        // <=
    return;

  if (((ecx >> 8) & 0xFF) == 1) {
    LOG_L(L_DEBUG,"[CpuId] SMT level found");
    shiftCore = eax & 0xf;
  } else {
    LOG_L(L_DEBUG,"[CpuId] No SMT level supported");
  }
  ....
}

SETI@home

V560 A part of conditional expression is always true: 0xff. seti_header.cpp 96


struct SETI_WU_INFO : public track_mem<SETI_WU_INFO>
{
  ....
  int splitter_version;
  ....
};

SETI_WU_INFO::SETI_WU_INFO(const workunit &w):....
{
  ....
  splitter_version=(int)floor(w.group_info->
    splitter_cfg->version)*0x100;
  splitter_version+=(int)((w.group_info->
    splitter_cfg->version)*0x100) && 0xff;
  ....
}

Unreal Engine 4

V560 A part of conditional expression is always true: FBasicToken::TOKEN_Guid. k2node_mathexpression.cpp 235


virtual FString ToString() const override
{
  if (Token.TokenType == FBasicToken::TOKEN_Identifier ||
      FBasicToken::TOKEN_Guid)                      // <=
  {
    return FString::Printf(TEXT("%s"), Token.Identifier);
  }
  else if (Token.TokenType == FBasicToken::TOKEN_Const)
  {
    return FString::Printf(TEXT("%s"),*Token.GetConstantValue());
  }
  else
  {
    ....
  }
}

Unreal Engine 4

V560 A part of conditional expression is always false: !FileReader. savepackage.cpp 721


bool
CompressFile( const TCHAR* DstFilename, ULinkerSave* SrcLinker )
{
 ....
 FMemoryReader Reader(*(FBufferArchive*)(SrcLinker->Saver),true);
 FArchive* FileReader = &Reader;
 FArchive* FileWriter = IFileManager::Get()....
 // ... and abort if either operation wasn't successful.
 if( !FileReader || !FileWriter )
 {
   ....
}

Apple II emulator

V560 A part of conditional expression is always true: (byteval[1] = 0xAA). diskimagehelper.cpp 439


void CImageBase::DenibblizeTrack(....)
{
  ....
  BYTE byteval[3] = {0,0,0};
  int  bytenum    = 0;
  ....
  if ((bytenum == 3) && (byteval[1] = 0xAA))
  ....
}

It is necessary to use comparision operator instead of assignment one: if ((bytenum == 3) && (byteval[1] == 0xAA))


Gamer_Z eXtreme Party

V560 A part of conditional expression is always true: (3). adminspectate.cxx 43


bool PlayerSpactatable(int playerid)
{
  static int state;
  state = GetPlayerState(playerid);
  return (state == PLAYER_STATE_ONFOOT ||
          state == PLAYER_STATE_DRIVER ||
          PLAYER_STATE_PASSENGER);                // <=
}

Doxygen

V560 A part of conditional expression is always true: !found. util.cpp 4264


bool getDefs(....)
{
  ....
  bool found=FALSE;
  MemberListIterator mmli(*mn);
  MemberDef *mmd;
  for (mmli.toFirst();((mmd=mmli.current()) && !found);++mmli)
  {
    ....
    //variable 'found' does not change value
    ....
  }
  ....
}

Doxygen

V560 A part of conditional expression is always false: (flags() &!0x0008). qfile_win32.cpp 267


#define IO_Truncate    0x0008

bool QFile::open(....)
{
  ....
  int length = INT_MAX;
  if ((flags() & !IO_Truncate) && length == 0 && isReadable())
  ....
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always false: (flags() &!0x0008). qfile_win32.cpp 337

Telegram

V560 A part of conditional expression is always true: radius < 16. Telegram images.cpp 241


QImage imageBlur(QImage img)
{
  ....
  const int radius = 3;
  ....
  if (radius < 16 && ....)
  ....
}

Oracle VM Virtual Box

V560 A part of conditional expression is always true: 0x1fbe. tstiprtministring.cpp 442


static void test2(RTTEST hTest)
{
  ....
  for (RTUNICP uc = 1; uc <= 0x10fffd; uc++)
  {
    if (uc == 0x131 || uc == 0x130 || uc == 0x17f || 0x1fbe)// <=
      continue;                                    //^^^^^^

    if (RTUniCpIsLower(uc))
    {
      RTTESTI_CHECK_MSG(....), ("%#x\n", uc));
      strLower.appendCodePoint(uc);
    }
    if (RTUniCpIsUpper(uc))
    {
      RTTESTI_CHECK_MSG(....), ("%#x\n", uc));
      strUpper.appendCodePoint(uc);
    }
  }
  ....
}

The GTK+ Project

V560 A part of conditional expression is always false: !auto_mnemonics. gtklabel.c 2693


static void
gtk_label_set_markup_internal (....)
{
  ....

  gboolean enable_mnemonics = TRUE;
  gboolean auto_mnemonics = TRUE;

  g_object_get (gtk_widget_get_settings (GTK_WIDGET (label)),
                "gtk-enable-mnemonics", &enable_mnemonics,
                NULL);

  if (!(enable_mnemonics && priv->mnemonics_visible &&
        (!auto_mnemonics ||
         (gtk_widget_is_sensitive (GTK_WIDGET (label)) &&
          (!priv->mnemonic_widget ||
           gtk_widget_is_sensitive (priv->mnemonic_widget))))))
  ....
}

Variable 'enable_mnemonics' is created near the 'auto_mnemonics' variable and is then initialized to a value from the settings. Perhaps the value for 'auto_mnemonics' must have been retrieved in a similar way, too.


The GTK+ Project

V560 A part of conditional expression is always false: !auto_mnemonics. gtklabel.c 2923


static void
gtk_label_set_pattern_internal (....)
{
  ....
  gboolean enable_mnemonics = TRUE;
  gboolean auto_mnemonics = TRUE;

  ....
  g_object_get (gtk_widget_get_settings (GTK_WIDGET (label)),
                "gtk-enable-mnemonics", &enable_mnemonics,
                NULL);

  if (enable_mnemonics && priv->mnemonics_visible && pattern &&
      (!auto_mnemonics ||
       (gtk_widget_is_sensitive (GTK_WIDGET (label)) &&
        (!priv->mnemonic_widget ||
         gtk_widget_is_sensitive (priv->mnemonic_widget)))))
  ....
}

Variable 'enable_mnemonics' is created near the 'auto_mnemonics' variable and is then initialized to a value from the settings. Perhaps the value for 'auto_mnemonics' must have been retrieved in a similar way, too.


Firebird

V560 A part of conditional expression is always false: !field. int_cxx.cpp 217


static void asgn_from( ref* reference, int column)
{
  TEXT variable[MAX_REF_SIZE];
  TEXT temp[MAX_REF_SIZE];

  for (; reference; reference = reference->ref_next)
  {
    const gpre_fld* field = reference->ref_field;
    ....

    if (!field || field->fld_dtype == dtype_text)
      ....
    else if (!field || field->fld_dtype == dtype_cstring)
      ....
    else
      ....
  }
}

Open X-Ray Engine

V560 A part of conditional expression is always true: 0x000000FF. nvi_image.cpp 170


void NVI_Image::ABGR8_To_ARGB8()
{
  // swaps RGB for all pixels
  assert(IsDataValid());
  assert(GetBytesPerPixel() == 4);
  UINT hxw = GetNumPixels();
  for (UINT i = 0; i < hxw; i++)
  {
    DWORD col;
    GetPixel_ARGB8(&col, i);
    DWORD a = (col >> 24) && 0x000000FF;
    DWORD b = (col >> 16) && 0x000000FF;
    DWORD g = (col >> 8)  && 0x000000FF;
    DWORD r = (col >> 0)  && 0x000000FF;
    col = (a << 24) | (r << 16) | (g << 8) | b;
    SetPixel_ARGB8(i, col);
  }
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: 0x000000FF. nvi_image.cpp 171
  • V560 A part of conditional expression is always true: 0x000000FF. nvi_image.cpp 172
  • V560 A part of conditional expression is always true: 0x000000FF. nvi_image.cpp 173

WPF samples by Microsoft

V560 A part of conditional expression is always true. aitdecoder.cpp 634


enum WICBitmapDecoderCapabilities
{
  WICBitmapDecoderCapabilitySameEncoder = 0x1,
  WICBitmapDecoderCapabilityCanDecodeAllImages = 0x2,
  WICBitmapDecoderCapabilityCanDecodeSomeImages = 0x4,
  WICBitmapDecoderCapabilityCanEnumerateMetadata = 0x8,
  WICBitmapDecoderCapabilityCanDecodeThumbnail = 0x10,
  WICBITMAPDECODERCAPABILITIES_FORCE_DWORD = 0x7fffffff
};

STDMETHODIMP AitDecoder::QueryCapability(....)
{
  ....
  // If this is our format, we can do everything
  if (strcmp(bh.Name, "AIT") == 0)
  {
     *pCapability =
       WICBitmapDecoderCapabilityCanDecodeAllImages ||
       WICBitmapDecoderCapabilityCanDecodeThumbnail ||
       WICBitmapDecoderCapabilityCanEnumerateMetadata ||
       WICBitmapDecoderCapabilitySameEncoder;
  }
  ....
}

OpenJDK

V560 A part of conditional expression is always false: 0. addnode.cpp 435


Node *AddLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
  ....
  if( op2 == Op_AddL &&
      in2->in(1) == in1 &&
      op1 != Op_ConL &&
      0 ) {
  ....
}

Blender

V560 A part of conditional expression is always true: nearest == 0. boids.c 361


static int rule_avoid_collision(....)
{
    ....
    int n, neighbors = 0, nearest = 0; //<=
    ....
    if (ptn && nearest==0)             //<=
        MEM_freeN(ptn);

    return ret;
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: edit == 0. particle.c 3781
  • V560 A part of conditional expression is always true: !error. pointcache.c 154
  • V560 A part of conditional expression is always true: !error. pointcache.c 2742
  • And 14 additional diagnostic messages.

ReOpenLDAP

V560 A part of conditional expression is always true: !saveit. syncprov.c 1510


static void
syncprov_matchops( Operation *op, opcookie *opc, int saveit )
{
  ....
  if ( saveit || op->o_tag == LDAP_REQ_ADD ) {
    ....
  } else if ( op->o_tag == LDAP_REQ_MODRDN && !saveit ) {
    ....
  }
  ....
}

Far2l

V560 A part of conditional expression is always true: Key == 0x75. Key.cpp 493


int FTP::ProcessKey(int Key, unsigned int ControlState)
{
  ....
  if(   !ShowHosts
     && (ControlState == 0 || ControlState == PKF_SHIFT)
     && Key == VK_F6)                     // <=
  {
    FTP *ftp = OtherPlugin(this);
    int  rc;

    if(   !ftp
       && ControlState == 0
       && Key == VK_F6)                   // <=
    {
      return FALSE;
    }
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: !cps. DString.cpp 47
  • V560 A part of conditional expression is always true: !ShowHosts. FGet.cpp 139
  • V560 A part of conditional expression is always false: !wsz. cnDownload.cpp 190
  • And 1 additional diagnostic messages.

FreeBSD Kernel

V560 A part of conditional expression is always true: 0x2002. sampirsp.c 7224


#define OSSA_MPI_ENC_ERR_ILLEGAL_DEK_PARAM            0x2001
#define OSSA_MPI_ERR_DEK_MANAGEMENT_DEK_UNWRAP_FAIL   0x2002

GLOBAL bit32 mpiDekManagementRsp(
  agsaRoot_t               *agRoot,
  agsaDekManagementRsp_t   *pIomb
  )
{
  ....
  if (status == OSSA_MPI_ENC_ERR_ILLEGAL_DEK_PARAM ||
      OSSA_MPI_ERR_DEK_MANAGEMENT_DEK_UNWRAP_FAIL)
  {
    agEvent.eq = errorQualifier;
  }
  ....
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: 0x7dac. t4_main.c 8001

FreeBSD Kernel

V560 A part of conditional expression is always true: 0x7dac. t4_main.c 8001


#define A_TP_KEEP_INTVL 0x7dac

static int
sysctl_tp_timer(SYSCTL_HANDLER_ARGS)
{
  struct adapter *sc = arg1;
  int reg = arg2;
  u_int tre;
  u_long tp_tick_us, v;
  u_int cclk_ps = 1000000000 / sc->params.vpd.cclk;

  MPASS(reg == A_TP_RXT_MIN || reg == A_TP_RXT_MAX ||
      reg == A_TP_PERS_MIN || reg == A_TP_PERS_MAX ||
      reg == A_TP_KEEP_IDLE || A_TP_KEEP_INTVL ||           // <=
      reg == A_TP_INIT_SRTT || reg == A_TP_FINWAIT2_TIMER);
  ....
}

Notepad++

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


TCHAR GetASCII(WPARAM wParam, LPARAM lParam)
{
  int returnvalue;
  TCHAR mbuffer[100];
  int result;
  BYTE keys[256];
  WORD dwReturnedValue;
  GetKeyboardState(keys);
  result = ToAscii(static_cast<UINT>(wParam),
    (lParam >> 16) && 0xff, keys, &dwReturnedValue, 0); // <=
  returnvalue = (TCHAR) dwReturnedValue;
  if(returnvalue < 0){returnvalue = 0;}
  wsprintf(mbuffer, TEXT("return value = %d"), returnvalue);
  if(result!=1){returnvalue = 0;}
  return (TCHAR)returnvalue;
}

This is what should have been written here: &.


Tizen

V560 A part of conditional expression is always false: val == 1. player_es_push_test.c 284


int bytestream2nalunit(FILE * fd, unsigned char *nal)
{
  unsigned char val, zero_count, i;
  ....
  val = buffer[0];
  while (!val) {                                           // <=
    if ((zero_count == 2 || zero_count == 3) && val == 1)  // <=
      break;
    zero_count++;
    result = fread(buffer, 1, read_size, fd);

    if (result != read_size)
      break;
    val = buffer[0];
  }
  ....
}

Tizen

V560 A part of conditional expression is always true: GT_SEARCH_ONLY_LONGER. scim_generic_table.cpp 1884


const int GT_SEARCH_NO_LONGER = 0,
          GT_SEARCH_INCLUDE_LONGER = 1,
          GT_SEARCH_ONLY_LONGER = 2;

bool GenericTableContent::search (const String &key,
                                  int search_type) const
{
  ....
  else if (nkeys.size () > 1 && GT_SEARCH_ONLY_LONGER) {
  ....
}

Most likely this is what should be written here: (nkeys.size () > 1 && search_type == GT_SEARCH_ONLY_LONGER)


Enlightenment

V560 A part of conditional expression is always false: (len > 1). e_fm.c 6110


static void
_e_fm2_typebuf_char_backspace(Evas_Object *obj)
{
  ....
  int len, p, dec;
  ....
  if ((len > 1) || (sd->typebuf.buf[0] == '/'))
  {
    ....
  }
  else if ((len > 1) || (sd->typebuf.buf[0] != '~'))       // <=
  {
    ....
  }
  else if (!memcmp(sd->typebuf.buf, "~/", 2))
  {
    ....
  }
  ....
}

Enlightenment

V560 A part of conditional expression is always false: (!ec). e_comp_x.c 2481


static Eina_Bool _e_comp_x_mouse_up(....)
{
  E_Client *ec;
  ....
  ec = _e_comp_x_client_find_by_window(ev->window);
  if ((!ec) && (ev->window != ev->event_window))
    ec = _e_comp_x_client_find_by_window(ev->event_window);
  if (!ec)
  {
    if (e_client_comp_grabbed_get())
      ec = e_client_action_get();
    if (!ec) return ECORE_CALLBACK_RENEW;
  }
  if ((!ec) || e_client_util_ignored_get(ec))              // <=
    return ECORE_CALLBACK_RENEW;
  ....
}

EFL Core Libraries

V560 A part of conditional expression is always true: headbyte <= - 1. evas_image_load_psd.c 221


static unsigned int
read_compressed_channel(....)
{
  ....
  signed char headbyte;
  ....
  if (headbyte >= 0)
  {
    ....
  }
  else if (headbyte >= -127 && headbyte <= -1)     // <=
  ....
}

EFL Core Libraries

V560 A part of conditional expression is always true: (!test). eeze_disk.c 55


static Eeze_Disk_Type
_eeze_disk_type_find(Eeze_Disk *disk)
{
  const char *test;
  ....
  test = udev_device_get_property_value(disk->device, "ID_BUS");
  if (test)
  {
    if (!strcmp(test, "ata")) return EEZE_DISK_TYPE_INTERNAL;
    if (!strcmp(test, "usb")) return EEZE_DISK_TYPE_USB;
    return EEZE_DISK_TYPE_UNKNOWN;
  }
  if ((!test) && (!filesystem))                            // <=
  ....
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: (!second_exist_twice). evas_3d_utils.h 1346
  • V560 A part of conditional expression is always true: (first_exist_twice < 2). evas_3d_utils.h 1354
  • V560 A part of conditional expression is always true: (second_exist_twice < 2). evas_3d_utils.h 1354
  • And 27 additional diagnostic messages.


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;