metrica
Мы используем куки, чтобы пользоваться сайтом было удобно.
Хорошо
to the top
close form

Заполните форму в два простых шага ниже:

Ваши контактные данные:

Шаг 1
Поздравляем! У вас есть промокод!

Тип желаемой лицензии:

Шаг 2
Team license
Enterprise license
** Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности
close form
Запросите информацию о ценах
Новая лицензия
Продление лицензии
--Выберите валюту--
USD
EUR
RUB
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Бесплатная лицензия PVS‑Studio для специалистов Microsoft MVP
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Для получения лицензии для вашего открытого
проекта заполните, пожалуйста, эту форму
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
Мне интересно попробовать плагин на:
* Нажимая на кнопку, вы даете согласие на обработку
своих персональных данных. См. Политику конфиденциальности

close form
check circle
Ваше сообщение отправлено.

Мы ответим вам на


Если вы так и не получили ответ, пожалуйста, проверьте папку
Spam/Junk и нажмите на письме кнопку "Не спам".
Так Вы не пропустите ответы от нашей команды.

Вебинар: Трудности при интеграции SAST, как с ними справляться - 04.04

>
>
>
Примеры ошибок, обнаруженных с помощью …

Примеры ошибок, обнаруженных с помощью диагностики V560

V560. 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


#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: &.

Similar errors can be found in some other places:

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

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


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.

Similar errors can be found in some other places:

  • 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

Qt

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


#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
  )
  ....
}

Similar errors can be found in some other places:

  • 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
  • And 6 additional diagnostic messages.

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


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.

Similar errors can be found in some other places:

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

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


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

Similar errors can be found in some other places:

  • 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

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


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. 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
  • And 4 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


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

Similar errors can be found in some other places:

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

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 26 additional diagnostic messages.

MuseScore

V560 A part of conditional expression is always false: strack > - 1. edit.cpp 3669


void Score::undoAddElement(Element* element)
{
  QList<Staff* > staffList;
  Staff* ostaff = element->staff();
  int strack = -1;
  if (ostaff) {
    if (ostaff->score()->excerpt() && strack > -1)
     strack = ostaff->score()->excerpt()->tracks().key(...);
    else
     strack = ostaff->idx() * VOICES + element->track() % VOICES;
  }
  ....
}

Rosegarden

V560 A part of conditional expression is always false: singleStaff. NotationScene.cpp 1707


void NotationScene::layout(....)
{
  ....
  bool full = (singleStaff == 0 && startTime == endTime);

  m_hlayout->setViewSegmentCount(m_staffs.size());

  if (full) {
    Profiler profiler("....", true);

    m_hlayout->reset();
    m_vlayout->reset();

    bool first = true;

    for (unsigned int i = 0; i < m_segments.size(); ++i) {

      if (singleStaff &&  // <= Always False
          m_segments[i] != &singleStaff->getSegment()) {
        continue;
      }

      timeT thisStart = m_segments[i]->getClippedStartTime();
      timeT thisEnd = m_segments[i]->getEndMarkerTime();

      if (first || thisStart < startTime) startTime = thisStart;
      if (first || thisEnd > endTime) endTime = thisEnd;

      first = false;
    }
  }
  ....
}

Chromium

V560 CWE-570 A part of conditional expression is always false: bad_message. declarative_rule.h 472


template <typename ConditionT, typename ActionT>
std::unique_ptr<DeclarativeRule<ConditionT, ActionT>>
DeclarativeRule<ConditionT, ActionT>::Create(....) {
  ....
  bool bad_message = false;                                 // <=
  std::unique_ptr<ActionSet> actions = ActionSet::Create(
      browser_context, extension, rule->actions, error,
      &bad_message);                                        // <=
  if (bad_message) {                                        // <=
    *error = "An action of a rule set had an invalid "
             "structure that should have been caught "
             "by the JSON validator.";
    return std::move(error_result);
  }
  if (!error->empty() || bad_message)                       // <=
    return std::move(error_result);
  ....
}

XNU kernel

V560 CWE-570 A part of conditional expression is always false: ((* state & 3) > 3). vm_user.c 3415


#define VM_PURGABLE_STATE_MASK  3

kern_return_t
memory_entry_purgeable_control_internal(...., int *state)
{
  ....
  if ((control == VM_PURGABLE_SET_STATE ||
       control == VM_PURGABLE_SET_STATE_FROM_KERNEL) &&
      (((*state & ~(VM_PURGABLE_ALL_MASKS)) != 0) ||
       ((*state & VM_PURGABLE_STATE_MASK) >
           VM_PURGABLE_STATE_MASK)))
    return(KERN_INVALID_ARGUMENT);
  ....
}

Let's leave the main point: ((* state & 3) > 3). The expression has no sense.

Similar errors can be found in some other places:

  • V560 CWE-570 A part of conditional expression is always false: ((* state & 3) > 3). vm_map.c 15809

RT-Thread

V560 CWE-571 A part of conditional expression is always true: 0xFFFF0000. peci.c 372


#define PECI_M0D0C_HITHR_M      0xFFFF0000  // High Threshold
#define PECI_M0D0C_LOTHR_M      0x0000FFFF  // Low Threshold

void
PECIDomainConfigGet(....)
{
  unsigned long ulTemp;
  ....
  ulTemp = HWREG(ulBase + PECI_O_M0D0C + (ulDomain * 4));
  *pulHigh =
    ((ulTemp && PECI_M0D0C_HITHR_M) >> PECI_M0D0C_HITHR_S);
  *pulLow =
    ((ulTemp && PECI_M0D0C_LOTHR_M) >> PECI_M0D0C_LOTHR_S);
}

Similar errors can be found in some other places:

  • V560 CWE-571 A part of conditional expression is always true: 0x0000FFFF. peci.c 373

Krita

V560 A part of conditional expression is always true. KoTextLayoutArea.cpp 1622


qreal KoTextLayoutArea::addLine(QTextLine &line,
                                FrameIterator *cursor,
                                KoTextBlockData &blockData)
{
  if (!d->documentLayout->changeTracker()
   || !d->documentLayout->changeTracker()->displayChanges()
   || !d->documentLayout->changeTracker()->...
   || !d->documentLayout->changeTracker()->...
   || !d->documentLayout->changeTracker()->elementById(....)
   || !d->documentLayout->changeTracker()->elementById(....)
   || ....
   || d->documentLayout->changeTracker()->displayChanges()) {
     ....
  }
}

Android

V560 CWE-570 A part of conditional expression is always false: ns != 1. fingerprint.c 126


static void saveFingerprint(worker_thread_t* listener, int idx) {
  ....
  int ns = fwrite(&listener->secureid[idx],
                  sizeof(uint64_t), 1, fp);
  ....
  int nf = fwrite(&listener->fingerid[idx],
                  sizeof(uint64_t), 1, fp);

  if (ns != 1 || ns !=1)                               // <=
    ALOGW("Corrupt emulator fingerprints storage; "
          "could not save fingerprints");

  fclose(fp);
  return;
}

Android

V560 CWE-571 A part of conditional expression is always true: (j < 4). ipphelper.c 926


void parse_printerAttributes(....) {
  ....
  ipp_t *collection = ippGetCollection(attrptr, i);

  for (j = 0, attrptr = ippFirstAttribute(collection);
      (j < 4) && (attrptr != NULL);
      attrptr = ippNextAttribute(collection))
  {
    if (strcmp("....", ippGetName(attrptr)) == 0) {
      ....TopMargin = ippGetInteger(attrptr, 0);
    } else if (strcmp("....", ippGetName(attrptr)) == 0) {
      ....BottomMargin = ippGetInteger(attrptr, 0);
    } else if (strcmp("....", ippGetName(attrptr)) == 0) {
      ....LeftMargin = ippGetInteger(attrptr, 0);
    } else if (strcmp("....", ippGetName(attrptr)) == 0) {
      ....RightMargin = ippGetInteger(attrptr, 0);
    }
  }
  ....
}

Android

V560 CWE-570 A part of conditional expression is always false: f->mode & 00000000. fec_read.cpp 322


#define O_RDONLY 00000000
#define O_WRONLY 00000001
#define O_RDWR   00000002

static ssize_t verity_read(fec_handle *f, ....)
{
  ....
  /* if we are in read-only mode and expect to read a zero
     block, skip reading and just return zeros */
  if (f->mode & O_RDONLY && expect_zeros) {
      memset(data, 0, FEC_BLOCKSIZE);
      goto valid;
  }
  ....
}

System Shock

V560 A part of conditional expression is always true: 0xffff0000. INTERP.C 355


void g3_interpret_object(....)
{
  ....
  temp = (((ulong) _view_position.gX)>>16);  // get high 16 bits
  if (((temp<<scale) && 0xffff0000)!=0) goto Exit; // overflow
  temp = (((ulong) _view_position.gY)>>16);  // get high 16 bits
  if (((temp<<scale) && 0xffff0000)!=0) goto Exit; // overflow
  temp = (((ulong) _view_position.gZ)>>16);  // get high 16 bits
  if (((temp<<scale) && 0xffff0000)!=0) goto Exit; // overflow
  ....
}

Qt

V560 CWE-570 A part of conditional expression is always false: c > 'z'. qdir.cpp 77


#if defined(Q_OS_WIN)
static QString driveSpec(const QString &path)
{
  if (path.size() < 2)
    return QString();
  char c = path.at(0).toLatin1();
  if (c < 'a' && c > 'z' && c < 'A' && c > 'Z')
    return QString();
  if (path.at(1).toLatin1() != ':')
    return QString();
  return path.mid(0, 2);
}
#endif

Qt

V560 CWE-570 A part of conditional expression is always false: currentType == QMetaType::Char. qvariant.cpp 3529


bool QVariant::canConvert(int targetTypeId) const
{
  ....
  if (currentType == QMetaType::SChar || currentType == QMetaType::Char)
    currentType = QMetaType::UInt;
  if (targetTypeId == QMetaType::SChar || currentType == QMetaType::Char)
    targetTypeId = QMetaType::UInt;
  ....
}

Qt

V560 CWE-571 A part of conditional expression is always true: doc. qtextdocument.cpp 2992


QString QTextHtmlExporter::findUrlForImage(const QTextDocument *doc, ....)
{
  QString url;
  if (!doc)
    return url;

  if (QTextDocument *parent = qobject_cast<QTextDocument *>(doc->parent()))
      return findUrlForImage(parent, cacheKey, isPixmap);

  if (doc && doc->docHandle()) {
  ....
}

NCBI Genome Workbench

V560 A part of conditional expression is always false: s1.IsSet(). valid_biosource.cpp 3073


static bool s_PCRPrimerSetLess(const CPCRPrimerSet& s1, const CPCRPrimerSet& s2)
{
  if (!s1.IsSet() && s1.IsSet()) {
    return true;
  } else if (s1.IsSet() && !s2.IsSet()) {
    return false;
  } else if (!s1.IsSet() && !s2.IsSet()) {
    return false;
  } else if (s1.Get().size() < s2.Get().size()) {
    return true;
  } else if (s1.Get().size() > s2.Get().size()) {
    return false;
  } else {
  ....
}

Stellarium

V560 A part of conditional expression is always true: updatePos. StelGuiItems.cpp 732


void BottomStelBar::updateText(bool updatePos)
{
  ....
  updatePos = true;
  ....
  if (location->text() != newLocation || updatePos)
  {
    updatePos = true;
    ....
  }
}

Windows Calculator

V560 A part of conditional expression is always true: NumbersAndOperatorsEnum::None != op. CalcViewModel UnitConverterViewModel.cpp 991


void UnitConverterViewModel::OnPaste(String^ stringToPaste, ViewMode mode)
{
  ....
  NumbersAndOperatorsEnum op = MapCharacterToButtonId(*it, canSendNegate);

  if (NumbersAndOperatorsEnum::None != op)      // <=
  {
    ....
    if (NumbersAndOperatorsEnum::None != op &&  // <=
        NumbersAndOperatorsEnum::Negate != op)
    {
      ....
    }
    ....
  }
  ....
}

SpeedCrunch

V560 A part of conditional expression is always true: !ruleFound. evaluator.cpp 1410


void Evaluator::compile(const Tokens& tokens)
{
  ....
  while (!syntaxStack.hasError()) {
    bool ruleFound = false;                                     // <=

    // Rule for function last argument: id (arg) -> arg.
    if (!ruleFound && syntaxStack.itemCount() >= 4) {           // <=
        Token par2 = syntaxStack.top();
        Token arg = syntaxStack.top(1);
        Token par1 = syntaxStack.top(2);
        Token id = syntaxStack.top(3);
        if (par2.asOperator() == Token::AssociationEnd
            && arg.isOperand()
            && par1.asOperator() == Token::AssociationStart
            && id.isIdentifier())
        {
            ruleFound = true;                                   // <=
            syntaxStack.reduce(4, MAX_PRECEDENCE);
            m_codes.append(Opcode(Opcode::Function, argCount));
#ifdef EVALUATOR_DEBUG
                dbg << "\tRule for function last argument "
                    << argCount << " \n";
#endif
            argCount = argStack.empty() ? 0 : argStack.pop();
        }
    }
    ....
  }
  ....
}

SpeedCrunch

V560 A part of conditional expression is always true: m_scrollDirection != 0. resultdisplay.cpp 242


void ResultDisplay::fullContentScrollEvent()
{
  QScrollBar* bar = verticalScrollBar();
  int value = bar->value();
  bool shouldStop = (m_scrollDirection == -1 && value <= 0) ||
                    (m_scrollDirection == 1 && value >= bar->maximum());

  if (shouldStop && m_scrollDirection != 0) {     // <=
      stopActiveScrollingAnimation();
      return;
  }

  scrollLines(m_scrollDirection * 10);
}

FreeRDP

V560 A part of conditional expression is always true: (rc >= 0). proxy.c 222


static BOOL check_no_proxy(....)
{
  ....
  int sub;
  int rc = sscanf(range, "%u", &sub);

  if ((rc == 1) && (rc >= 0))
  {
    ....
  }
  ....
}

rdesktop

V560 A part of conditional expression is always true: add > 0. scard.c 507


static void
inRepos(STREAM in, unsigned int read)
{
  SERVER_DWORD add = 4 - read % 4;
  if (add < 4 && add > 0)
  {
    ....
  }
}

xrdp

V560 A part of conditional expression is always false: (cap_len < 0). xrdp_caps.c 616


// common/parse.h
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint16_le(s, v) do \
....
#else
#define in_uint16_le(s, v) do \
{ \
    (v) = *((unsigned short*)((s)->p)); \
    (s)->p += 2; \
} while (0)
#endif

int
xrdp_caps_process_confirm_active(struct xrdp_rdp *self, struct stream *s)
{
  int cap_len;
  ....
  in_uint16_le(s, cap_len);
  ....
  if ((cap_len < 0) || (cap_len > 1024 * 1024))
  {
    ....
  }
  ....
}

xrdp

V560 A part of conditional expression is always true: (bpp != 16). libxrdp.c 704


int EXPORT_CC
libxrdp_send_pointer(struct xrdp_session *session, int cache_idx,
                     char *data, char *mask, int x, int y, int bpp)
{
  ....
  if ((bpp == 15) && (bpp != 16) && (bpp != 24) && (bpp != 32))
  {
      g_writeln("libxrdp_send_pointer: error");
      return 1;
  }
  ....
}

LLVM/Clang

V560 [CWE-570] A part of conditional expression is always false: RegNo == 0xe. ARMDisassembler.cpp 939


static DecodeStatus DecodeGPRPairRegisterClass(MCInst &Inst, unsigned RegNo,
                                   uint64_t Address, const void *Decoder) {
  DecodeStatus S = MCDisassembler::Success;

  if (RegNo > 13)
    return MCDisassembler::Fail;

  if ((RegNo & 1) || RegNo == 0xe)
     S = MCDisassembler::SoftFail;
  ....
}

EAStdC

V560 A part of conditional expression is always true: (result >= 0). EASprintfOrdered.cpp 489


static int OVprintfCore(....)
{
  ....
  for(result = 1; (result >= 0) && (p < pEnd); ++p)
  {
    if(pWriteFunction8(p, 1, pWriteFunctionContext8, kWFSIntermediate) < 0)
      return -1;
    nWriteCountSum += result;
  }
  ....
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: (result >= 0). EASprintfOrdered.cpp 852
  • V560 A part of conditional expression is always true: (result >= 0). EASprintfOrdered.cpp 1215

TON

V560 A part of conditional expression is always false: last == 0x80. boc.cpp 78


class Slice {
  ....
  char operator[](size_t i) const;
  ....
};

td::Result<int> CellSerializationInfo::get_bits(td::Slice cell) const {
  ....
  int last = cell[data_offset + data_len - 1];
  if (!last || last == 0x80) { // <=
    return td::Status::Error("overlong encoding");
  }
  ....
}

Platinum

V560 A part of conditional expression is always false: c == '\t'. NptUtils.cpp:863


NPT_Result NPT_ParseMimeParameters(....)
{
  ....
  case NPT_MIME_PARAMETER_PARSER_STATE_NEED_EQUALS:
    if (c <  ' ') return NPT_ERROR_INVALID_SYNTAX; // END or CTLs are invalid
    if (c == ' ' || c == '\t') continue; // ignore leading whitespace
  ....
}

Heawei Ark Compiler

V560 A part of conditional expression is always false: !firstImport. parser.cpp 2633


bool MIRParser::ParseMIRForImport() {
  ....
  if (paramIsIPA && firstImport) {
    BinaryMplt *binMplt = new BinaryMplt(mod);
    mod.SetBinMplt(binMplt);
    if (!(*binMplt).Import(...., paramIsIPA && !firstImport, paramIsComb)) {
      ....
    }
    ....
  }
  ....
}

VVVVVV

V560 A part of conditional expression is always true: x >= 0. editor.cpp 1137


int editorclass::at( int x, int y )
{
  if(x<0) return at(0,y);
  if(y<0) return at(x,0);
  if(x>=40) return at(39,y);
  if(y>=30) return at(x,29);

  if(x>=0 && y>=0 && x<40 && y<30)
  {
      return contents[x+(levx*40)+vmult[y+(levy*30)]];
  }
  return 0;
}

Similar errors can be found in some other places:

  • V560 A part of conditional expression is always true: y >= 0. editor.cpp 1137
  • V560 A part of conditional expression is always true: x < 40. editor.cpp 1137
  • V560 A part of conditional expression is always true: y < 30. editor.cpp 1137

SDCC

V560 [CWE-571] A part of conditional expression is always true: 0xff. timer.cc 198


t_mem
cl_tim::read(class cl_memory_cell *cell)
{
  ....
  if (a == idx.pscrl)
    v= prescaler_preload && 0xff;
  else if (a == idx.pscrh)
    v= (prescaler_preload >> 8) & 0xff;
  ....
}

GCC

V560 A part of conditional expression is always false: ((machine_mode)(xop1)->mode) == xmode1. optabs.c 1053


#define GET_MODE(RTX)    ((machine_mode) (RTX)->mode)

static int
add_equal_note (rtx_insn *insns, rtx target, enum rtx_code code, rtx op0,
    rtx op1, machine_mode op0_mode)
{
  ....
  if (commutative_p
      && GET_MODE (xop0) != xmode0 && GET_MODE (xop1) != xmode1
      && GET_MODE (xop0) == xmode1 && GET_MODE (xop1) == xmode1)
    std::swap (xop0, xop1);
  ....
}

Minetest

V560 A part of conditional expression is always false: y > max_spawn_y. mapgen_v7.cpp 262


int MapgenV7::getSpawnLevelAtPoint(v2s16 p)
{
  ....
  while (iters > 0 && y <= max_spawn_y) {               // <=
    if (!getMountainTerrainAtPoint(p.X, y + 1, p.Y)) {
      if (y <= water_level || y > max_spawn_y)          // <=
        return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point

      // y + 1 due to biome 'dust'
      return y + 1;
    }
  ....
}

structopt

V560 A part of conditional expression is always false: input[i] <= '9'. structopt.hpp 1870


static inline bool is_valid_number(const std::string &input) {
  ....
  else if (input[i] == 'e') {
    // set dot_or_exp = 1 when e is encountered.
    dot_or_exp = true;

    // if there is no digit before 'e'.
    if (!(input[i - 1] >= '0' && input[i - 1] <= '9'))
      return false;

    // If 'e' is the last Character
    if (i + 1 > input.length())
      return false;

    // if e is not followed either by
    // '+', '-' or a digit
    if (input[i + 1] != '+' && input[i + 1] != '-' &&
        (input[i + 1] >= '0' && input[i] <= '9'))        // <=
      return false;
  }
  ....
}

Amnesia: The Dark Descent

V560 A part of conditional expression is always true: eLuxEnemyMoveState_Jogging. LuxEnemyMover.cpp 672


void cLuxEnemyMover::UpdateMoveAnimation(float afTimeStep)
{
  ....
  if(prevMoveState != mMoveState)
  {
    ....

    //Backward
    if(mMoveState == eLuxEnemyMoveState_Backward)
    {
      ....
    }
    ....
    //Walking
    else if(mMoveState == eLuxEnemyMoveState_Walking)
    {
      bool bSync =    prevMoveState == eLuxEnemyMoveState_Running
                   || eLuxEnemyMoveState_Jogging
                    ? true : false;
      ....
    }
    ....
  }
}

GTK

V560 [CWE-571] A part of conditional expression is always true: seq_index. gtkimcontextsimple.c 475


gboolean
gtk_check_compact_table (const GtkComposeTableCompact  *table,
                         guint16                       *compose_buffer,
                         int                            n_compose,
                         gboolean                      *compose_finish,
                         gboolean                      *compose_match,
                         gunichar                      *output_char)
{
  int row_stride;
  guint16 *seq_index;
  ....

  seq_index = bsearch (compose_buffer,
                       table->data,
                       table->n_index_size,
                       sizeof (guint16) * table->n_index_stride,
                       compare_seq_index);

  if (!seq_index)
    return FALSE;

  if (seq_index && n_compose == 1)
    return TRUE;
  ....
}

Most likely this is what should be written here: if (*seq_index && n_compose == 1)


Qt

V560 [CWE-570] A part of conditional expression is always false: time->second() == MSECS_PER_DAY - 1. qdatetime.cpp 2488


enum {
  ....
  MSECS_PER_DAY = 86400000,
  ....
  SECS_PER_MIN = 60,
};

int QTime::second() const
{
    if (!isValid())
        return -1;

    return (ds() / 1000)%SECS_PER_MIN;
}

static qint64 qt_mktime(QDate *date, QTime *time, ....)
{
  ....
  } else if (yy == 1969 && mm == 12 && dd == 31
             && time->second() == MSECS_PER_DAY - 1) {
      // There was, of course, a last second in 1969, at time_t(-1); we won't
      // rescue it if it's not in normalised form, and we don't know its DST
      // status (unless we did already), but let's not wantonly declare it
      // invalid.
  } else {
  ....
}

Qt

V560 [CWE-570] A part of conditional expression is always false: !month. qdatetime.cpp 4921


static const char qt_shortMonthNames[][4] = {
    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

static int fromShortMonthName(QStringView monthName)
{
  for (unsigned int i = 0;
       i < sizeof(qt_shortMonthNames) / sizeof(qt_shortMonthNames[0]); ++i)
  {
    if (monthName == QLatin1String(qt_shortMonthNames[i], 3))
      return i + 1;
  }
  return -1;
}

QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format)
{
  ....
  month = fromShortMonthName(parts.at(1));
  if (month)
    day = parts.at(2).toInt(&ok);

  // If failed, try day then month
  if (!ok || !month || !day) {
    month = fromShortMonthName(parts.at(2));
    if (month) {
      QStringView dayPart = parts.at(1);
      if (dayPart.endsWith(u'.'))
        day = dayPart.chopped(1).toInt(&ok);
    }
  }
  ....
}

Similar errors can be found in some other places:

  • V560 [CWE-570] A part of conditional expression is always false: !month. qdatetime.cpp 4911

Snort

V560 A part of conditional expression is always false: !p->tcph. sp_rpc_check.c 285


int CheckRpc(void *option_data, Packet *p)
{
  ....
  if (!p->iph_api || (IsTCP(p) && !p->tcph)
    || (IsUDP(p) && !p->udph))
    return 0; /* if error occured while ip header
               * was processed, return 0 automagically.  */
  ....
}

#define IsTCP(p) (IsIP(p) && p->tcph)
#define IsUDP(p) (IsIP(p) && p->udph)

Snort

V560 A part of conditional expression is always true: hnode. spp_frag3.c 4364


static int Frag3Prune(FragTracker *not_me)
{
  SFXHASH_NODE *hnode;
  ....
  while (....)
  {
    hnode = sfxhash_lru_node(f_cache);
    if (!hnode)
    {
      break;
    }

    if (hnode && hnode->data == not_me)
  }
  ....
}

Darwin-XNU

V560 A part of conditional expression is always false: index < 0. bsd_stubs.c:236


int
cdevsw_isfree(int index)
{
  struct cdevsw * devsw;

  if (index < 0) {
    if (index == -1) {
      index = 0;
    } else {
      index = -index;
    }
    devsw = &cdevsw[index];
    for (; index < nchrdev; index++, devsw++) {
      if (memcmp(....) == 0) {
        break;
      }
    }
  }

  if (index < 0 || index >= nchrdev) {
    return -1;
  }
  ....
  return index;
}

Darwin-XNU

V560 A part of conditional expression is always true: (bp->nb_dirtyoff < end). nfs_bio.c 3862


int
nfs_vinvalbuf_internal(....)
{
  struct nfsbuf *bp;
  ....
  off_t end = ....;

  /* check for any dirty data before the EOF */
  if ((bp->nb_dirtyend > 0) && (bp->nb_dirtyoff < end))
  {
    /* clip dirty range to EOF */
    if (bp->nb_dirtyend > end)
    {
      bp->nb_dirtyend = end;

      if (bp->nb_dirtyoff >= bp->nb_dirtyend)             // <=
      {
        bp->nb_dirtyoff = bp->nb_dirtyend = 0;
      }
    }

    if ((bp->nb_dirtyend > 0) && (bp->nb_dirtyoff < end)) // <=
    {
      ....
    }
  }
  ....
}

Storm Engine

V560 A part of conditional expression is always true: 0x00 <= c. utf8.h 187


inline bool IsValidUtf8(....)
{
  int c, i, ix, n, j;
  for (i = 0, ix = str.length(); i < ix; i++)s
  {
    c = (unsigned char)str[i];
    if (0x00 <= c && c <= 0x7f)
      n = 0;
    ....
  }
  ....
}

libtorrent

V560 A part of conditional expression is always false: idx < 0. alert.cpp 1885.


char const* operation_name(operation_t const op)
  {
    ....
    static char const* const names[] = {
      ....
    };

    int const idx = static_cast<int>(op);
    if (idx < 0 || idx >= int(sizeof(names) / sizeof(names[0])))
      return "unknown operation";
    return names[idx];
}

RPCS3

V560 A part of conditional expression is always true: i != 1. PPUTranslator.cpp 4252


void PPUTranslator::MTFSF(ppu_opcode_t op)
{
  const auto value = GetFpr(op.frb, 32, true);

  for (u32 i = 16; i < 20; i++)
  {
    if (i != 1 && i != 2 && (op.flm & (128 >> (i / 4))) != 0)
    {
      SetFPSCRBit(i, Trunc(m_ir->CreateLShr(value, i ^ 31),
                  GetType<bool>()), false);
    }
  }

  if (op.rc) SetCrFieldFPCC(1);
}

Ogre3D

V560 Part of conditional expression is always true/false. OgreTerrainLodManager.cpp 62


void TerrainLodManager::open(const String& filename)
{
  if (!filename.empty() && filename.length() > 0)
       mDataStream =
         Root::getSingleton()
              .openFileStream(filename,
                              mTerrain->_getDerivedResourceGroup());
}

Here, the developer checks that the std::string container is empty and its length is greater than 0. We can remove one of the condition parts


LLVM/Clang

V560 [CWE-570] A part of conditional expression is always false: DefaultCC == ToCC. SemaType.cpp 7856


void Sema::adjustMemberFunctionCC(QualType &T, bool IsStatic, bool IsCtorOrDtor,
                                  SourceLocation Loc) {
  ....
  CallingConv CurCC = FT->getCallConv();
  CallingConv ToCC = Context.getDefaultCallingConvention(IsVariadic, !IsStatic);

  if (CurCC == ToCC)
    return;
  ....
  CallingConv DefaultCC =
    Context.getDefaultCallingConvention(IsVariadic, IsStatic);

  if (CurCC != DefaultCC || DefaultCC == ToCC)
    return;
  ....
}

VCMI

V560 A part of conditional expression is always true: creature. CGarrisonInt.cpp 284


bool CGarrisonSlot::mustForceReselection() const
{
  ....
  if (!creature || !selection->creature)
    return false;
  ....
  if (!owner->removableUnits)
  {
    if (selection->upg == EGarrisonType::UP)
      return true;
    else
      return creature || upg == EGarrisonType::UP;
  }
}

VCMI

V560 A part of conditional expression is always true: bs.canFlee. BattleAI.cpp 837


std::optional<BattleAction> CBattleAI::considerFleeingOrSurrendering()
{
  ....
  if (!bs.canFlee || !bs.canSurrender)
  {
    return std::nullopt;
  }
  auto result = cb->makeSurrenderRetreatDecision(bs);
  if (!result && bs.canFlee && bs.turnsSkippedByDefense > 30)
  {
    return BattleAction::makeRetreat(bs.ourSide);
  }
  ....
}

GZDoom

V560 A part of conditional expression is always true: sym->tokenType != TK_FloatConst. sc_man.cpp 829


bool FScanner::GetFloat (bool evaluate)
{
  ....
  if(sym && sym->tokenType == TK_IntConst && sym->tokenType != TK_FloatConst)
  {
    BigNumber = sym->Number;
    Number = (int)sym->Number;
    Float = sym->Float;
    // String will retain the actual symbol name.
    return true;
  }
  ....
}