Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: C++ semantics - 06.11

>
>
>
Examples of errors detected by the V501…

Examples of errors detected by the V501 diagnostic

V501. Identical sub-expressions to the left and to the right of 'foo' operator.


Audacity

V501 There are identical sub-expressions to the left and to the right of the '-' operator. Audacity voicekey.cpp 304


sampleCount VoiceKey::OnBackward (....) {
  ....
  int atrend = sgn(buffer[samplesleft - 2]-
                   buffer[samplesleft - 1]);
  int ztrend = sgn(buffer[samplesleft - WindowSizeInt-2]-
                   buffer[samplesleft - WindowSizeInt-2]);
  ....
}

A Copy-Paste error. In the last line 1 should be subtracted instead of 2.


Crystal Space 3D SDK

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. plgcsopcode icelss.h 69


inline_ bool Contains(const LSS& lss)
{
  // We check the LSS contains the two spheres
  // at the start and end of the sweep
  return Contains(Sphere(lss.mP0, lss.mRadius)) &&
         Contains(Sphere(lss.mP0, lss.mRadius));
}

A Copy-Paste error. The lss.mP1 variable should have been probably used when calling the Sphere function for the second time.


Shareaza

V501 There are identical sub-expressions to the left and to the right of the '==' operator: nCmd == nCmd Shareaza wndpacket.cpp 477


void CPacketWnd::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
  ....

  if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 )
  {
    m_bTypeED = ( nCmd == nCmd ) ? TRUE : FALSE;
  }
  ....
}

Xpdf

V501 There are identical sub-expressions to the left and to the right of the '||' operator: ( res -> pw == 0 ) || ( res -> pw == 0 ) mupdf pi.c 219


static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
  ....
  if ((res->pw==0)||(res->pw==0)) continue;

  ....
}

Most likely this is what should be written here: (res->pw==0)||(res->ph==0).


XUIFramework

V501 There are identical sub-expressions to the left and to the right of the '||' operator. Borne resizedlg.cpp 157


HDWP CItemCtrl::OnSize(....)
{
  ....
  if (m_styTop == CST_ZOOM ||
      m_styTop == CST_ZOOM ||
      m_styBottom == CST_DELTA_ZOOM ||
      m_styBottom == CST_DELTA_ZOOM)
  ....
}

Most likely this is what should be written here: m_styBottom == CST_ZOOM || m_styBottom == CST_DELTA_ZOOM.


Ultimate Toolbox

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. UT ox3dtabview.cpp 230


void COX3DTabViewContainer::OnNcPaint()
{
  ....
  if(rectClient.top<rectClient.bottom &&
     rectClient.top<rectClient.bottom)
  {
    dc.ExcludeClipRect(rectClient);
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator. UT oxtabclientwnd.cpp 184

Ultimate Toolbox

V501 There are identical sub-expressions to the left and to the right of the '==' operator: dwDockStyle == dwDockStyle UT oxframewnddock.cpp 190


void COXFrameWndSizeDock::TileDockedBars(
  DWORD dwDockStyle)
{
  ....
  if (pDock != NULL &&
      (pDock->m_dwStyle &&
       dwDockStyle == dwDockStyle))
  ....
}

Probably some other expression should be written instead of "dwDockStyle == dwDockStyle".


Ultimate Toolbox

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. UT oxscrollwnd.cpp 645


void COXScrollWnd::OnPrepareDC(....)
{
  ....
  ASSERT(m_totalDev.cx>=0 && m_totalDev.cx>=0);
  ....
}

This is what should have been written here: ASSERT(m_totalDev.cx>=0 && m_totalDev.cy>=0);

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator. UT oxzoomvw.cpp 179

Fennec Media

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: a -> tsize && a -> tsize media library.c 1076


int fennec_tag_item_compare(struct fennec_audiotag_item *a,
  struct fennec_audiotag_item *b)
{
  int v;
  if(a->tsize && a->tsize)
    v = abs(str_cmp(a->tdata, a->tdata));
  else
    v = 1;
  return v;
}

Notepad++

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: _isPointXValid && _isPointXValid parameters.h 232


bool _isPointXValid;
bool _isPointYValid;

bool isPointValid() {
  return _isPointXValid && _isPointXValid;
};

WinMerge

V501 There are identical sub-expressions to the left and to the right of the '||' operator mergedoc.cpp 1167


BUFFERTYPE m_nBufferType[2];
....
// Handle unnamed buffers
if ((m_nBufferType[nBuffer] == BUFFER_UNNAMED) ||
    (m_nBufferType[nBuffer] == BUFFER_UNNAMED))
  nSaveErrorCode = SAVE_NO_FILENAME;

If we look at the code nearby, the following should be written here by analogy: (m_nBufferType[0] == BUFFER_UNNAMED) || (m_nBufferType[1] == BUFFER_UNNAMED).


eLynx Image Processing SDK and Lab

V501 There are identical sub-expressions to the left and to the right of the '/' operator: sizeof (ms_pfList) / sizeof (ms_pfList) IFF plugins engine.cpp 955


void uteTestRunner::StressBayer(uint32 iFlags)
{
  ....
  static EPixelFormat ms_pfList[] =
    { PF_Lub, PF_Lus, PF_Li, PF_Lf, PF_Ld };
  const int fsize = sizeof(ms_pfList) / sizeof(ms_pfList);

  static EBayerMatrix ms_bmList[] =
    { BM_GRBG, BM_GBRG, BM_RGGB, BM_BGGR, BM_None };
  const int bsize = sizeof(ms_bmList) / sizeof(ms_bmList);
  ....
}

This is what should have been written here: sizeof(ms_pfList) / sizeof(ms_pfList[0]) and sizeof(ms_bmList) / sizeof(ms_bmList[0]).

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '/' operator: sizeof (ms_bmList) / sizeof (ms_bmList) IFF plugins engine.cpp 958

eLynx Image Processing SDK and Lab

V501 There are identical sub-expressions 'sizeof (ms_2boolean)' to the left and to the right of the '/' operator. ImageVariant checkformatconversion.cpp 72


void checkFormatConversion::Test(....)
{
  ....
  static struct { bool _b1, _b2; } ms_2boolean[] = {
    { false, false },
    { false, true  },
    { true,  false },
    { true,  true  }
  };
  const int b2size = sizeof(ms_2boolean) / sizeof(ms_2boolean);
  ....
}

This is what should have been written here: sizeof(ms_2boolean) / sizeof(ms_2boolean[0])

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '/' operator: sizeof (ms_list) / sizeof (ms_list) ImageVariant checkformatconversion.cpp 99
  • V501 There are identical sub-expressions 'sizeof (ms_ColorSpace)' to the left and to the right of the '/' operator. ImageVariant checkformatconversion.cpp 172
  • V501 There are identical sub-expressions to the left and to the right of the '/' operator: sizeof (ms_bmList) / sizeof (ms_bmList) ImageVariant checkformatconversion.cpp 436

RunAsAdmin Explorer Shim

V501 There are identical sub-expressions to the left and to the right of the '==' operator: luid2.HighPart == luid2.HighPart RAACommon raacommonfuncs.cpp 1511


bool IsLuidsEqual(LUID luid1, LUID luid2)
{
  return (luid1.LowPart == luid2.LowPart) &&
         (luid2.HighPart == luid2.HighPart);
}

This is what should have been written here: (luid1.HighPart == luid2.HighPart).


EchoVNC

V501 There are identical sub-expressions to the left and to the right of the '||' operator: fHorzSize < 0 || fHorzSize < 0 PicLibAPI picture.cpp 347


bool CPicture::Draw(....)
{
  ....
  if (fHorzSize < 0 || fHorzSize < 0 ) {
    return false;
  }
  ....
}

Lugaru

V501 There are identical sub-expressions '(mainmenu && gameon)' to the left and to the right of the '||' operator. Lugaru gamedraw.cpp 2237


int Game::DrawGLScene(void)
{
  ....
  if(freeze||winfreeze||(mainmenu&&gameon)||
     (!gameon&&gamestarted)||(mainmenu&&gameon)||
     (!gameon&&gamestarted)||(!gameon&&gamestarted))
  {
    multiplier=tempmult;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '(!gameon && gamestarted)' to the left and to the right of the '||' operator. Lugaru gamedraw.cpp 2237

Lugaru

V501 There are identical sub-expressions '(!gameon && gamestarted)' to the left and to the right of the '||' operator. Lugaru gamedraw.cpp 3960


int Game::DrawGLScene(void)
{
  ....
  if(freeze||winfreeze||(mainmenu&&gameon)||
     (!gameon&&gamestarted)||(!gameon&&gamestarted))
  {
    tempmult=multiplier;
    multiplier=0;
  }
  ....
}

Lugaru

V501 There are identical sub-expressions 'Compare (consoletext [0], "belt ", 0, 4)' to the left and to the right of the '||' operator. Lugaru gametick.cpp 5515


void  Game::Tick()
{
  ....
  if(Compare(consoletext[0],"belt ",0,4)||
     Compare(consoletext[0],"belt ",0,4))
  {
    player[0].skeleton.clothes = 1-player[0].skeleton.clothes;
    donesomething=1;
  }
  ....
}

The word "belt" should start both with the capital and small letters.


TickerTape

V501 There are identical sub-expressions 'm_GamePad [iUserIndex].sThumbLX' to the left and to the right of the '||' operator. TickerTape dxutcamera.cpp 479


void CBaseCamera::GetInput(....)
{
  ....
  if( m_GamePad[iUserIndex].wButtons ||
      m_GamePad[iUserIndex].sThumbLX ||
      m_GamePad[iUserIndex].sThumbLX ||
      m_GamePad[iUserIndex].sThumbRX ||
      m_GamePad[iUserIndex].sThumbRY ||
      m_GamePad[iUserIndex].bLeftTrigger ||
      m_GamePad[iUserIndex].bRightTrigger )
  {
    m_GamePadLastActive[iUserIndex] = DXUTGetTime();
  }
  ....
}

This is what should have been written here: m_GamePad[iUserIndex].sThumbLX || m_GamePad[iUserIndex].sThumbLY ||.


IPP Samples

V501 There are identical sub-expressions 'p_newHeader.pic_parameter_set_id' to the left and to the right of the '!=' operator. h264_spl umc_h264_au_stream.cpp 478


bool H264_AU_Stream::IsPictureSame(
  H264SliceHeaderParse & p_newHeader)
{
  if ((p_newHeader.frame_num !=
       m_lastSlice.frame_num) ||
      (p_newHeader.pic_parameter_set_id !=
       p_newHeader.pic_parameter_set_id) ||
      (p_newHeader.field_pic_flag !=
       p_newHeader.field_pic_flag) ||
      (p_newHeader.bottom_field_flag !=
       m_lastSlice.bottom_field_flag)
      ){
      return false;
  }
  ....
}

The code is formatted. That's why the error is clearly seen. In reality, such errors are difficult to find. 'p_newHeader' is used in two places instead of 'm_lastSlice' here.

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'p_newHeader.field_pic_flag' to the left and to the right of the '!=' operator. h264_spl umc_h264_au_stream.cpp 479

IPP Samples

V501 There are identical sub-expressions to the left and to the right of the '<' operator: (m_cur.AcRate [2]) < (m_cur.AcRate [2]) me umc_me.cpp 898


void MeBase::MakeVlcTableDecision()
{
  ....
  Ipp32s BestMV =
    IPP_MIN(IPP_MIN(m_cur.MvRate[0],m_cur.MvRate[1]),
                    IPP_MIN(m_cur.MvRate[2],m_cur.MvRate[3]));
  Ipp32s BestAC =
    IPP_MIN(IPP_MIN(m_cur.AcRate[0],m_cur.AcRate[1]),
                    IPP_MIN(m_cur.AcRate[2],m_cur.AcRate[2]));
  ....
}

See the last string. The index at the end should be '3', not '2'. As a result, the error causes the minimum value to be estimated incorrectly at times.


IPP Samples

V501 There are identical sub-expressions '(mBVOPsearchHorBack)' to the left and to the right of the '>' operator. mpeg4_enc mp4_enc_misc.cpp 547


Ipp32s ippVideoEncoderMPEG4::Init(mp4_Param *par)
{
  ....
  i = IPP_MAX(mBVOPsearchHorBack, mBVOPsearchHorBack);
  ....
}

By analogy with the nearby code, the second variable should be mBVOPsearchVerBack instead of mBVOPsearchHorBack. This is the correct code: i = IPP_MAX(mBVOPsearchHorBack, mBVOPsearchVerBack).


IPP Samples

V501 There are identical sub-expressions to the left and to the right of the '-' operator: state->freq - state->freq speech ec_fb.c 250


int ec_fb_GetSubbandNum(void *stat)
{
    _fbECState *state=(_fbECState *)stat;
    return (state->freq-state->freq);
}

Something wrong has been subtracted. I don't know what the code should look like exactly, but this is obviously an error. The function always returns 0.


IPP Samples

V501 There are identical sub-expressions 'm_pContext->m_seqLayerHeader->heightMB' to the left and to the right of the '&&' operator. vc1_dec umc_vc1_video_decoder.cpp 1347


Status VC1VideoDecoder::ResizeBuffer()
{
  ....
  if(m_pContext && m_pContext->m_seqLayerHeader &&
     m_pContext->m_seqLayerHeader->heightMB &&
     m_pContext->m_seqLayerHeader->heightMB)
  ....
}

This is what should have been written here: m_pContext->m_seqLayerHeader->heightMB && m_pContext->m_seqLayerHeader->widthMB.


IT++

V501 There are identical sub-expressions 'mseq1.get_length ()' to the left and to the right of the '==' operator. itpp_mkl sequence.cpp 126


Gold::Gold(const ivec &mseq1_connections,
           const ivec &mseq2_connections)
{
  ....
  it_assert(mseq1.get_length() == mseq1.get_length(),
            "Gold::Gold(): dimension mismatch");
}

This assert never works.


SAGA GIS

V501 There are identical sub-expressions 'pSandInput->Get_NY ()' to the left and to the right of the '==' operator. grid_analysis soil_texture.cpp 180


bool CSoil_Texture::On_Execute(void)
{
  ....
  if (pSandInput->Get_NX()==pClayInput->Get_NX() &&
      pSandInput->Get_NY()==pSandInput->Get_NY() )
  ....
}

Miranda IM

V501 There are identical sub-expressions to the left and to the right of the '||' operator: !pStatusList ||!ppUserList ||!ppUserList chat manager.c 1333


USERINFO* UM_AddUser(STATUSINFO* pStatusList,
  USERINFO** ppUserList, const TCHAR* pszUID,
  const TCHAR* pszNick, WORD wStatus)
{
  ....
  if (!pStatusList || !ppUserList || !ppUserList)
    return NULL;
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: !pStatusList ||!ppUserList ||!ppUserList scriver manager.c 1119
  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: !pStatusList ||!ppUserList ||!ppUserList tabsrmm manager.cpp 1265

Miranda IM

V501 There are identical sub-expressions 'job->hOwner' to the left and to the right of the '&&' operator. tabsrmm hotkeyhandler.cpp 564


LONG_PTR CALLBACK HotkeyHandlerDlgProc(....)
{
  ....
  if (job->hOwner && job->iAcksNeeded && job->hOwner &&
      job->iStatus == SendQueue::SQ_INPROGRESS) {
  ....
}

Miranda IM

V501 There are identical sub-expressions 'user->statusMessage' to the left and to the right of the '&&' operator. jabber jabber_chat.cpp 214


void CJabberProto::GcLogShowInformation(....)
{
  ....
  if (user->statusMessage && user->statusMessage)
  ....
}

StrongDC++

V501 There are identical sub-expressions 'line [linelen] != '\r'' to the left and to the right of the '&&' operator. miniupnpc miniupnpc.c 153


static voidgetContentLengthAndHeaderLength(....)
{
  ....
  while(line[linelen] != '\r' && line[linelen] != '\r')
  ....
}

Chromium

V501 There are identical sub-expressions to the left and to the right of the '||' operator. browser web_database.cc 404


bool AutoFillProfileHasName(const AutoFillProfile& profile) {
  return
   !profile.GetFieldText(AutofillType(NAME_FIRST)).empty() ||
   !profile.GetFieldText(AutofillType(NAME_MIDDLE)).empty() ||
   !profile.GetFieldText(AutofillType(NAME_MIDDLE)).empty();
}

Chromium

V501 There are identical sub-expressions 'host != buzz::XmlConstants::str_empty ()' to the left and to the right of the '&&' operator. chromoting_jingle_glue iq_request.cc 248


void JingleInfoRequest::OnResponse(....) {
  ....
  std::string host = server->Attr(buzz::QN_JINGLE_INFO_HOST);
  std::string port_str = server->Attr(buzz::QN_JINGLE_INFO_UDP);
  if (host != buzz::STR_EMPTY && host != buzz::STR_EMPTY) {
  ....
}

Most likely this is what should be written here: (host != buzz::STR_EMPTY && port_str != buzz::STR_EMPTY).


Libjingle

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !has_audio &&!has_audio libjingle_p2p sessionmessages.cc 308


bool ParseGingleTransportInfos(....)
{
  ....
  bool has_audio =
    FindContentInfoByName(contents, CN_AUDIO) != NULL;
  bool has_video =
    FindContentInfoByName(contents, CN_VIDEO) != NULL;

  if (!has_audio && !has_audio) {
    ....
}

This is what should have been written here: if (!has_audio && !has_video) {


Libxml2

V501 There are identical sub-expressions 'sub->negNsSet->value' to the left and to the right of the '==' operator. libxml xmlschemas.c 13949


static int
xmlSchemaCheckCOSNSSubset(....)
{
  ....
  if ((sub->negNsSet != NULL) &&
      (super->negNsSet != NULL) &&
      (sub->negNsSet->value == sub->negNsSet->value))
   return 0;
 ....
}

This is what should have been written here: (sub->negNsSet->value == super->negNsSet->value))


Mesa 3D Graphics Library

V501 There are identical sub-expressions 'ir1->operands [0]->type->is_matrix ()' to the left and to the right of the '||' operator. mesa ir_algebraic.cpp 189


bool
ir_algebraic_visitor::reassociate_constant(....)
{
  ....
  if (ir1->operands[0]->type->is_matrix() ||
      ir1->operands[0]->type->is_matrix() ||
      ir2->operands[1]->type->is_matrix() ||
      ir2->operands[1]->type->is_matrix())
   return false;
  ....
}

Mesa 3D Graphics Library

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: width > 0 && height > 0 && height > 0 mesa teximage.c 2801


void GLAPIENTRY
_mesa_TexSubImage3D(....)
{
  ....
  else if (width > 0 && height > 0 && height > 0) {
  ....
}

This is what should have been written here: else if (width > 0 && height > 0 && depth > 0) {


Skia Graphics Engine

V501 There are identical sub-expressions 'kKeep_StencilOp == fFrontFailOp' to the left and to the right of the '&&' operator. skia grstencil.h 159


bool isDisabled() const {
  return kKeep_StencilOp == fFrontPassOp   &&
         kKeep_StencilOp == fBackPassOp    &&
         kKeep_StencilOp == fFrontFailOp   &&
         kKeep_StencilOp == fFrontFailOp   &&
         kAlways_StencilFunc == fFrontFunc &&
         kAlways_StencilFunc == fBackFunc;
}

Here we seem to have several errors at once. Besides the repeating condition, && and || may be mixed up.


EA WebKit

V501 There are identical sub-expressions 'x >= 0' to the left and to the right of the '&&' operator. webcore_platform feconvolvematrix.cpp 289


ALWAYS_INLINE int
FEConvolveMatrix::getPixelValue(
  PaintingData& paintingData, int x, int y)
{
  if (x >= 0 &&
      x < paintingData.width &&
      x >= 0 &&
      y < paintingData.height)
    return (y * paintingData.width + x) << 2;
  ....
}

This is what should have been written here: y >= 0 && y < paintingData.height


EA WebKit

V501 There are identical sub-expressions '(bStart >= aStart && bStart <= aEnd)' to the left and to the right of the '||' operator. webcore_remaining spatialnavigation.cpp 236


// This method checks if |start| and
// |dest| have a partial intersection, either
// horizontally or vertically.
// * a = Current focused node's rect.
// * b = Focus candidate node's rect.
static bool areRectsPartiallyAligned(....)
{
    int aStart  = start(direction, a);
    int bStart  = start(direction, b);
    int bMiddle = middle(direction, b);
    int aEnd = end(direction, a);
    int bEnd = end(direction, b);

    // Picture of the partially aligned logic:
    //
    //    Horizontal       Vertical
    // ********************************
    // *  _            *   _ _ _      *
    // * |_|           *  |_|_|_|     *
    // * |_|.... _     *      . .     *
    // * |_|    |_|    *      . .     *
    // * |_|....|_|    *      ._._ _  *
    // *        |_|    *      |_|_|_| *
    // *        |_|    *              *
    // *               *              *
    // ********************************
    //
    // ... and variants of the above cases.
    return ((bStart >= aStart && bStart <= aEnd)
            || (bStart >= aStart && bStart <= aEnd)
            || (bEnd >= aStart && bEnd <= aEnd)
            || (bMiddle >= aStart && bMiddle <= aEnd)
            || (bEnd >= aStart && bEnd <= aEnd));
}

The (bStart >= aStart && bStart <= aEnd) comparison is repeated twice. I cannot say for sure what should be written instead of this.


EA WebKit

V501 There are identical sub-expressions 'cy().isRelative()' to the left and to the right of the '||' operator. webcore_svg svgradialgradientelement.cpp 253


bool SVGRadialGradientElement::selfHasRelativeLengths() const
{
  return cy().isRelative()
      || cy().isRelative()
      || r().isRelative()
      || fx().isRelative()
      || fy().isRelative();
}

This is what should have been written here: return cx().isRelative() || cy().isRelative() || .....


Qt

V501 There are identical sub-expressions to the left and to the right of the '-' operator: orig->y1 - orig->y1 QtGui qbezier.cpp 329


static ShiftResult shift(....)
{
  ....
  qreal l = (orig->x1 - orig->x2)*(orig->x1 - orig->x2) +
            (orig->y1 - orig->y2)*(orig->y1 - orig->y1) *
            (orig->x3 - orig->x4)*(orig->x3 - orig->x4) +
            (orig->y3 - orig->y4)*(orig->y3 - orig->y4);
  ....
}

Seems like it should be "orig->y1 - orig->y2" instead of "orig->y1 - orig->y1".


Qt

V501 There are identical sub-expressions to the left and to the right of the '||' operator: iw <= 0 || iw <= 0 QtGui qfontengine_win.cpp 1103


QNativeImage *QFontEngineWin::drawGDIGlyph(....)
{
  ....
  int iw = gm.width.toInt();
  int ih = gm.height.toInt();

  if (iw <= 0 || iw <= 0)
    return 0;
  ....
}

This is what should have been written here: if (iw <= 0 || ih <= 0)


Qt

V501 There are identical sub-expressions 'State_Sunken' to the left and to the right of the '|' operator. QtGui qwindowsstyle.cpp 1365


void QWindowsStyle::drawPrimitive(....)
{
  ....
  } else if (flags & (State_Raised | State_Sunken |
                      State_On | State_Sunken))
  {
  ....
}

One 'State_Sunken' constant is unnecessary here - something else should be written instead of it.


Qt

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. Qt3Support q3richtext.cpp 6978


Q3TextCustomItem* Q3TextDocument::parseTable(....)
{
  ....
  while (end < length
    && !hasPrefix(doc, length, end, QLatin1String("</td"))
    && !hasPrefix(doc, length, end, QLatin1String("<td"))
    && !hasPrefix(doc, length, end, QLatin1String("</th"))
    && !hasPrefix(doc, length, end, QLatin1String("<th"))
    && !hasPrefix(doc, length, end, QLatin1String("<td"))
    && !hasPrefix(doc, length, end, QLatin1String("</tr"))
    && !hasPrefix(doc, length, end, QLatin1String("<tr"))
    && !hasPrefix(doc, length, end, QLatin1String("</table"))
  ) {
  ....
}

The "td" prefix is being searched for twice.


Qt

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. QtOpenGL qglextensions.cpp 367


bool qt_resolve_glsl_extensions(QGLContext *ctx)
{
  ....
  return glCreateShader &&
    glShaderSource &&
    glCompileShader &&
    glDeleteProgram &&      // <=
    glCreateProgram &&
    glAttachShader &&
    glDetachShader &&
    glLinkProgram &&
    glUseProgram &&
    glDeleteProgram &&      // <=
    glGetShaderInfoLog &&
    glGetShaderiv &&
    glGetShaderSource &&
    glGetProgramiv &&
    glGetProgramInfoLog &&
    glGetUniformLocation &&
    glUniform1fv &&
    glUniform2fv &&
    glUniform3fv &&
    glUniform4fv &&
    glUniform1i &&
    glUniform1iv &&
    glUniformMatrix2fv &&
    glUniformMatrix3fv &&
    glUniformMatrix4fv &&
    glBindAttribLocation &&
    glGetAttribLocation &&
    glVertexAttrib1fv &&
    glVertexAttrib2fv &&
    glVertexAttrib3fv &&
    glVertexAttrib4fv &&
    glVertexAttribPointer &&
    glDisableVertexAttribArray &&
    glEnableVertexAttribArray;
  ....
}

There's no error. It's just an unnecessary line. It is still useful to find and fix such code fragments: your code will become a bit shorter.


Qt

V501 There are identical sub-expressions to the left and to the right of the '||' operator: ignoreTrans || ignoreTrans QtDeclarative qdeclarativestategroup.cpp 400


void QDeclarativeStateGroupPrivate::setCurrentStateInternal(....)
{
  ....
  QDeclarativeTransition *transition =
    (ignoreTrans || ignoreTrans) ?
        0 :
        findTransition(currentState, state);
  ....
}

Strange... But maybe not an error. There are no other suitable variables.


Qt

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. QtWebKit renderstyle.h 162


bool operator==(const InheritedFlags& other) const
{
  ....
  return
    (_empty_cells == other._empty_cells) &&
    (_caption_side == other._caption_side) &&
    (_list_style_type == other._list_style_type) &&
    (_list_style_position == other._list_style_position) &&
    (_visibility == other._visibility) &&
    (_text_align == other._text_align) &&
    (_text_transform == other._text_transform) &&       // <=
    (_text_decorations == other._text_decorations) &&
    (_text_transform == other._text_transform) &&       // <=
    (_cursor_style == other._cursor_style) &&
    (_direction == other._direction) &&
    (_border_collapse == other._border_collapse) &&
    (_white_space == other._white_space) &&
    (_box_direction == other._box_direction) &&
    (_visuallyOrdered == other._visuallyOrdered) &&
    (_htmlHacks == other._htmlHacks) &&
    (_force_backgrounds_to_white ==
     other._force_backgrounds_to_white) &&
    (_pointerEvents == other._pointerEvents);
  ....
}

There's no error. It's just an unnecessary line. It is still useful to find and fix such code fragments: your code will become a bit shorter.


Qt

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: mt.pbFormat && mt.pbFormat phonon_ds9 videorenderer_soft.cpp 462


QSize VideoRendererSoftFilter::videoSize() const
{
  ....
  if (mt.pbFormat && mt.pbFormat) {
  ....
}

Most likely this is what should be written here: if (mt.pbFormat && mt.cbFormat) {


MySQL

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: val != end && val != end sql item_timefunc.cc 2971


static date_time_format_types
get_date_time_result_type(const char *format, uint length)
{
  ....
  for (; val != end && val != end; val++)
  ....
}

Apache HTTP Server

V501 There are identical sub-expressions 'state == rsl_encoding' to the left and to the right of the '||' operator. mod_mime_magic mod_mime_magic.c 787


static int magic_rsl_to_request(request_rec *r)
{
  ....
  if (state == rsl_subtype || state == rsl_encoding ||
      state == rsl_encoding) {
  ....
}

This is what should have been written here: (state == rsl_subtype || state == rsl_separator || state == rsl_encoding).


OpenWsman

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: name && uri && name OpenWsmanLib wsman-xml.c 156


static char *make_qname(
    WsXmlNodeH node, const char *uri, const char *name)
{
  char *buf = NULL;
  if (name && uri && name) {
  ....
}

Most likely this is what should be written here: (node && uri && name).


Intel AMT SDK

V501 There are identical sub-expressions 'options->delivery_password' to the left and to the right of the '||' operator. OpenWsmanLib wsman-client.c 631


static void
wsman_set_subscribe_options(....)
{
  ....
  if(options->delivery_certificatethumbprint ||
     options->delivery_password ||
     options->delivery_password) {
  ....
}

The password is checked twice, while the options->delivery_username variable is not checked.


LLVM/Clang

V501 There are identical sub-expressions 'LBO->hasNoUnsignedWrap ()' to the left and to the right of the '&&' operator. LLVMAnalysis instructionsimplify.cpp 1891


static Value *SimplifyICmpInst(....) {
  ....
  case Instruction::Shl: {
    bool NUW = LBO->hasNoUnsignedWrap() &&
               LBO->hasNoUnsignedWrap();
    bool NSW = LBO->hasNoSignedWrap() &&
               RBO->hasNoSignedWrap();
  ....
}

Most likely this is what should be written here: bool NUW = LBO->hasNoUnsignedWrap() && RBO->hasNoUnsignedWrap();


LLVM/Clang

V501 There are identical sub-expressions 'FoldMskICmp_Mask_AllZeroes' to the left and to the right of the '|' operator. LLVMInstCombine instcombineandorxor.cpp 505


static unsigned getTypeOfMaskedICmp(....)
{
  ....
  result |= (icmp_eq ? (FoldMskICmp_Mask_AllZeroes |
                        FoldMskICmp_Mask_AllZeroes |
                        FoldMskICmp_AMask_Mixed |
                        FoldMskICmp_BMask_Mixed)
                     : (FoldMskICmp_Mask_NotAllZeroes |
                        FoldMskICmp_Mask_NotAllZeroes |
                        FoldMskICmp_AMask_NotMixed |
                        FoldMskICmp_BMask_NotMixed));
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'FoldMskICmp_Mask_NotAllZeroes' to the left and to the right of the '|' operator. LLVMInstCombine instcombineandorxor.cpp 509

LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '||' operator: Op1I->hasOneUse () || Op1I->hasOneUse () LLVMInstCombine instcombineandorxor.cpp 2246


Instruction *InstCombiner::visitXor(BinaryOperator &I) {
  ....
  if (Op0I && Op1I && Op0I->isShift() &&
      Op0I->getOpcode() == Op1I->getOpcode() &&
      Op0I->getOperand(1) == Op1I->getOperand(1) &&
      (Op1I->hasOneUse() || Op1I->hasOneUse())) {
  ....
}

Most likely this is what should be written here: (Op0I->hasOneUse() || Op1I->hasOneUse()).


LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Src1.FloatVal != Src1.FloatVal LLVMInterpreter execution.cpp 437


static GenericValue executeFCMP_UNO(GenericValue Src1,
                                    GenericValue Src2,
                                    Type *Ty) {
  GenericValue Dest;
  if (Ty->isFloatTy())
    Dest.IntVal = APInt(1,(Src1.FloatVal != Src1.FloatVal ||
                           Src2.FloatVal != Src2.FloatVal));
  else
    Dest.IntVal = APInt(1,(Src1.DoubleVal != Src1.DoubleVal ||
                           Src2.DoubleVal != Src2.DoubleVal));
  return Dest;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Src2.FloatVal != Src2.FloatVal LLVMInterpreter execution.cpp 438
  • V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Src1.DoubleVal != Src1.DoubleVal LLVMInterpreter execution.cpp 440
  • V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Src2.DoubleVal != Src2.DoubleVal LLVMInterpreter execution.cpp 441

LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurChar != '\n' && CurChar != '\n' LLVMMCParser asmlexer.cpp 149


AsmToken AsmLexer::LexLineComment() {
  // FIXME: This is broken if we happen to a comment
  // at the end of a file, which was .included, and
  // which doesn't end with a newline.
  int CurChar = getNextChar();
  while (CurChar != '\n' && CurChar != '\n' && CurChar != EOF)
    CurChar = getNextChar();
  ....
}

Most likely this is what should be written here: (CurChar != '\n' && CurChar != '\r' && CurChar != EOF).


LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '||' operator. LLVMSelectionDAG dagcombiner.cpp 7340


bool DAGCombiner::SimplifySelectOps(....) {
  ....
  LoadSDNode *LLD = cast<LoadSDNode>(LHS);
  LoadSDNode *RLD = cast<LoadSDNode>(RHS);
  ....
  if ((LLD->hasAnyUseOfValue(1) &&
       (LLD->isPredecessorOf(CondLHS) ||
        LLD->isPredecessorOf(CondRHS))) ||
      (LLD->hasAnyUseOfValue(1) &&
       (LLD->isPredecessorOf(CondLHS) ||
        LLD->isPredecessorOf(CondRHS))))
    return false;
  ....
}

A Copy-Paste error. The programmer seems to have forgotten to replace LLD with RLD in three places.


LLVM/Clang

V501 There are identical sub-expressions '!DAG.isKnownNeverZero (LHS)' to the left and to the right of the '&&' operator. LLVMX86CodeGen x86isellowering.cpp 11635


static SDValue PerformSELECTCombine(....)
{
  ....
  SDValue LHS = N->getOperand(1);
  SDValue RHS = N->getOperand(2);

  ....
  if (!UnsafeFPMath &&
      !DAG.isKnownNeverZero(LHS) &&
      !DAG.isKnownNeverZero(RHS))
  ....
  if (!UnsafeFPMath &&
      !DAG.isKnownNeverZero(LHS) &&
      !DAG.isKnownNeverZero(LHS))
  ....
}

Maybe RHS should be used in the last line, not LHS.


LLVM/Clang

V501 There are identical sub-expressions 'CondResult.isInvalid()' to the left and to the right of the '||' operator. clangSema semastmt.cpp 899


StmtResult
Sema::ActOnDoStmt(....)
{
  ....
  ExprResult CondResult = CheckBooleanCondition(Cond, DoLoc);
  if (CondResult.isInvalid() || CondResult.isInvalid())
    return StmtError();
  ....
}

LLVM/Clang

V501 There are identical sub-expressions 'P->isMemberPointerType ()' to the left and to the right of the '&&' operator. clangSema sematemplatededuction.cpp 3240


Sema::DeduceTemplateArguments(....)
{
  ....
  if ((P->isPointerType() && A->isPointerType()) ||
      (P->isMemberPointerType() && P->isMemberPointerType()))
  ....
}

This is what should have been written here: (P->isMemberPointerType() && A->isMemberPointerType()).


ReactOS

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: str [0] == '\\' && str [0] == '\\' urlmon uri.c 273


static inline BOOL is_unc_path(const WCHAR *str) {
  return (str[0] == '\\' && str[0] == '\\');
}

ReactOS

V501 There are identical sub-expressions 'SetLocalTime (lpSystemTime)' to the left and to the right of the '&&' operator. timedate dateandtime.c 51


BOOL
SystemSetLocalTime(LPSYSTEMTIME lpSystemTime)
{
  ....
  Ret = SetLocalTime(lpSystemTime) &&
        SetLocalTime(lpSystemTime);
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'SetLocalTime (& SetupData->SystemTime)' to the left and to the right of the '&&' operator. syssetup wizard.c 1398

ReactOS

V501 There are identical sub-expressions '_ILIsControlPanel (pidl)' to the left and to the right of the '||' operator. shell32 she_ocmenu.c 1222


HRESULT
SHEOW_LoadOpenWithItems(SHEOWImpl *This, IDataObject *pdtobj)
{
  ....
  if (_ILIsDesktop(pidl) || _ILIsMyDocuments(pidl) ||
      _ILIsControlPanel(pidl) || _ILIsNetHood(pidl) ||
      _ILIsBitBucket(pidl) || _ILIsDrive(pidl) ||
      _ILIsCPanelStruct(pidl) || _ILIsFolder(pidl) ||
      _ILIsControlPanel(pidl))
  {
    TRACE("pidl is a folder\n");
    SHFree((void*)pidl);
    return E_FAIL;
  }
  ....
}

You have to strain your eyes, but if you look closely, you will notice that _ILIsControlPanel(pidl) is repeated twice.


ReactOS

V501 There are identical sub-expressions 'item->member.para.pCell' to the left and to the right of the '&&' operator. riched20 writer.c 254


static BOOL
ME_StreamOutRTFFontAndColorTbl(....)
{
  ....
  if (item->member.para.pCell && item->member.para.pCell)
  ....
}

ReactOS

V501 There are identical sub-expressions to the left and to the right of the '||' operator. ole32 filelockbytes.c 139


static HRESULT WINAPI FileLockBytesImpl_QueryInterface(
  ILockBytes *iface, REFIID riid, void **ppvObject)
{
  if (IsEqualIID(riid, &IID_ILockBytes) ||
      IsEqualIID(riid, &IID_ILockBytes))
    *ppvObject = iface;
  ....
}

ReactOS

V501 There are identical sub-expressions to the left and to the right of the '==' operator: sizeof (GUID) == sizeof (GUID) ntoskrnl events.c 180


NTSTATUS
PopAddRemoveSysCapsCallback(....)
{
   else if (
     RtlCompareMemory(&Notification->Event,
                      &GUID_DEVICE_INTERFACE_REMOVAL,
                      sizeof(GUID) == sizeof(GUID)))
}

A parenthesis is in a wrong place! A closing parenthesis should be placed after the first operator 'sizeof': "sizeof(GUID)) == sizeof(GUID))".

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '==' operator: sizeof (GUID) == sizeof (GUID) ntoskrnl events.c 178

ReactOS

V501 There are identical sub-expressions '* ScanString == L'\"'' to the left and to the right of the '||' operator. kernel32 proc.c 2326


BOOL
CreateProcessInternalW(....)
{
  ....
  if (*ScanString == L'\"' ||
      *ScanString == L'^' ||
      *ScanString == L'\"')
  ....
}

ReactOS

V501 There are identical sub-expressions to the left and to the right of the '&' operator: dwEnabledOptions & dwEnabledOptions jscript jscript.c 905


static HRESULT WINAPI
JScriptSafety_SetInterfaceSafetyOptions(....)
{
  ....
  This->safeopt = dwEnabledOptions & dwEnabledOptions;
  ....
}

ReactOS

V501 There are identical sub-expressions 'sizeof (mag [0][0])' to the left and to the right of the '/' operator. glu32 mapdescv.cc 131


REAL
Mapdesc::calcPartialVelocity (....)
{
  ....
  const int istride = sizeof(tmp[0]) / sizeof(tmp[0][0][0]);
  const int jstride = sizeof(tmp[0][0]) / sizeof(tmp[0][0][0]);
  const int mistride = sizeof(mag[0]) / sizeof(mag[0][0]);
  const int mjstride = sizeof(mag[0][0]) / sizeof(mag[0][0]);
  ....
}

This is what should have been written here: mjstride = sizeof(mag[0][0]) / sizeof(mag[0][0][0]);


ReactOS

V501 There are identical sub-expressions '!(types [i + 1] & PathPointTypeBezier)' to the left and to the right of the '||' operator. gdiplus graphics.c 925


static GpStatus draw_poly(....)
{
  if((i + 2 >= count)
     || !(types[i + 1] & PathPointTypeBezier)
     || !(types[i + 1] & PathPointTypeBezier)) {
}

IPP Samples

V501 There are identical sub-expressions '(srcB->depth == 16)' to the left and to the right of the '||' operator. ipl iplmpy2d.c 457


IPLFUN(void, iplMpyRCPack2D,
       (IplImage* srcA, IplImage* srcB, IplImage* dst))
{
  ....
  if( (srcA->depth == IPL_DEPTH_8U ) ||
      (srcB->depth == IPL_DEPTH_8U ) ||
      (srcB->depth == IPL_DEPTH_16U) ||
      (srcB->depth == IPL_DEPTH_16U) ||
      (srcA->depth == IPL_DEPTH_1U ) ||
      (srcB->depth == IPL_DEPTH_1U ) )
  ....
}

This is what should have been written here: (srcA->depth == IPL_DEPTH_16U) || (srcB->depth == IPL_DEPTH_16U) ||


IPP Samples

V501 There are identical sub-expressions to the left and to the right of the '-' operator: state->freq - state->freq speech ec_fb.c 253


int ec_fb_GetSubbandNum(void* stat)
{
  _fbECState* state = (_fbECState*)stat;
  return (state->freq - state->freq);
}

Chromium

V501 There are identical sub-expressions 'tempPosition.isNull ()' to the left and to the right of the '||' operator. webcore_remaining accessibilityobject.cpp 489


static VisiblePosition updateAXLineStartForVisiblePosition(....)
{
  ....
  tempPosition = startPosition.previous();
  if (tempPosition.isNull() || tempPosition.isNull())
      break;
  ....
}

Chromium

V501 There are identical sub-expressions 'sizeof (threadcounts)' to the left and to the right of the '/' operator. base_unittests shared_memory_unittest.cc 231


TEST(SharedMemoryTest, MultipleThreads) {
  ....
  int threadcounts[] = { 1, kNumThreads };
  for (size_t i = 0;
       i < sizeof(threadcounts) / sizeof(threadcounts); i++) {
  ....
}

This is what should have been written here: i < sizeof(threadcounts) / sizeof(*threadcounts).


OGRE

V501 There are identical sub-expressions to the left and to the right of the '||' operator. OgreMain ogreparticlesystem.cpp 1358


void ParticleSystem::increaseEmittedEmitterPool(size_t size)
{
  ....
  if (clonedEmitter->getDuration() > 0.0f &&
      (clonedEmitter->getRepeatDelay() > 0.0f ||
       clonedEmitter->getMinRepeatDelay() > 0.0f ||
       clonedEmitter->getMinRepeatDelay() > 0.0f))
   clonedEmitter->setEnabled(false);
  ....
}

Mozilla Firefox

V501 There are identical sub-expressions 'unit [0] == eCSSUnit_Null' to the left and to the right of the '||' operator. nsstyleanimation.cpp 1767


PRBool
nsStyleAnimation::AddWeighted(....)
{
  ....
  if (unit[0] == eCSSUnit_Null || unit[1] == eCSSUnit_Null ||
      unit[0] == eCSSUnit_Null || unit[0] == eCSSUnit_URL) {
    return PR_FALSE;
  }
  ....
}

There seem to be 2 errors at once. The second line in the condition should look like this: unit[0] == eCSSUnit_URL || unit[1] == eCSSUnit_URL.


Mozilla Firefox

V501 There are identical sub-expressions to the left and to the right of the '||' operator. nsdisplaylist.cpp 767


static PRBool IsZPositionLEQ(nsDisplayItem* aItem1,
                             nsDisplayItem* aItem2,
                             void* aClosure) {
  if (!aItem1->GetUnderlyingFrame()->Preserves3D() ||
      !aItem1->GetUnderlyingFrame()->Preserves3D()) {
    return IsContentLEQ(aItem1, aItem2, aClosure);
  }
  ....
}

Most likely this is what should be written here: !aItem1->.... || !aItem2->....


Mozilla Firefox

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: aXResolution > 0.0 && aXResolution > 0.0 nspresshell.cpp 5114


nsresult PresShell::SetResolution(float aXResolution,
                                  float aYResolution)
{
  if (!(aXResolution > 0.0 && aXResolution > 0.0)) {
    return NS_ERROR_ILLEGAL_VALUE;
  }
  ....
}

This is what should have been written here: (aXResolution > 0.0 && aYResolution > 0.0)


Mozilla Firefox

V501 There are identical sub-expressions 'protocol.EqualsIgnoreCase ("ftp")' to the left and to the right of the '||' operator. mozinlinespellwordutil.cpp 1034


if (protocol.EqualsIgnoreCase("http") ||
    protocol.EqualsIgnoreCase("https") ||
    protocol.EqualsIgnoreCase("news") ||
    protocol.EqualsIgnoreCase("ftp") ||
    protocol.EqualsIgnoreCase("file") ||
    protocol.EqualsIgnoreCase("javascript") ||
    protocol.EqualsIgnoreCase("ftp")) {....}

Mozilla Firefox

V501 There are identical sub-expressions to the left and to the right of the '||' operator. svgorientsmiltype.cpp 161


nsresult
SVGOrientSMILType::Interpolate(....)
{
  ....
  if (aStartVal.mU.mOrient.mOrientType !=
      nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE ||
      aStartVal.mU.mOrient.mOrientType !=
      nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE)
  {
    // TODO: it would be nice to be able
    // to handle auto angles too.
    return NS_ERROR_FAILURE;
  }
  ....
}

Quake-III-Arena

V501 There are identical sub-expressions '(result->flags & 64)' to the left and to the right of the '||' operator. botlib be_ai_move.c 3236


void BotMoveToGoal(....)
{
  ....
  if ((result->flags & MOVERESULT_ONTOPOF_FUNCBOB) ||
      (result->flags & MOVERESULT_ONTOPOF_FUNCBOB))
  {
    ms->reachability_time = AAS_Time() + 5;
  }
  ....
}

Quake-III-Arena

V501 There are identical sub-expressions 'fabs(dir[1]) > test->radius' to the left and to the right of the '||' operator. q3map lightv.c 1962


int VL_FindAdjacentSurface(....)
{
  ....
  if (fabs(dir[0]) > test->radius ||
      fabs(dir[1]) > test->radius ||
      fabs(dir[1]) > test->radius)
  {
  ....
}

Scintilla

V501 There are identical sub-expressions 'ch == '/'' to the left and to the right of the '||' operator. lexmmixal.cxx 40


inline bool isMMIXALOperator(char ch) {
  if (isascii(ch) && isalnum(ch))
    return false;
  if (ch == '+' || ch == '-' || ch == '|' || ch == '^' ||
      ch == '*' || ch == '/' || ch == '/' ||
      ch == '%' || ch == '<' || ch == '>' || ch == '&' ||
      ch == '~' || ch == '$' ||
      ch == ',' || ch == '(' || ch == ')' ||
      ch == '[' || ch == ']')
    return true;
  return false;
}

Dolphin Emulator

V501 There are identical sub-expressions '~ComputeKnownZeroBits(Op1)' to the left and to the right of the '&' operator. Core ir.cpp 1215


bool IRBuilder::maskedValueIsZero(InstLoc Op1, InstLoc Op2) const
{
  return (~ComputeKnownZeroBits(Op1) &
          ~ComputeKnownZeroBits(Op1)) == 0;
}

ADAPTIVE Communication Environment (ACE)

V501 There are identical sub-expressions 'url_string[pos + 1] == '/'' to the left and to the right of the '&&' operator. INet urlbase.cpp 205


bool URL_Base::strip_scheme (ACE_CString& url_string)
{
  ....
  ACE_CString::size_type pos = url_string.find (':');
  if (pos > 0 &&
      url_string[pos+1] == '/' &&
      url_string[pos+1] == '/')
  {
    ....
    // skip '<protocol>://'
    url_string = url_string.substr (pos+3);
  }
  ....
}

Most likely this is what should be written here: url_string[pos+1] == '/' && url_string[pos+2] == '/'.


WinMerge

V501 There are identical sub-expressions to the left and to the right of the '||' operator: c == L'}' || c == L'}' Merge ccrystaleditview.cpp 1556


bool
isopenbrace (TCHAR c)
{
  return c == _T ('{') || c == _T ('(') ||
         c == _T ('[') || c == _T ('<');
}

bool
isclosebrace (TCHAR c)
{
  return c == _T ('}') || c == _T ('}') ||
         c == _T (']') || c == _T ('>');
}

The variable in the second function is compared to '} twice. A comparison to the ')' character is missing.


WinMerge

V501 There are identical sub-expressions 'pView1->GetTextBufferEol(line)' to the left and to the right of the '!=' operator. Merge mergedoclinediffs.cpp 216


void CMergeDoc::Computelinediff(
  CCrystalTextView *pView1, CCrystalTextView *pView2, ....)
{
  ....
  if (pView1->GetTextBufferEol(line) !=
      pView1->GetTextBufferEol(line))
  ....
}

LLVM/Clang

V501 There are identical sub-expressions 'SM.getExpansionColumnNumber(ContainerREnd)' to the left and to the right of the '>=' operator. clangStaticAnalyzerCore bugreporter.cpp 925


bool EdgeBuilder::containsLocation(
  const PathDiagnosticLocation &Container,
  const PathDiagnosticLocation &Containee)
{
  ....
  return (ContainerBegLine <= ContaineeBegLine &&
          ContainerEndLine >= ContaineeEndLine &&
          (ContainerBegLine != ContaineeBegLine ||
           SM.getExpansionColumnNumber(ContainerRBeg) <=
           SM.getExpansionColumnNumber(ContaineeRBeg)) &&
          (ContainerEndLine != ContaineeEndLine ||
           SM.getExpansionColumnNumber(ContainerREnd) >=
           SM.getExpansionColumnNumber(ContainerREnd)));
}

The ContaineeREnd variable should have been used in the last line instead of ContainerREnd. You don't see the difference? Spell the words.


LLVM/Clang

V501 There are identical sub-expressions 'Ty2->isIntegerType()' to the left and to the right of the '&&' operator. SampleAnalyzerPlugin svalbuilder.h 81


bool haveSameType(QualType Ty1, QualType Ty2) {
  return (Context.getCanonicalType(Ty1) ==
          Context.getCanonicalType(Ty2) ||
          (Ty2->isIntegerType() &&
           Ty2->isIntegerType()));
}

Blender

V501 There are identical sub-expressions to the left and to the right of the '>=' operator: start >= start bf_python_bmesh bmesh_py_types_customdata.c 442


static PyObject *bpy_bmlayercollection_subscript_slice(
  BPy_BMLayerCollection *self,
  Py_ssize_t start, Py_ssize_t stop)
{
  ....
  if (start >= start) start = len - 1;
  if (stop >= stop)   stop  = len - 1;
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '>=' operator: stop >= stop bf_python_bmesh bmesh_py_types_customdata.c 443

Blender

V501 There are identical sub-expressions to the left and to the right of the '||' operator: (res->pw == 0) || (res->pw == 0) extern_openjpeg pi.c 219


typedef struct opj_pi_resolution {
  int pdx, pdy;
  int pw, ph;
} opj_pi_resolution_t;

static bool pi_next_rpcl(opj_pi_iterator_t * pi) {
  ....
  if ((res->pw==0)||(res->pw==0)) continue;
  ....
}

Most likely this is what should be written here: (res->pw==0)||(res->ph==0).

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: (res->pw == 0) || (res->pw == 0) extern_openjpeg pi.c 300
  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: (res->pw == 0) || (res->pw == 0) extern_openjpeg pi.c 379

Blender

V501 There are identical sub-expressions 'EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET' to the left and to the right of the '|' operator. eevee_cryptomatte.cc 18


void Cryptomatte::begin_sync()
{
  const eViewLayerEEVEEPassType enabled_passes =

    static_cast<eViewLayerEEVEEPassType>(
      inst.film.enabled_passes_get() &
      (  EEVEE_RENDER_PASS_CRYPTOMATTE_OBJECT |
         EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET  |
         EEVEE_RENDER_PASS_CRYPTOMATTE_ASSET ) );
  ....
}

Blender

V501 There are identical sub-expressions 'dst_edge[0] < total_verts' to the left and to the right of the '&&' operator. obj_import_mesh.cc 266


void MeshFromGeometry::create_edges(Mesh *mesh)
{
  ....
  for (int i = 0; i < tot_edges; ++i)
  {
    ....
    dst_edge[0] = mesh_geometry_.global_to_local_vertices_
                                .lookup_default(src_edge[0], 0);
    dst_edge[1] = mesh_geometry_.global_to_local_vertices_
                                .lookup_default(src_edge[1], 0);
    BLI_assert(   dst_edge[0] < total_verts
               && dst_edge[0] < total_verts);
  }
  ....
}

Blender

V501 There are identical sub-expressions 'ANIMFILTER_FCURVESONLY' to the left and to the right of the '|' operator. graph_select.cc 178


static void get_nearest_fcurve_verts_list (bAnimContext *ac,
                                           const int mval[2],
                                           ListBase *matches)
{
  ....
  filter = (ANIMFILTER_DATA_VISIBLE  |
            ANIMFILTER_CURVE_VISIBLE |
            ANIMFILTER_FCURVESONLY   |
            ANIMFILTER_NODUPLIS      |
            ANIMFILTER_FCURVESONLY);
  ....
}

MAME

V501 There are identical sub-expressions 'offset != (0x370 >> 1)' to the left and to the right of the '&&' operator. decoprot.c 118


WRITE16_HANDLER( deco16_104_prot_w )
{
  ....
  if (offset != (0x150 >> 1) &&
      offset != (0x0 >> 1) &&
      offset != (0x110 >> 1) &&
      offset != (0x280 >> 1) &&
      offset != (0x290 >> 1) &&
      offset != (0x2b0 >> 1) &&
      offset != (0x370 >> 1) &&   // <=
      offset != (0x3c0 >> 1) &&   // <=
      offset != (0x370 >> 1) &&   // <=
      offset != (0x3c0 >> 1) &&   // <=
      offset != (0x430 >> 1) &&
      offset != (0x460 >> 1) &&
      offset != (0x5a0 >> 1) &&
      offset != (0x5b0 >> 1) &&
      offset != (0x6e0 >> 1) &&
      offset != (0x7d0 >> 1)
  )
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'offset != (0x3c0 >> 1)' to the left and to the right of the '&&' operator. decoprot.c 118
  • V501 There are identical sub-expressions 'offset != 0x2c / 2' to the left and to the right of the '&&' operator. decoprot.c 240
  • V501 There are identical sub-expressions 'offset != 0xe' to the left and to the right of the '&&' operator. decoprot.c 447

Trans-Proteomic Pipeline

V501 There are identical sub-expressions 'szPeptide[i + 1] != 'P'' to the left and to the right of the '&&' operator. Comet_fastadb comet-fastadb1.cxx 1906


void DIGEST_PROTEIN(char *szSeq,
       int iLenSeq)
{
  ....
  if (pOptions.bMarkNXST
      && szPeptide[i] == 'N'
      && szPeptide[i + 1] != 'P'
      && (szPeptide[i + 2] == 'S' ||
          szPeptide[i + 2] == 'T')
      && szPeptide[i + 1] != 'P')
  ....
}

The index in the last line should be this: [i + 3].


Visualization Toolkit (VTK)

V501 There are identical sub-expressions 'newPos[2] != oldPos[2]' to the left and to the right of the '||' operator. vtkCharts vtkpiecewisecontrolpointsitem.cxx 129


void vtkPiecewiseControlPointsItem::SetControlPoint(
  vtkIdType index, double* newPos)
{
  double oldPos[4];
  this->PiecewiseFunction->GetNodeValue(index, oldPos);
  if (newPos[0] != oldPos[0] || newPos[1] != oldPos[1] ||
      newPos[2] != oldPos[2] || newPos[2] != oldPos[2])
    {
      this->PiecewiseFunction->SetNodeValue(index, newPos);
    }
}

A misprint. The last array items are not compared.


Visualization Toolkit (VTK)

V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[0] - outExt[0] vtkFiltering vtkdatasetattributes.cxx 457


template <class iterT>
void vtkDataSetAttributesCopyValues(....)
{
  ....
  inZPtr +=
    (outExt[0]-outExt[0])*inIncs[0] * data_type_size +
    (outExt[2] - outExt[2])*inIncs[1] * data_type_size +
    (outExt[4] - outExt[4])*inIncs[2] * data_type_size;
  ....
}

Meaningless code. It's equivalent to inZPtr += 0;

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[2] - outExt[2] vtkFiltering vtkdatasetattributes.cxx 458
  • V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[4] - outExt[4] vtkFiltering vtkdatasetattributes.cxx 459
  • V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[0] - outExt[0] vtkFiltering vtkdatasetattributes.cxx 490
  • And 2 additional diagnostic messages.

Visualization Toolkit (VTK)

V501 There are identical sub-expressions 'this->GetMTime() > this->BuildTime' to the left and to the right of the '||' operator. vtkFiltering vtkdiscretizablecolortransferfunction.cxx 85


void vtkDiscretizableColorTransferFunction::Build()
{
  ....
  if (this->Discretize &&
      (this->GetMTime() > this->BuildTime ||
       this->GetMTime() > this->BuildTime))
  ....
}

Visualization Toolkit (VTK)

V501 There are identical sub-expressions to the left and to the right of the '||' operator: gridType == 11 || gridType == 11 vtkHybrid vtktransformtogrid.cxx 184


void vtkTransformToGrid::UpdateShiftScale()
{
  int gridType = this->GridScalarType;
  if (gridType == VTK_DOUBLE || gridType == VTK_DOUBLE)
  ....
}

Visualization Toolkit (VTK)

V501 There are identical sub-expressions to the left and to the right of the '>=' operator: allocateExtent[1] >= allocateExtent[1] vtkImaging vtkimagestencildata.cxx 1178


void vtkImageStencilRaster::PrepareForNewData(....)
{
  ....
  if (allocateExtent &&
      allocateExtent[1] >= allocateExtent[1])
  ....
}

Visualization Toolkit (VTK)

V501 There are identical sub-expressions '(minX > imageViewportSize[0] - 1 && maxX > imageViewportSize[0] - 1)' to the left and to the right of the '||' operator. vtkVolumeRendering vtkfixedpointvolumeraycastmapper.cxx 2184


int vtkFixedPointVolumeRayCastMapper::ComputeRowBounds(....)
{
  if ( ( minX < 0 && maxX < 0 ) ||
       ( minY < 0 && maxY < 0 ) ||
       ( minX > imageViewportSize[0]-1 &&
         maxX > imageViewportSize[0]-1 ) ||
       ( minX > imageViewportSize[0]-1 &&
         maxX > imageViewportSize[0]-1 ) )
  ....
}

The consequences of the Copy-Paste method. A null index is used everywhere.


Visualization Toolkit (VTK)

V501 There are identical sub-expressions '(mat[0 * 4 + 3] != 0)' to the left and to the right of the '||' operator. vtkVolumeRendering vtkprojectedtetrahedramapper.cxx 134


template<class point_type>
void vtkProjectedTetrahedraMapperTransformPoints(....)
{
  ....
  if (   (mat[0*4+3] != 0) || (mat[1*4+3] != 0)
      || (mat[0*4+3] != 0) || (mat[1*4+3] != 1) )
  ....
}

Visualization Toolkit (VTK)

V501 There are identical sub-expressions 'sub->negNsSet->value' to the left and to the right of the '==' operator. vtklibxml2 xmlschemas.c 13873


static int
xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
                          xmlSchemaWildcardPtr super)
{
  ....
  if ((sub->negNsSet != NULL) &&
      (super->negNsSet != NULL) &&
      (sub->negNsSet->value == sub->negNsSet->value))
      return (0);
  ....
}

This is what should have been written here: (sub->negNsSet->value == super->negNsSet->value).


MongoDB

V501 There are identical sub-expressions to the left and to the right of the '==' operator: buildIndexes == buildIndexes rs_config.h 101


bool operator==(const MemberCfg& r) const {
  ....
  return _id==r._id && votes == r.votes &&
         h == r.h && priority == r.priority &&
         arbiterOnly == r.arbiterOnly &&
         slaveDelay == r.slaveDelay &&
         hidden == r.hidden &&
         buildIndexes == buildIndexes;        // <=
}

ffdshow

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: pict.rectClip != pict.rectClip timgfilterresize.cpp 80


bool TimgFilterResize::is(const TffPictBase &pict,
                          const TfilterSettingsVideo *cfg0)
{
  ....
  return pict.rectFull != newRectFull ||
         pict.rectClip != pict.rectClip;
  ....
}

ReactOS

V501 There are identical sub-expressions '(* DebugOptionEnd == ' ')' to the left and to the right of the '||' operator. ntoskrnl kdinit.c 194


BOOLEAN
KdInitSystem(IN ULONG BootPhase,
             IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
  ....
  /* Check if this is a comma, a space or a tab */
  if ((*DebugOptionEnd == ',') ||
      (*DebugOptionEnd == ' ') ||
      (*DebugOptionEnd == ' '))
  ....
}

This is an interesting example. There is no error here actually. The last blank is not a blank, but a tab. PVS-Studio doesn't distinguish between blanks and tabs, that's why it has generated a false positive. But this false positive has proved to be useful because it's outrageous to compare something to a tab. This is what should have been written here: (*DebugOptionEnd == '\t').


Samba

V501 There are identical sub-expressions 'ace->type == SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT' to the left and to the right of the '||' operator. sddl.c 528


static char *sddl_encode_ace(TALLOC_CTX *mem_ctx,
                             const struct security_ace *ace,
                             const struct dom_sid *domain_sid)
{
  ....
  if (ace->type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT ||
      ace->type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT ||
      ace->type == SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT ||
      ace->type == SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT) {
  ....
}

Samba

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: s1_len != s1_len pdbtest.c 106


static bool samu_correct(struct samu *s1, struct samu *s2)
{
  ....
  } else if (s1_len != s1_len) {
    DEBUG(0, ("Password history not written correctly, "
              "lengths differ, want %d, got %d\n",
          s1_len, s2_len));
    ret = False;
  }
  ....
}

Samba

V501 There are identical sub-expressions to the left and to the right of the '>' operator: data > data t_asn1.c 45


int main(void)
{
  ....
  if ((data->length != tests[i].length) ||
      (memcmp(data>data, tests[i].data, data->length) != 0)) {
    printf("Test for %d failed\n", values[i]);
    ok = False;
  }
  ....
}

Most likely this is what should be written here: data->data.


Samba

V501 There are identical sub-expressions to the left and to the right of the '>' operator: i2->pid > i2->pid brlock.c 1901


static int compare_procids(const void *p1, const void *p2)
{
  const struct server_id *i1 = (struct server_id *)p1;
  const struct server_id *i2 = (struct server_id *)p2;

  if (i1->pid < i2->pid) return -1;
  if (i2->pid > i2->pid) return 1;
  return 0;
}

OpenSSL

V501 There are identical sub-expressions '!object->data.key' to the left and to the right of the '||' operator. str_lib.c 475


EVP_PKEY *STORE_get_private_key(....)
{
  STORE_OBJECT *object;
  ....
  if (!object || !object->data.key || !object->data.key)
  {
    STOREerr(STORE_F_STORE_GET_PRIVATE_KEY,
             STORE_R_FAILED_GETTING_KEY);
    return 0;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '!object->data.key' to the left and to the right of the '||' operator. str_lib.c 616
  • V501 There are identical sub-expressions '!object->data.key' to the left and to the right of the '||' operator. str_lib.c 670
  • V501 There are identical sub-expressions '!object->data.key' to the left and to the right of the '||' operator. str_lib.c 811

OpenCV

V501 There are identical sub-expressions to the left and to the right of the '||' operator: _rvec3 || dr3dr1 || dr3dr1 calibration.cpp 415


CV_IMPL void cvComposeRT(
  const CvMat* _rvec1, const CvMat* _tvec1,
  const CvMat* _rvec2, const CvMat* _tvec2,
  CvMat* _rvec3, CvMat* _tvec3,
  CvMat* dr3dr1, CvMat* dr3dt1,
  CvMat* dr3dr2, CvMat* dr3dt2,
  CvMat* dt3dr1, CvMat* dt3dt1,
  CvMat* dt3dr2, CvMat* dt3dt2)
{
  ....
  if( _rvec3 || dr3dr1 || dr3dr1 )
  ....
}

OpenCV

V501 There are identical sub-expressions 'cmptlut[0] < 0' to the left and to the right of the '||' operator. grfmt_jpeg2000.cpp 215


bool Jpeg2KDecoder::readHeader()
{
  ....
  cmptlut[0] = ....
  cmptlut[1] = ....
  cmptlut[2] = ....
  if( cmptlut[0] < 0 || cmptlut[1] < 0 || cmptlut[0] < 0 )
    result = false;
  ....
}

OpenCV

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: dst_size.height != dst_size.height epilines.cpp 2118


CV_IMPL IplImage* icvCreateIsometricImage(....)
{
  ....
  if( !dst || dst->depth != desired_depth ||
      dst->nChannels != desired_num_channels ||
      dst_size.width != src_size.width ||
      dst_size.height != dst_size.height )
  ....
}

OpenCV

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: cat_var_count != cat_var_count tree.cpp 1415


void CvDTreeTrainData::read_params(....)
{
  ....
  if( cat_var_count != cat_var_count ||
      ord_var_count != ord_var_count )
    CV_ERROR(CV_StsParseError,
      "var_type is inconsistent with "
      "cat_var_count and ord_var_count");
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '!=' operator: ord_var_count != ord_var_count tree.cpp 1415

OpenCV

V501 There are identical sub-expressions to the left and to the right of the '==' operator: M.size() == M.size() imgwarp.cpp 3672


CV_IMPL CvMat*
cv2DRotationMatrix( CvPoint2D32f center, double angle,
                    double scale, CvMat* matrix )
{
  cv::Mat M0 = cv::cvarrToMat(matrix),
          M = cv::getRotationMatrix2D(center, angle, scale);
  CV_Assert( M.size() == M.size() );
  M.convertTo(M0, M0.type());
  return matrix;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: data && dims >= 1 && data mat.hpp 434
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: 0 <= d && _sizes && d <= 32 && _sizes matrix.cpp 186
  • V501 There are identical sub-expressions to the left and to the right of the '==' operator: M.size() == M.size() imgwarp.cpp 3685

ReactOS

V501 There are identical sub-expressions 'src_tex->target != PIPE_TEXTURE_2D' to the left and to the right of the '&&' operator. u_blit.c 421


void util_blit_pixels_writemask(....)
{
  ....
  if ((src_tex == dst_surface->texture &&
      dst_surface->u.tex.level == src_level &&
      dst_surface->u.tex.first_layer == srcZ0) ||
      (src_tex->target != PIPE_TEXTURE_2D &&
      src_tex->target != PIPE_TEXTURE_2D &&
      src_tex->target != PIPE_TEXTURE_RECT))
  ....
}

ReactOS

V501 There are identical sub-expressions 'src->channel[i].type' to the left and to the right of the '!=' operator. translate_generic.c 776


struct util_format_channel_description
{
   unsigned type:5;
   unsigned normalized:1;
   unsigned pure_integer:1;
   unsigned size:9;
};

static boolean
is_legal_int_format_combo(
  const struct util_format_description *src,
  const struct util_format_description *dst )
{
  ....
  for (i = 0; i < nr; i++) {
    /* The signs must match. */
    if (src->channel[i].type != src->channel[i].type) {
      return FALSE;
    }
  ....
}

This is what should have been written here: src->channel[i].type != dst->channel[i].type


ReactOS

V501 There are identical sub-expressions '!(types[i + 1] & PathPointTypeBezier)' to the left and to the right of the '||' operator. graphics.c 1912


static GpStatus draw_poly(....)
{
  ....
  if((i + 2 >= count) ||
     !(types[i + 1] & PathPointTypeBezier) ||
     !(types[i + 1] & PathPointTypeBezier))
  {
    ERR("Bad bezier points\n");
    goto end;
  }
  ....
}

ReactOS

V501 There are identical sub-expressions '!LunExt->IdentifyData.SectorsPerTrack' to the left and to the right of the '||' operator. id_init.cpp 1528


VOID NTAPI UniAtaReadLunConfig(....)
{
  if(!LunExt->IdentifyData.SectorsPerTrack ||
     !LunExt->IdentifyData.NumberOfCylinders ||
     !LunExt->IdentifyData.SectorsPerTrack)
    ....
}

ReactOS

V501 There are identical sub-expressions to the left and to the right of the '||' operator: (ir->from == 0) || (ir->from == 0) ir_validate.cpp 123


ir_visitor_status
ir_validate::visit_leave(ir_loop *ir)
{
  if (ir->counter != NULL) {
    if ((ir->from == NULL) || (ir->from == NULL) ||
        (ir->increment == NULL)) {
  ....
}

This is what should have been written here: (ir->from == NULL) || (ir->to == NULL)

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: (ir->from != 0) || (ir->from != 0) ir_validate.cpp 139

Windows 8 Driver Samples

V501 There are identical sub-expressions 'sizeof (tempString)' to the left and to the right of the '/' operator. utils.c 931


BOOLEAN
DsmpFindSupportedDevice(
    _In_ IN PUNICODE_STRING DeviceName,
    _In_ IN PUNICODE_STRING SupportedDevices
    )
{
  WCHAR tempString[32];
  ....
  tempString[(sizeof(tempString) /
              sizeof(tempString)) - 1] = L'\0';
  ....
}

This is what should have been written here: tempString[(sizeof(tempString) / sizeof(tempString[0])) - 1]


TortoiseSVN

V501 There are identical sub-expressions '((sc.state == 11) && isdigit(sc.ch))' to the left and to the right of the '||' operator. lexa68k.cxx 160


static void ColouriseA68kDoc (....)
{
  if (((sc.state == SCE_A68K_NUMBER_DEC) && isdigit(sc.ch))
      ....
      || ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch))
      || ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch))
      ....
}

TortoiseSVN

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: rv && forceucase && (rv) affixmgr.cxx 1784


struct hentry * AffixMgr::compound_check(
  ....
  if (rv && forceucase && (rv) && ....)
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: rv && forceucase && (rv) affixmgr.cxx 1879

Chromium

V501 There are identical sub-expressions 'field.form_control_type == "text"' to the left and to the right of the '||' operator. autocomplete_history_manager.cc 35


bool IsTextField(const FormFieldData& field) {
  return
    field.form_control_type == "text" ||
    field.form_control_type == "search" ||
    field.form_control_type == "tel" ||
    field.form_control_type == "url" ||
    field.form_control_type == "email" ||
    field.form_control_type == "text";
}

Mesa 3D Graphics Library

V501 There are identical sub-expressions 'parseState->isStateProgram' to the left and to the right of the '&&' operator. nvvertparse.c 576


static GLboolean
Parse_MaskedDstReg(....)
{
  ....
  else if (parseState->isStateProgram && token[0] == 'c' &&
           parseState->isStateProgram) {
  ....
}

Chromium

V501 There are identical sub-expressions 'sizeof (kRequestFrameCounts)' to the left and to the right of the '/' operator. test_audio_config.cc 56


std::string TestAudioConfig::TestValidConfigs() {
  ....
  static const uint32_t kRequestFrameCounts[] = {
    PP_AUDIOMINSAMPLEFRAMECOUNT,
    PP_AUDIOMAXSAMPLEFRAMECOUNT,
    1024,
    2048,
    4096
  };
  ....
  for (size_t j = 0;
    j < sizeof(kRequestFrameCounts)/sizeof(kRequestFrameCounts);
    j++) {
  ....
}

Chromium

V501 There are identical sub-expressions to the left and to the right of the '-' operator: data_[M02] - data_[M02] matrix3_f.cc 128


Vector3dF
Matrix3F::SolveEigenproblem(Matrix3F* eigenvectors) const
{
  // The matrix must be symmetric.
  const float epsilon = std::numeric_limits<float>::epsilon();
  if (std::abs(data_[M01] - data_[M10]) > epsilon ||
      std::abs(data_[M02] - data_[M02]) > epsilon ||
      std::abs(data_[M12] - data_[M21]) > epsilon) {
    NOTREACHED();
    return Vector3dF();
  }
  ....
}

Curl

V501 There are identical sub-expressions to the left and to the right of the '||' operator: !cookies->cookies ||!cookies->cookies cookie.c 880


void Curl_cookie_clearsess(struct CookieInfo *cookies)
{
  ....
  if(!cookies->cookies || !cookies->cookies)
    return;
  ....
}

Multi Theft Auto

V501 There are identical sub-expressions to the left and to the right of the '||' operator: us == 1009 || us == 1009 cvehicleupgrades.cpp 84


bool CVehicleUpgrades::IsUpgradeCompatible (
  unsigned short usUpgrade )
{
  ....
  case 402: return ( us == 1009 || us == 1009 || us == 1010 );
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'us == 1009' to the left and to the right of the '||' operator. cvehicleupgrades.cpp 142

Multi Theft Auto

V501 There are identical sub-expressions 'm_fSampleRate != 0.0f' to the left and to the right of the '||' operator. cclientplayervoice.h 58


bool IsTempoChanged(void)
{
  return m_fSampleRate != 0.0f ||
         m_fSampleRate != 0.0f ||
         m_fTempo != 0.0f;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'm_fSampleRate != 0.0f' to the left and to the right of the '||' operator. cclientsound.h 71

Boost (C++ libraries)

V501 There are identical sub-expressions to the left and to the right of the '/' operator: p1.z / p1.z lorenz_point.cpp 61


point3D operator/(const point3D &p1, const point3D &p2)
{
  return point3D(p1.x/p2.x, p1.y/p2.y, p1.z/p1.z);
}

OpenMS

V501 There are identical sub-expressions 'spectra_offsets.empty()' to the left and to the right of the '&&' operator. mzmlhandler.h 5288


std::vector<std::pair<std::string, long>> spectra_offsets;
std::vector<std::pair<std::string, long>> chromatograms_offsets;

template <typename MapType>
void MzMLHandler<MapType>::writeFooter_(std::ostream& os)
{
  ....
  int indexlists;
  if (spectra_offsets.empty() && spectra_offsets.empty() )
  {
    indexlists = 0;
  }
  else if (!spectra_offsets.empty() && !spectra_offsets.empty())
  {
    indexlists = 2;
  }
  else
  {
    indexlists = 1;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '!spectra_offsets.empty()' to the left and to the right of the '&&' operator. mzmlhandler.h 5292

AssaultCube Reloaded

V501 There are identical sub-expressions 'players[i]->pBot' to the left and to the right of the '&&' operator. world.cpp 440


bool empty_world(int factor, bool force)
{  ....
  if(players[i] && players[i]->pBot && players[i]->pBot){
  ....
}

QuantLib

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: d1.xmin_ == 0.0 && d1.xmin_ == 0.0 distribution.cpp 281


Distribution ManipulateDistribution::convolve(
  const Distribution& d1, const Distribution& d2) {
  ....
  QL_REQUIRE (d1.xmin_ == 0.0 && d1.xmin_ == 0.0,
              "distributions offset larger than 0");
  ....
}

Most likely this is what should be written here: d1.xmin_ == 0.0 && d2.xmin_ == 0.0,


VirtualDub

V501 There are identical sub-expressions 'stream.mChunkCount' to the left and to the right of the '&&' operator. VirtualDub avioutputfile.cpp 761


void AVIOutputFile::finalize() {
  ....
  if (stream.mChunkCount && hdr.dwScale && stream.mChunkCount)
  ....
}

Geant4 software

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: fMatIndex1 >= 0 && fMatIndex1 >= 0 G4xrays g4forwardxraytr.cc 620


G4VParticleChange* G4ForwardXrayTR::PostStepDoIt(
  const G4Track& aTrack, const G4Step& aStep)
{
  ....
  if (     iMat == jMat
      || (    (fMatIndex1 >= 0 && fMatIndex1 >= 0)
           && ( iMat != fMatIndex1 && iMat != fMatIndex2 )
           && ( jMat != fMatIndex1 && jMat != fMatIndex2 )  )
  ....
}

Most likely this is what should be written here: (fMatIndex1 >= 0 && fMatIndex2 >= 0)


Geant4 software

V501 There are identical sub-expressions to the left and to the right of the '||' operator: p.x() != 0. || p.x() != 0. G4csg g4cons.cc 2041


G4double G4Cons::DistanceToOut( const G4ThreeVector& p,
                                const G4ThreeVector& v,
                                const G4bool calcNorm,
                                      G4bool *validNorm,
                                      G4ThreeVector *n) const
{
  ....
  if( p.x() != 0. || p.x() != 0.)
  {
    G4cout << "point phi = " << std::atan2(p.y(),p.x())/degree
           << " degree" << G4endl << G4endl ;
  }
  ....
}

Most likely this is what should be written here: p.x() != 0. || p.y() != 0.


Geant4 software

V501 There are identical sub-expressions to the left and to the right of the '==' operator: enableNull == enableNull G4hadronic_deex_fermi_breakup g4fermiintegerpartition.icc 58


inline G4bool G4FermiIntegerPartition::
operator==(const G4FermiIntegerPartition& right)
{
  return (total == right.total &&
          enableNull == enableNull &&
          partition == right.partition);
}

Most likely this is what should be written here: enableNull == right.enableNull


Geant4 software

V501 There are identical sub-expressions 'trk1.GetDefinition() == G4Neutron::Neutron()' to the left and to the right of the '||' operator. G4had_im_r_matrix g4mesonabsorption.cc 285


G4double G4MesonAbsorption::
GetTimeToAbsorption(const G4KineticTrack& trk1,
                    const G4KineticTrack& trk2)
{
  ....
  if(( trk1.GetDefinition() == G4Neutron::Neutron() ||
       trk1.GetDefinition() == G4Neutron::Neutron() ) &&
       sqrtS>1.91*GeV && pi*distance>maxChargedCrossSection)
    return time;
  ....
}

Most likely this is what should be written here: trk1.GetDefinition() == G4Neutron::Neutron() || trk2.GetDefinition() == G4Neutron::Neutron()

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'trk1.GetDefinition() == G4Neutron::Neutron()' to the left and to the right of the '||' operator. G4had_im_r_matrix g4scatterer.cc 138

Geant4 software

V501 There are identical sub-expressions to the left and to the right of the '||' operator: ITTU->size() != np || ITTU->size() != np G4emlowenergy g4penelope08rayleighmodel.cc 973


void G4Penelope08RayleighModel::InitializeSamplingAlgorithm(
  const G4Material* mat)
{
  ....
  std::vector<size_t> *ITTL = new std::vector<size_t>;
  std::vector<size_t> *ITTU = new std::vector<size_t>;
  ....
  if (ITTU->size() != np || ITTU->size() != np)
    {
      G4cout << "....." << G4endl;
      G4cout << "....." << G4endl;
      G4Exception();
    }
  ....
}

Most likely this is what should be written here: ITTL->size() != np || ITTU->size() != np


Skia Graphics Engine

V501 There are identical sub-expressions to the left and to the right of the '-' operator: i - i SkCanvasStack.cpp 38


void SkCanvasStack::pushCanvas(....) {
  ....
  for (int i = fList.count() - 1; i > 0; --i) {
    SkIRect localBounds = canvasBounds;
    localBounds.offset(origin - fCanvasData[i-1].origin);

    fCanvasData[i-1].requiredClip.op(localBounds,
                                     SkRegion::kDifference_Op);
    fList[i-i]->clipRegion(fCanvasData[i-1].requiredClip);
  }
  ....
}

Most likely this is what should be written here: fList[i-1]->


Skia Graphics Engine

V501 There are identical sub-expressions 'fitsInBits(k2, 16)' to the left and to the right of the '&&' operator. SkArithmeticMode.cpp 211


static bool fitsInBits(SkScalar x, int bits) {
#ifdef SK_SCALAR_IS_FIXED
  x = SkAbs32(x);
  x += 1 << 7;
  x >>= 8;
  return x < (1 << (bits - 1));
#else
  return SkScalarAbs(x) < (1 << (bits - 1));
#endif
}

SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2,
                                     SkScalar k3, SkScalar k4)
{
  if (fitsInBits(k1, 8) &&
      fitsInBits(k2, 16) &&
      fitsInBits(k2, 16) &&
      fitsInBits(k2, 24)) {
  ....
}

Source Engine SDK

V501 There are identical sub-expressions '(float) nScreenWidth' to the left and to the right of the '/' operator. Client (HL2) viewpostprocess.cpp 1888


static void DrawPyroVignette(....)
{
  ....
  Vector2D vMaxSize(
   ( float )nScreenWidth / ( float )nScreenWidth /
     NUM_PYRO_SEGMENTS * 2.0f,
   ( float )nScreenHeight / ( float )nScreenHeight /
     NUM_PYRO_SEGMENTS * 2.0f );
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '(float) nScreenHeight' to the left and to the right of the '/' operator. Client (HL2) viewpostprocess.cpp 1888

Source Engine SDK

V501 There are identical sub-expressions 'HasCondition(COND_STRIDER_SHOULD_CROUCH)' to the left and to the right of the '&&' operator. Server (HL2) npc_strider.cpp 1164


void CNPC_Strider::GatherHeightConditions(
  const Vector &vTestPos, CBaseEntity *pEntity )
{
  if ( HasCondition( COND_STRIDER_SHOULD_CROUCH ) &&
       HasCondition( COND_STRIDER_SHOULD_CROUCH ) )
    return;
  ....
}

Source Engine SDK

V501 There are identical sub-expressions 'IsJoystickPOVCode(code)' to the left and to the right of the '||' operator. vgui_controls textentry.cpp 1639


void TextEntry::OnKeyCodePressed(KeyCode code)
{
  ....
  if ( IsMouseCode(code) || IsNovintButtonCode(code) ||
       IsJoystickCode(code) || IsJoystickButtonCode(code) ||
       IsJoystickPOVCode(code) || IsJoystickPOVCode(code) ||
       IsJoystickAxisCode(code) )
  ....
}

LibRaw

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: m == 0 && m == 0 dht_demosaic.cpp 260


void DHT::hide_hots() {
  ....
  for (int k = -2; k < 3; k += 2)
    for (int m = -2; m < 3; m += 2)
      if (m == 0 && m == 0)
        continue;
      else
        avg += nraw[nr_offset(y + k, x + m)][kc];

  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: m == 0 && m == 0 aahd_demosaic.cpp 199

Coin3D

V501 There are identical sub-expressions 'size[1] >= 0.0f' to the left and to the right of the '&&' operator. inline.cpp 409


SoVRMLInline::GLRender(SoGLRenderAction * action)
{
  ....
  if ((size[0] >= 0.0f && size[1] >= 0.0f && size[1] >= 0.0f) &&
      ((vis == ALWAYS) ||
       (vis == UNTIL_LOADED && child == NULL))) {
  ....
}

Firebird

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: yyps->errflag != yyps->errflag parse.cpp 23523


int Parser::parseAux()
{
  ....
  if (yyps->errflag != yyps->errflag) goto yyerrlab;
  ....
}

Firebird

V501 There are identical sub-expressions 'node2->nod_desc.dsc_scale' to the left and to the right of the '!=' operator. compile.cpp 156


bool CMP_node_match( const qli_nod* node1, const qli_nod* node2)
{
  ....
  if (node1->nod_desc.dsc_dtype != node2->nod_desc.dsc_dtype ||
      node2->nod_desc.dsc_scale != node2->nod_desc.dsc_scale ||
      node2->nod_desc.dsc_length != node2->nod_desc.dsc_length)
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'node2->nod_desc.dsc_length' to the left and to the right of the '!=' operator. compile.cpp 157
  • V501 There are identical sub-expressions 'node1->nod_arg[e_fun_function]' to the left and to the right of the '!=' operator. compile.cpp 183

CryEngine 3 SDK

V501 There are identical sub-expressions 'angVel.GetLengthSquared() > 0.001f' to the left and to the right of the '||' operator. vehiclemovementarcadewheeled.cpp 3300


void CVehicleMovementArcadeWheeled::InternalPhysicsTick(float dt)
{
  ....
  if (fabsf(m_movementAction.rotateYaw)>0.05f ||
      vel.GetLengthSquared()>0.001f ||
      m_chassis.vel.GetLengthSquared()>0.001f ||
      angVel.GetLengthSquared()>0.001f ||
      angVel.GetLengthSquared()>0.001f)
  ....
}

The JUCE Library

V501 There are identical sub-expressions 'lParam == 0x0203' to the left and to the right of the '||' operator. juce_win32_systemtrayicon.cpp 93


void handleTaskBarEvent (const LPARAM lParam)
{
  if (owner.isCurrentlyBlockedByAnotherModalComponent())
  {
    if (lParam == WM_LBUTTONDOWN || lParam == WM_RBUTTONDOWN
        || lParam == WM_LBUTTONDBLCLK
        || lParam == WM_LBUTTONDBLCLK)
  ....
}

FFmpeg

V501 There are identical sub-expressions '!srcSlice' to the left and to the right of the '||' operator. swscale.c 924


int attribute_align_arg sws_scale(struct SwsContext *c,
  const uint8_t * const srcSlice[],
  const int srcStride[], int srcSliceY,
  int srcSliceH, uint8_t *const dst[],
  const int dstStride[])
{
  int i, ret;
  const uint8_t *src2[4];
  uint8_t *dst2[4];
  uint8_t *rgb0_tmp = NULL;

  if (!srcSlice || !dstStride || !dst || !srcSlice) {
    av_log(c, AV_LOG_ERROR,
      "One of the input parameters to sws_scale() is NULL, "
      "please check the calling code\n");
    return 0;
  }
  ....
}

FFmpeg

V501 There are identical sub-expressions 'codec->sample_aspect_ratio.den != 0' to the left and to the right of the '&&' operator. mux.c 277


static int init_muxer(AVFormatContext *s, AVDictionary **options)
{
  ....
  if (st->sample_aspect_ratio.num != 0 &&
    st->sample_aspect_ratio.den != 0 &&
    codec->sample_aspect_ratio.den != 0 &&
    codec->sample_aspect_ratio.den != 0) {
      av_log(s, AV_LOG_ERROR,
             "Aspect ratio mismatch between muxer "
             "(%d/%d) and encoder layer (%d/%d)\n",
             st->sample_aspect_ratio.num,
             st->sample_aspect_ratio.den,
             codec->sample_aspect_ratio.num,
             codec->sample_aspect_ratio.den);
      ret = AVERROR(EINVAL);
      goto fail;
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'Position.Y >= Control.Center.Y - BoxSize.Y * 0.5f' to the left and to the right of the '&&' operator. svirtualjoystick.cpp 97


static bool PositionIsInside(....)
{
  return
    Position.X >= Control.Center.X - BoxSize.X * 0.5f &&
    Position.X <= Control.Center.X + BoxSize.X * 0.5f &&
    Position.Y >= Control.Center.Y - BoxSize.Y * 0.5f &&
    Position.Y >= Control.Center.Y - BoxSize.Y * 0.5f;
}

Unreal Engine 4

V501 There are identical sub-expressions 'View.StereoPass == eSSP_LEFT_EYE' to the left and to the right of the '||' operator. oculusrifthmd.cpp 1453


void FOculusRiftHMD::PreRenderView_RenderThread(FSceneView& View)
{
  ....
  if (View.StereoPass == eSSP_LEFT_EYE ||
      View.StereoPass == eSSP_LEFT_EYE)
  ....
}

Qt

V501 There are identical sub-expressions to the left and to the right of the '||' operator. qxml.cpp 3249


void QXmlSimpleReader::setFeature(
  const QString& name, bool enable)
{
  ....
  } else if (   name == QLatin1String(
    "http://trolltech.com/xml/features/report-start-end-entity")
             || name == QLatin1String(
    "http://trolltech.com/xml/features/report-start-end-entity"))
  {
  ....
}

Qt

V501 There are identical sub-expressions 'getTouchInputInfo' to the left and to the right of the '&&' operator. qwindowscontext.cpp 216


bool QWindowsUser32DLL::initTouch()
{
  QSystemLibrary library(QStringLiteral("user32"));

  registerTouchWindow   = ....;
  unregisterTouchWindow = ....;
  getTouchInputInfo     = ....;
  closeTouchInputHandle = ....;

  return registerTouchWindow &&
         unregisterTouchWindow &&
         getTouchInputInfo &&
         getTouchInputInfo;
}

Qt

V501 There are identical sub-expressions to the left and to the right of the '||' operator: iw <= 0 || iw <= 0 qwindowsfontengine.cpp 1095


QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(....)
{
  ....
  int gx = gm.x.toInt();
  int gy = gm.y.toInt();
  int iw = gm.width.toInt();
  int ih = gm.height.toInt();
  if (iw <= 0 || iw <= 0)
    return 0;
  ....
}

Qt

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: t2.height() != t2.height() qtest_gui.h 101


inline bool qCompare(QImage const &t1, QImage const &t2, ....)
{
  ....
  if (t1.width() != t2.width() || t2.height() != t2.height()) {
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '!=' operator: t2.height() != t2.height() qtest_gui.h 135

Qt

V501 There are identical sub-expressions '!m_seconds' to the left and to the right of the '&&' operator. qdaytimeduration.cpp 148


QString DayTimeDuration::stringValue() const
{
  ....
  if(!m_hours && !m_minutes && !m_seconds && !m_seconds)
  ....
}

This is what should have been written here: if(!m_hours && !m_minutes && !m_seconds && !m_mseconds)

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: m_seconds || m_seconds qdaytimeduration.cpp 170
  • V501 There are identical sub-expressions '!m_seconds' to the left and to the right of the '&&' operator. qduration.cpp 167
  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: m_seconds || m_seconds qduration.cpp 189

Qt

V501 There are identical sub-expressions '!qIsFinite(w)' to the left and to the right of the '||' operator. qquickcontext2d.cpp 3305


QV4::ReturnedValue
QQuickJSContext2DPrototype::method_getImageData(....)
{
  ....
  qreal x = ctx->callData->args[0].toNumber();
  qreal y = ctx->callData->args[1].toNumber();
  qreal w = ctx->callData->args[2].toNumber();
  qreal h = ctx->callData->args[3].toNumber();
  if (!qIsFinite(x) || !qIsFinite(y) ||
      !qIsFinite(w) || !qIsFinite(w))
  ....
}

Qt

V501 There are identical sub-expressions to the left and to the right of the '||' operator: ignoreTrans || ignoreTrans qdeclarativestategroup.cpp 442


void QDeclarativeStateGroupPrivate::setCurrentStateInternal(
  const QString &state,
  bool ignoreTrans)
{
  ....
  QDeclarativeTransition *transition =
    (ignoreTrans || ignoreTrans) ?
      0 : findTransition(currentState, state);
  ....
}

OpenSSL

V501 There are identical sub-expressions 'type' to the left and to the right of the '&&' operator. s3_pkt.c 952


int ssl3_read_bytes(SSL *s, int type,
                    unsigned char *buf, int len, int peek)
  {
  ....
  if ((type && (type != SSL3_RT_APPLICATION_DATA) &&
       (type != SSL3_RT_HANDSHAKE) && type) ||
      (peek && (type != SSL3_RT_APPLICATION_DATA)))
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'type' to the left and to the right of the '&&' operator. d1_pkt.c 760

SlimDX

V501 There are identical sub-expressions 'box.Maximum.X - box.Minimum.X > radius' to the left and to the right of the '&&' operator. boundingbox.cpp 94


ContainmentType BoundingBox::Contains(
  BoundingBox box, BoundingSphere sphere )
{
  ....
  if( box.Minimum.X + radius <= sphere.Center.X &&
      sphere.Center.X <= box.Maximum.X - radius &&
      box.Maximum.X - box.Minimum.X > radius    &&  // <=
      box.Minimum.Y + radius <= sphere.Center.Y &&
      sphere.Center.Y <= box.Maximum.Y - radius &&
      box.Maximum.Y - box.Minimum.Y > radius    &&
      box.Minimum.Z + radius <= sphere.Center.Z &&
      sphere.Center.Z <= box.Maximum.Z - radius &&
      box.Maximum.X - box.Minimum.X > radius)       // <=
    return ContainmentType::Contains;
  ....
}

Crash Server Library

V501 There are identical sub-expressions 'st.wDay != m_wLogDay' to the left and to the right of the '||' operator. log.cpp 683


class FileMedia: public ILogMedia
{
  ....
  WORD m_wLogYear, m_wLogMonth, m_wLogDay;
  ....
};

void FileMedia::Write(....)
{
  ....
  if (st.wDay != m_wLogDay ||
      st.wMonth != m_wLogMonth ||
      st.wDay != m_wLogDay)
  ....
}

TortoiseGit

V501 There are identical sub-expressions '(!this->m_Rev1.IsEmpty())' to the left and to the right of the '||' operator. gitstatuslistctrl.cpp 1560


class CGitStatusListCtrl :
      public CListCtrl
{
  ....
  CString m_Rev1;
  CString m_Rev2;
  ....
};

void CGitStatusListCtrl::OnContextMenuList(....)
{
  ....
  if( (!this->m_Rev1.IsEmpty()) || (!this->m_Rev1.IsEmpty()) )
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '(!m_Rev1.IsEmpty())' to the left and to the right of the '||' operator. gitstatuslistctrl.cpp 2642
  • V501 There are identical sub-expressions '(!m_Rev1.IsEmpty())' to the left and to the right of the '||' operator. gitstatuslistctrl.cpp 3274

Chromium

V501 There are identical sub-expressions to the left and to the right of the '==' operator: a.data_size == a.data_size cdm_file_io_test.cc 367


bool FileIOTest::MatchesResult(const TestStep& a,
                               const TestStep& b) {
  ....
  return (a.data_size == a.data_size &&
          std::equal(a.data, a.data + a.data_size, b.data));
}

Chromium

V501 There are identical sub-expressions '(delta_y <= 0.0f)' to the left and to the right of the '||' operator. spinning_cube.cc 207


void Frustum(....)
{
  float delta_x = right - left;
  float delta_y = top - bottom;
  float delta_z = far_z - near_z;
  if ((near_z <= 0.0f) ||
      (far_z <= 0.0f) ||
      (delta_z <= 0.0f) ||
      (delta_y <= 0.0f) ||
      (delta_y <= 0.0f))    // <=
    return;
  ....
}

SQLite

V501 There are identical sub-expressions 'p->nToken <= 4' to the left and to the right of the '&&' operator. sqlite3.c 128758


static int fts3EvalPhraseStart(....)
{
  ....
  int bIncrOk = (bOptOk
   && pCsr->bDesc==pTab->bDescIdx
   && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
   && p->nToken<=MAX_INCR_PHRASE_TOKENS && p->nToken>0
   && pTab->bNoIncrDoclist==0
  );
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'p->nToken > 0' to the left and to the right of the '&&' operator. sqlite3.c 128758

Mozilla Firefox

V501 There are identical sub-expressions 'aWidgetType == 237' to the left and to the right of the '||' operator. nsnativethemewin.cpp 2475


NS_IMETHODIMP
nsNativeThemeWin::WidgetStateChanged(....)
{
  ....
  if (aWidgetType == NS_THEME_WINDOW_TITLEBAR ||
      aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED ||
      aWidgetType == NS_THEME_WINDOW_FRAME_LEFT ||
      aWidgetType == NS_THEME_WINDOW_FRAME_RIGHT ||
      aWidgetType == NS_THEME_WINDOW_FRAME_BOTTOM ||
      aWidgetType == NS_THEME_WINDOW_BUTTON_CLOSE ||
      aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE ||  // <=
      aWidgetType == NS_THEME_WINDOW_BUTTON_MINIMIZE ||  // <=
      aWidgetType == NS_THEME_WINDOW_BUTTON_RESTORE) {
    *aShouldRepaint = true;
    return NS_OK;
  ....
}

Mozilla Firefox

V501 There are identical sub-expressions 'nsEditProperty::ul == tagName' to the left and to the right of the '||' operator. nshtmlcssutils.cpp 432


bool
nsHTMLCSSUtils::IsCSSEditableProperty(....)
{
  ....
  if (aAttribute && aAttribute->EqualsLiteral("align") &&
      (nsEditProperty::ul == tagName                       // <=
       || nsEditProperty::ol == tagName
       || nsEditProperty::dl == tagName
       || nsEditProperty::li == tagName
       || nsEditProperty::dd == tagName
       || nsEditProperty::dt == tagName
       || nsEditProperty::address == tagName
       || nsEditProperty::pre == tagName
       || nsEditProperty::ul == tagName)) {                // <=
    return true;
  }
  ....
}

Mozilla Firefox

V501 There are identical sub-expressions 'listener->DopplerFactor()' to the left and to the right of the '/' operator. pannernode.cpp 529


float
PannerNode::ComputeDopplerShift()
{
  ....
  double scaledSpeedOfSound = listener->DopplerFactor() /
                              listener->DopplerFactor();
  ....
}

Mozilla Firefox

V501 There are identical sub-expressions 'size_t (destinationBus->mDuration) >= framesToProcess' to the left and to the right of the '&&' operator. reverb.cpp 192


void Reverb::process(....)
{
  ....
  bool isCopySafe =
    destinationChannelL &&
    destinationChannelR &&
    size_t(destinationBus->mDuration) >= framesToProcess &&
    size_t(destinationBus->mDuration) >= framesToProcess;
  ....
}

Newton Game Dynamics

V501 There are identical sub-expressions 'info->IsType(dSceneCacheInfo::GetRttiType())' to the left and to the right of the '||' operator. dscene.cpp 125


static void PopupateTextureCacheNode (dScene* const scene)
{
  ....
  if (!(info->IsType(dSceneCacheInfo::GetRttiType()) ||
        info->IsType(dSceneCacheInfo::GetRttiType()))) {
  ....
}

Wine Is Not an Emulator

V501 There are identical sub-expressions '!lpScaleWindowExtEx->xNum' to the left and to the right of the '||' operator. enhmetafile.c 1418


BOOL WINAPI PlayEnhMetaFileRecord(....)
{
  ....
  if (!lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->xDenom ||
      !lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->yDenom)
    break;
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '|' operator: VT_ARRAY | VT_ARRAY vartest.c 2161
  • V501 There are identical sub-expressions to the left and to the right of the '==' operator: ddsd3.lpSurface == ddsd3.lpSurface dsurface.c 272

Wine Is Not an Emulator

V501 There are identical sub-expressions '!(types[i + 1] & PathPointTypeBezier)' to the left and to the right of the '||' operator. graphics.c 1751


static GpStatus draw_poly(.... INT count, BOOL caps)
{
  for(i = 1; i < count; i++){
    ....
    if((i + 2 >= count) ||
        !(types[i + 1] & PathPointTypeBezier) ||
        !(types[i + 1] & PathPointTypeBezier)){
      ....
    }
    i += 2;
  }
}

Asterisk

V501 There are identical sub-expressions 'strcasecmp(item->u1.str, "endwhile") == 0' to the left and to the right of the '||' operator. pval.c 2513


void check_pval_item(pval *item, ....)
{
  ....
  if (strcasecmp(item->u1.str,"GotoIf") == 0
      || strcasecmp(item->u1.str,"GotoIfTime") == 0
      || strcasecmp(item->u1.str,"while") == 0
      || strcasecmp(item->u1.str,"endwhile") == 0           // <=
      || strcasecmp(item->u1.str,"random") == 0
      || strcasecmp(item->u1.str,"gosub") == 0
      || strcasecmp(item->u1.str,"gosubif") == 0
      || strcasecmp(item->u1.str,"continuewhile") == 0
      || strcasecmp(item->u1.str,"endwhile") == 0           // <=
      || strcasecmp(item->u1.str,"execif") == 0
      || ....)
  {....}
}

PHP:Hypertext Preprocessor

V501 There are identical sub-expressions '!memcmp("auto", charset_hint, 4)' to the left and to the right of the '||' operator. html.c 396


static enum
entity_charset determine_charset(char *charset_hint TSRMLS_DC)
{
  ....
  if ((len == 4) /* sizeof (none|auto|pass) */ && // <=
    (!memcmp("pass", charset_hint, 4) ||
     !memcmp("auto", charset_hint, 4) ||          // <=
     !memcmp("auto", charset_hint, 4)))           // <=
  {
       charset_hint = NULL;
      len = 0;
  }
  ....
}

Oracle VM Virtual Box

V501 There are identical sub-expressions 'pState->fIgnoreTrailingWhite' to the left and to the right of the '||' operator. scmdiff.cpp 238


typedef struct SCMDIFFSTATE
{
  ....
  bool  fIgnoreTrailingWhite;
  bool  fIgnoreLeadingWhite;
  ....
} SCMDIFFSTATE;
/* Pointer to a diff state. */

typedef SCMDIFFSTATE *PSCMDIFFSTATE;

/* Compare two lines */
DECLINLINE(bool) scmDiffCompare(PSCMDIFFSTATE pState, ....)
{
  ....
  if (pState->fIgnoreTrailingWhite
   || pState->fIgnoreTrailingWhite)
    return scmDiffCompareSlow(....);
  ....
}

Oracle VM Virtual Box

V501 There are identical sub-expressions '!field("username").toString().isEmpty()' to the left and to the right of the '||' operator. uiwizardexportapp.cpp 177


QString UIWizardExportApp::uri(bool fWithFile) const
{
  ....
  case SunCloud:
  {
    ....
    QString uri("SunCloud://");
    ....
    if (!field("username").toString().isEmpty() ||  // <=
        !field("username").toString().isEmpty())    // <=
      uri = QString("%1@").arg(uri);
    ....
  }
  case S3:
  {
    QString uri("S3://");
    ....
    if (!field("username").toString().isEmpty() ||
        !field("password").toString().isEmpty())
      uri = QString("%1@").arg(uri);
    ....
  }
  ....
}

K Desktop Environment

V501 There are identical sub-expressions 'mimeData->hasFormat(QLatin1String("application/x-kde-ark-dndextract-service"))' to the left and to the right of the '&&' operator. iconview.cpp 2357


void IconView::dropEvent(QGraphicsSceneDragDropEvent *event)
{
  ....
  if (mimeData->hasFormat(QLatin1String(
       "application/x-kde-ark-dndextract-service")) &&      // <=
      mimeData->hasFormat(QLatin1String(
       "application/x-kde-ark-dndextract-service")))        // <=
  {
    const QString remoteDBusClient = mimeData->data(
      QLatin1String("application/x-kde-ark-dndextract-service"));
    const QString remoteDBusPath = mimeData->data(
      QLatin1String("application/x-kde-ark-dndextract-path"));
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'file == rhs.file' to the left and to the right of the '&&' operator. pp-macro.cpp 44
  • V501 There are identical sub-expressions 'tokenKind == Token_not_eq' to the left and to the right of the '||' operator. builtinoperators.cpp 174
  • V501 There are identical sub-expressions '!context->owner()' to the left and to the right of the '||' operator. typeutils.cpp 194

Miranda NG

V501 There are identical sub-expressions 'job->hContact' to the left and to the right of the '&&' operator. TabSRMM hotkeyhandler.cpp 523


LONG_PTR CALLBACK HotkeyHandlerDlgProc(....)
{
  ....
  if (job->hContact && job->iAcksNeeded &&
      job->hContact && job->iStatus == SendQueue::SQ_INPROGRESS)
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'in == '*'' to the left and to the right of the '||' operator. EkHtml ekhtml_mktables.c 67
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: rv && forceucase && (rv) SpellChecker affixmgr.cxx 1784
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: rv && forceucase && (rv) SpellChecker affixmgr.cxx 1879
  • And 1 additional diagnostic messages.

Miranda NG

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: dbv.ptszVal != 0 && dbv.ptszVal != '\0' SimpleStatusMsg msgbox.cpp 247


HWND WINAPI CreateRecentComboBoxEx(....)
{
  ....
  if (dbv.ptszVal != NULL && dbv.ptszVal != '\0') {
  ....
}

Spring Engine

V501 There are identical sub-expressions to the left and to the right of the '||' operator: 0 == pArchive || 0 == pArchive assimp q3bspfileimporter.cpp 631


bool Q3BSPFileImporter::importTextureFromArchive(
  const Q3BSP::Q3BSPModel *pModel,
  Q3BSP::Q3BSPZipArchive *pArchive, aiScene* /*pScene*/,
  aiMaterial *pMatHelper, int textureId )
{
  ....
  if( NULL == pArchive || NULL == pArchive || NULL == pMatHelper)
  {
    return false;
  }

  if ( textureId < 0 ||
    textureId >= static_cast<int>( pModel->m_Textures.size() ) )
  {
    return false;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'aha->mNumWeights != oha->mNumWeights' to the left and to the right of the '||' operator. assimp findinstancesprocess.cpp 87

LibreOffice

V501 There are identical sub-expressions to the left and to the right of the '==' operator: getColor() == getColor() svggradientprimitive2d.hxx 61


class SvgGradientEntry
{
  ....
  bool operator==(const SvgGradientEntry& rCompare) const
  {
    return (getOffset() == rCompare.getOffset()
           && getColor() == getColor()
           && getOpacity() == getOpacity());
  }
  ....
}

LibreOffice

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: iContainerEnd != iContainerEnd theme.cxx 439


void SAL_CALL Theme::disposing (void)
{
  ChangeListeners aListeners;
  maChangeListeners.swap(aListeners);

  const lang::EventObject aEvent (static_cast<XWeak*>(this));

  for (ChangeListeners::const_iterator
           iContainer(maChangeListeners.begin()),
           iContainerEnd(maChangeListeners.end());
       iContainerEnd!=iContainerEnd;
       ++iContainerEnd)
  {
    ....
  }
}

.NET CoreCLR

V501 There are identical sub-expressions 'tree->gtOper == GT_CLS_VAR' to the left and to the right of the '||' operator. ClrJit lsra.cpp 3140


// register variable
GTNODE(GT_REG_VAR      , "regVar"  ,0,GTK_LEAF|GTK_LOCAL)
// static data member
GTNODE(GT_CLS_VAR      , "clsVar"  ,0,GTK_LEAF)
// static data member address
GTNODE(GT_CLS_VAR_ADDR , "&clsVar" ,0,GTK_LEAF)
....

void  LinearScan::buildRefPositionsForNode(GenTree *tree, ....)
{
  ....
  if ((tree->gtOper == GT_CLS_VAR ||
       tree->gtOper == GT_CLS_VAR) && i == 1)
  {
      registerType = TYP_PTR;
      currCandidates = allRegs(TYP_PTR);
  }
  ....
}

.NET CoreCLR

V501 There are identical sub-expressions 'DECODE_PSP_SYM' to the left and to the right of the '|' operator. daccess 264


enum GcInfoDecoderFlags
{
    DECODE_SECURITY_OBJECT       = 0x01,
    DECODE_CODE_LENGTH           = 0x02,
    DECODE_VARARG                = 0x04,
    DECODE_INTERRUPTIBILITY      = 0x08,
    DECODE_GC_LIFETIMES          = 0x10,
    DECODE_NO_VALIDATION         = 0x20,
    DECODE_PSP_SYM               = 0x40,
    DECODE_GENERICS_INST_CONTEXT = 0x80,
    DECODE_GS_COOKIE             = 0x100,
    DECODE_FOR_RANGES_CALLBACK   = 0x200,
    DECODE_PROLOG_LENGTH         = 0x400,
    DECODE_EDIT_AND_CONTINUE     = 0x800,
};

size_t GCDump::DumpGCTable(PTR_CBYTE table, ....)
{
  GcInfoDecoder hdrdecoder(table,
   (GcInfoDecoderFlags)(  DECODE_SECURITY_OBJECT
                        | DECODE_GS_COOKIE
                        | DECODE_CODE_LENGTH
                        | DECODE_PSP_SYM
                        | DECODE_VARARG
                        | DECODE_PSP_SYM                // <= 1
                        | DECODE_GENERICS_INST_CONTEXT
                        | DECODE_GC_LIFETIMES
                        | DECODE_GENERICS_INST_CONTEXT  // <= 2
                        | DECODE_PROLOG_LENGTH),
   0);
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'varLoc1.vlStk2.vls2BaseReg' to the left and to the right of the '==' operator. cee_wks util.cpp 657
  • V501 There are identical sub-expressions 'varLoc1.vlStk2.vls2Offset' to the left and to the right of the '==' operator. cee_wks util.cpp 658
  • V501 There are identical sub-expressions 'varLoc1.vlFPstk.vlfReg' to the left and to the right of the '==' operator. cee_wks util.cpp 661

Haiku Operation System

V501 There are identical sub-expressions to the left and to the right of the '<' operator: lJack->m_jackType < lJack->m_jackType MediaJack.cpp 783


int __CORTEX_NAMESPACE__ compareTypeAndID(....)
{
  int retValue = 0;
  ....
  if (lJack && rJack)
  {
    if (lJack->m_jackType < lJack->m_jackType)           // <=
    {
      return -1;
    }
    if (lJack->m_jackType == lJack->m_jackType)          // <=
    {
      if (lJack->m_index < rJack->m_index)
      {
        return -1;
      }
      else
      {
        return 1;
      }
    }
    else if (lJack->m_jackType > rJack->m_jackType)
    {
      retValue = 1;
    }
  }
  return retValue;
}

Godot Engine

V501 There are identical sub-expressions 'type' to the left and to the right of the '&&' operator. s3_pkt.c 971


int ssl3_read_bytes(....)
{
  ....
  if ((type && (type != SSL3_RT_APPLICATION_DATA)
       && (type != SSL3_RT_HANDSHAKE) && type)
    || (peek && (type != SSL3_RT_APPLICATION_DATA)))
  {
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'type' to the left and to the right of the '&&' operator. d1_pkt.c 761
  • V501 There are identical sub-expressions 'rs >= 4' to the left and to the right of the '&&' operator. http_client.cpp 290

Godot Engine

V501 There are identical sub-expressions 'section == "float_array"' to the left and to the right of the '||' operator. collada.cpp 982


void Collada::_parse_curve_geometry(....)
{
  ....
  String section  = parser.get_node_name();
  ....
  if (section == "source")
  {
     ....
  } else if (section=="float_array" || section=="array" ||
             section=="float_array")
   {
     ....
   }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'section == "float_array"' to the left and to the right of the '||' operator. collada.cpp 1079

Godot Engine

V501 There are identical sub-expressions 'k.mod.command' to the left and to the right of the '||' operator. text_edit.cpp 1565


void TextEdit::_input_event(const InputEvent& p_input_event)
{
  ....
  if (k.mod.command || k.mod.shift || k.mod.alt || k.mod.command)
    break;
  ....
}

Godot Engine

V501 There are identical sub-expressions '(c == ' ')' to the left and to the right of the '||' operator. a_print.c 76


int ASN1_PRINTABLE_type(const unsigned char *s, int len)
{
  int c;
  ....
  if (!( ((c >= 'a') && (c <= 'z')) ||
    ((c >= 'A') && (c <= 'Z')) ||
    (c == ' ') ||
    ((c >= '0') && (c <= '9')) ||
    (c == ' ') || (c == '\'') ||
    (c == '(') || (c == ')') ||
    (c == '+') || (c == ',') ||
    (c == '-') || (c == '.') ||
    (c == '/') || (c == ':') ||
    (c == '=') || (c == '?')))
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'WindowsMinorVersion' to the left and to the right of the '>=' operator. windowstextinputmethodsystem.cpp 371


bool FWindowsTextInputMethodSystem::InitializeTSF()
{
  ....
  const DWORD WindowsMajorVersion=LOBYTE(LOWORD(WindowsVersion));
  const DWORD WindowsMinorVersion=HIBYTE(LOWORD(WindowsVersion));

  static const DWORD WindowsVistaMajorVersion = 6;
  static const DWORD WindowsVistaMinorVersion = 0;

  if(WindowsMajorVersion > WindowsVistaMajorVersion ||
    (WindowsMajorVersion == WindowsVistaMajorVersion &&
     WindowsMinorVersion >= WindowsMinorVersion))
  {
    ....
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'LevelStreaming->LoadedLevel' to the left and to the right of the '&&' operator. editor.cpp 2030


void UEditorEngine::CloseEditedWorldAssets(UWorld* InWorld)
{
  ....
  if (LevelStreaming &&
      LevelStreaming->LoadedLevel &&
      LevelStreaming->LoadedLevel)
  {
    ClosingWorlds.Add(CastChecked<UWorld>(....));
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'DestCoordType == TRANSFORM_Tangent' to the left and to the right of the '||' operator. hlslmaterialtranslator.h 3109


UENUM()
enum EMaterialVectorCoordTransform
{
  TRANSFORM_World UMETA(DisplayName="World"),
  TRANSFORM_View UMETA(DisplayName="View"),
  TRANSFORM_Local UMETA(DisplayName="Local"),
  TRANSFORM_Tangent UMETA(DisplayName="Tangent"),
  TRANSFORM_MAX,
};

virtual int32 TransformVector(uint8 SourceCoordType,uint8
                              DestCoordType,int32 A) override
{
  ....
  if( (Domain != MD_Surface && Domain != MD_DeferredDecal) &&
      (SourceCoordinateSpace == TRANSFORMSOURCE_Tangent ||
       SourceCoordinateSpace == TRANSFORMSOURCE_Local ||
       DestCoordType == TRANSFORM_Tangent ||
       DestCoordType == TRANSFORM_Tangent) )
  {
    ....
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'Texture2D->LODGroup == TEXTUREGROUP_WorldNormalMap' to the left and to the right of the '||' operator. meshpaintedmode.cpp 4465


void FEdModeMeshPaint::UpdateTexturePaintTargetList()
{
  ....
  if( Texture2D->IsNormalMap() == true
    || Texture2D->LODGroup == TEXTUREGROUP_WorldNormalMap
    || Texture2D->LODGroup == TEXTUREGROUP_CharacterNormalMap
    || Texture2D->LODGroup == TEXTUREGROUP_WeaponNormalMap
    || Texture2D->LODGroup == TEXTUREGROUP_VehicleNormalMap
    || Texture2D->LODGroup == TEXTUREGROUP_WorldNormalMap   // <=
    || Texture2DName.Contains( TEXT("_N0" ))
    || Texture2DName.Contains( TEXT("_N_" ))
    || Texture2DName.Contains( TEXT("_NORMAL" ))
    || (Texture2DName.Right(2)).Contains( TEXT("_N" )) )
  {
    continue;
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurrentTool != 0 && CurrentTool != 0 landscapeedmode.cpp 824


EEditAction::Type FEdModeLandscape::GetActionEditDuplicate()
{
  EEditAction::Type Result = EEditAction::Skip;

  if (NewLandscapePreviewMode == ENewLandscapePreviewMode::None)
  {
    if (CurrentTool != NULL && CurrentTool != NULL)
    {
      Result = CurrentTool->GetActionEditDuplicate();
    }
  }

  return Result;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurrentTool != 0 && CurrentTool != 0 landscapeedmode.cpp 839
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurrentTool != 0 && CurrentTool != 0 landscapeedmode.cpp 874
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurrentTool != 0 && CurrentTool != 0 landscapeedmode.cpp 896
  • And 6 additional diagnostic messages.

Unreal Engine 4

V501 There are identical sub-expressions to the left and to the right of the '||' operator: !bc.lclusters ||!bc.lclusters detourtilecache.cpp 687


dtStatus dtTileCache::buildNavMeshTile(....)
{
  ....
  bc.lcset = dtAllocTileCacheContourSet(m_talloc);
  bc.lclusters = dtAllocTileCacheClusterSet(m_talloc);
  if (!bc.lclusters || !bc.lclusters)
    return status;
  status = dtBuildTileCacheContours(....);
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'MaxResaveUnrealEngine4Version == INDEX_NONE' to the left and to the right of the '&&' operator. contentcommandlets.cpp 614


bool UResavePackagesCommandlet::PerformPreloadOperations(....)
{
  ....
  bool bNoLimitation =
    MaxResaveUnrealEngine4Version == IGNORE_PACKAGE_VERSION &&
    MaxResaveUnrealEngine4Version == IGNORE_PACKAGE_VERSION &&
    MaxResaveLicenseeUnrealEngine4Version ==
      IGNORE_PACKAGE_VERSION;
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: CurrentTool != 0 && CurrentTool != 0 landscapeedmode.cpp 1013


bool FEdModeLandscape::ProcessEditCopy()
{
  ....
  if (CurrentTool != NULL && CurrentTool != NULL)
  {
    Result = CurrentTool->ProcessEditCopy();
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions '(CommitInfo == ETextCommit::OnUserMovedFocus)' to the left and to the right of the '||' operator. physicssettingsdetails.cpp 85


UENUM(BlueprintType)
namespace ETextCommit
{
  enum Type
  {
    Default,
    OnEnter,
    OnUserMovedFocus,
    OnCleared
  };
}

void SPhysicalSurfaceListItem::NewNameEntered(....)
{
  ....
  if((CommitInfo == ETextCommit::OnEnter) ||
     (CommitInfo == ETextCommit::OnUserMovedFocus) ||
     (CommitInfo == ETextCommit::OnUserMovedFocus))
  {
    ....
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions '!FOpenGL::SupportsTextureView()' to the left and to the right of the '&&' operator. opengltexture.cpp 881


template<typename RHIResourceType>
void TOpenGLTexture<RHIResourceType>::Unlock(uint32 MipIndex,
                                             uint32 ArrayIndex)
{
  ....
  bool const bUseClientStorage =
    FOpenGL::SupportsClientStorage() &&
    !FOpenGL::SupportsTextureView() &&
    !FOpenGL::SupportsTextureView() &&
    !bRenderable && !this->GetSizeZ() &&
    !GLFormat.bCompressed;
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions to the left and to the right of the '||' operator: ArraySlice == - 1 || ArraySlice == - 1 d3d11rhi.cpp 171


void FD3D11DynamicRHI::CheckIfSRVIsResolved(....)
{
  ....
  ensureMsgf((ArraySlice == -1 || ArraySlice == -1) ||
    (LastSlice < RTInfo.ArraySlice || ArraySlice > RTLastSlice),
    TEXT("...."), ArraySlice, LastSlice,
    *RTInfo.ResourceName.ToString(), RTInfo.ArraySlice);
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'Track->IsA(UInterpTrackVectorBase::StaticClass())' to the left and to the right of the '||' operator. matineedraw.cpp 1438


void
FMatineeViewportClient::CreatePushPropertiesOntoGraphButton(....)
{
  ....
  if(
    Track->IsA(UInterpTrackFloatBase::StaticClass()) ||
    Track->IsA(UInterpTrackVectorBase::StaticClass()) ||
    Track->IsA(UInterpTrackMove::StaticClass()) ||
    Track->IsA(UInterpTrackLinearColorBase::StaticClass()) ||
    Track->IsA(UInterpTrackVectorBase::StaticClass())
    )
  {
    ....
  }
  ....
}

Unreal Engine 4

V501 There are identical sub-expressions 'MaxResaveUE4Version == INDEX_NONE' to the left and to the right of the '&&' operator. contentcommandlets.cpp 614


bool UResavePackagesCommandlet::PerformPreloadOperations(....)
{
  ....
  // Check if this package meets the maximum requirements.
  bool bNoLimitation =
    MaxResaveUE4Version == IGNORE_PACKAGE_VERSION &&
    MaxResaveUE4Version == IGNORE_PACKAGE_VERSION &&
    MaxResaveLicenseeUE4Version == IGNORE_PACKAGE_VERSION;
  ....
}

FreeCAD

V501 There are identical sub-expressions 'surfaceTwo->IsVRational()' to the left and to the right of the '!=' operator. modelrefine.cpp 780


bool FaceTypedBSpline::isEqual(const TopoDS_Face &faceOne,
                               const TopoDS_Face &faceTwo) const
{
  ....
  if (surfaceOne->IsURational() !=
      surfaceTwo->IsURational())
    return false;
  if (surfaceTwo->IsVRational() !=
      surfaceTwo->IsVRational())       // <=
    return false;
  if (surfaceOne->IsUPeriodic() !=
      surfaceTwo->IsUPeriodic())
    return false;
  if (surfaceOne->IsVPeriodic() !=
      surfaceTwo->IsVPeriodic())
    return false;
  if (surfaceOne->IsUClosed() !=
      surfaceTwo->IsUClosed())
    return false;
  if (surfaceOne->IsVClosed() !=
      surfaceTwo->IsVClosed())
    return false;
  if (surfaceOne->UDegree() !=
      surfaceTwo->UDegree())
    return false;
  if (surfaceOne->VDegree() !=
      surfaceTwo->VDegree())
    return false;
  ....
}

Mozilla Thunderbird

V501 There are identical sub-expressions 'aStatus == NS_ERROR_OFFLINE' to the left and to the right of the '||' operator. nsdocshell.cpp 7606


nsresult
nsDocShell::EndPageLoad(nsresult aStatus, ....)
{
  if(....)
  {
    ....
  }
  else if (aStatus == NS_ERROR_NET_TIMEOUT ||
           ....
           aStatus == NS_ERROR_OFFLINE ||
           aStatus == NS_ERROR_MALWARE_URI ||
           aStatus == NS_ERROR_PHISHING_URI ||
           aStatus == NS_ERROR_UNWANTED_URI ||
           aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
           aStatus == NS_ERROR_REMOTE_XUL ||
           aStatus == NS_ERROR_OFFLINE ||
           ....)
}

Unreal Engine 4

V501 There are identical sub-expressions 'GlyphIndex == Other.GlyphIndex' to the left and to the right of the '&&' operator. fontcache.h 139


FORCEINLINE
bool operator==(const FShapedGlyphEntryKey& Other) const
{
  return FontFace == Other.FontFace
    && GlyphIndex == Other.GlyphIndex
    && FontSize == Other.FontSize
    && FontScale == Other.FontScale
    && GlyphIndex == Other.GlyphIndex;
}

Unreal Engine 4

V501 There are identical sub-expressions to the left and to the right of the '==' operator: AutoWritable == AutoWritable rendererinterface.h 180


bool
Compare(const FPooledRenderTargetDesc& rhs, bool bExact) const
{
  ....
  return Extent == rhs.Extent
    && Depth == rhs.Depth
    && bIsArray == rhs.bIsArray
    && ArraySize == rhs.ArraySize
    && NumMips == rhs.NumMips
    && NumSamples == rhs.NumSamples
    && Format == rhs.Format
    && LhsFlags == RhsFlags
    && TargetableFlags == rhs.TargetableFlags
    && bForceSeparateTargetAndShaderResource ==
         rhs.bForceSeparateTargetAndShaderResource
    && ClearValue == rhs.ClearValue
    && AutoWritable == AutoWritable;   // <=
}

Unreal Engine 4

V501 There are identical sub-expressions to the left and to the right of the '==' operator: bTickDuringGame == bTickDuringGame eqstestingpawn.cpp 157


void AEQSTestingPawn::PostLoad()
{
  ....
  UWorld* World = GetWorld();
  if (World && World->IsGameWorld() &&
      bTickDuringGame == bTickDuringGame)
  {
    PrimaryActorTick.bCanEverTick = false;
  }
}

Unreal Engine 4

V501 There are identical sub-expressions 'RenderTargetResource->GetWidth() != 0' to the left and to the right of the '&&' operator. sretainerwidget.cpp 291


int32 SRetainerWidget::OnPaint(....) const
{
  ....
  if ( RenderTargetResource->GetWidth() != 0 &&
       RenderTargetResource->GetWidth() != 0 )
  ....
}

ChakraCore

V501 There are identical sub-expressions 'this->propId == Js::PropertyIds::_superReferenceSymbol' to the left and to the right of the '||' operator. diagobjectmodel.cpp 123


IDiagObjectModelDisplay * ResolvedObject::CreateDisplay()
{
 ....
  if (this->isConst ||
    this->propId == Js::PropertyIds::_superReferenceSymbol ||
    this->propId == Js::PropertyIds::_superReferenceSymbol)
  {
      pOMDisplay->SetDefaultTypeAttribute(....);
  }
  ....
}

ChakraCore

V501 There are identical sub-expressions 'GetVarSymID(srcIndexOpnd->GetStackSym())' to the left and to the right of the '==' operator. globopt.cpp 20795


void GlobOpt::EmitMemop(....)
{
  ....
  IR::RegOpnd *srcBaseOpnd = nullptr;
  IR::RegOpnd *srcIndexOpnd = nullptr;
  IRType srcType;
  GetMemOpSrcInfo(...., srcBaseOpnd, srcIndexOpnd, srcType);
  Assert(GetVarSymID(srcIndexOpnd->GetStackSym()) ==
         GetVarSymID(srcIndexOpnd->GetStackSym()));
  ....
}

Computational Network Toolkit

V501 There are identical sub-expressions '!Input(0)->HasMBLayout()' to the left and to the right of the '||' operator. trainingnodes.h 1416


virtual void Validate(bool isFinalValidationPass) override
{
  ....
  if (isFinalValidationPass &&
      !(Input(0)->GetSampleMatrixNumRows() ==
        Input(2)->GetSampleMatrixNumRows() &&
       (Input(0)->GetMBLayout() ==
        Input(2)->GetMBLayout() ||
       !Input(0)->HasMBLayout() ||
       !Input(0)->HasMBLayout())))
  {
    LogicError(..., NodeName().c_str(),OperationName().c_str());
  }
   ....
}

Computational Network Toolkit

V501 There are identical sub-expressions to the left and to the right of the '-' operator: i0 - i0 ssematrix.h 564


void assignpatch(const ssematrixbase &patch,
                 const size_t i0,
                 const size_t i1,
                 const size_t j0,
                 const size_t j1)
{
  ....
  for (size_t j = j0; j < j1; j++)
  {
    const float *pcol = &patch(i0 - i0, j - j0);
    float *qcol = &us(i0, j);
    const size_t colbytes = (i1 - i0) * sizeof(*pcol);
    memcpy(qcol, pcol, colbytes);
  }
  ....
}

FreeBSD Kernel

V501 There are identical sub-expressions '(uintptr_t) b->handler' to the left and to the right of the '>' operator. ip_fw_sockopt.c 2893


static int
compare_sh(const void *_a, const void *_b)
{
  const struct ipfw_sopt_handler *a, *b;

  a = (const struct ipfw_sopt_handler *)_a;
  b = (const struct ipfw_sopt_handler *)_b;
  ....
  if ((uintptr_t)a->handler < (uintptr_t)b->handler)
    return (-1);
  else if ((uintptr_t)b->handler > (uintptr_t)b->handler)
    return (1);

  return (0);
}

FreeBSD Kernel

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: m->m_pkthdr.len != m->m_pkthdr.len key.c 7208


int
key_parse(struct mbuf *m, struct socket *so)
{
  ....
  if ((m->m_flags & M_PKTHDR) == 0 ||
      m->m_pkthdr.len != m->m_pkthdr.len) {
    ....
    goto senderror;
  }
  ....
}

FreeBSD Kernel

V501 There are identical sub-expressions to the left and to the right of the '|' operator: PIM_NOBUSRESET | PIM_NOBUSRESET sbp_targ.c 1327


typedef enum {
  PIM_EXTLUNS      = 0x100,
  PIM_SCANHILO     = 0x80,
  PIM_NOREMOVE     = 0x40,
  PIM_NOINITIATOR  = 0x20,
  PIM_NOBUSRESET   = 0x10, // <=
  PIM_NO_6_BYTE    = 0x08,
  PIM_SEQSCAN      = 0x04,
  PIM_UNMAPPED     = 0x02,
  PIM_NOSCAN       = 0x01
} pi_miscflag;

static void
sbp_targ_action1(struct cam_sim *sim, union ccb *ccb)
{
  ....
  struct ccb_pathinq *cpi = &ccb->cpi;

    cpi->version_num = 1; /* XXX??? */
    cpi->hba_inquiry = PI_TAG_ABLE;
    cpi->target_sprt = PIT_PROCESSOR
         | PIT_DISCONNECT
         | PIT_TERM_IO;
    cpi->transport = XPORT_SPI;
    cpi->hba_misc = PIM_NOBUSRESET | PIM_NOBUSRESET; // <=
  ....
}

Oracle VM Virtual Box

V501 There are identical sub-expressions 'mstrFormat.equalsIgnoreCase("text/plain")' to the left and to the right of the '||' operator. vboxdnddataobject.cpp 38


STDMETHODIMP VBoxDnDDataObject::GetData(....)
{
  ....
  else if(
         mstrFormat.equalsIgnoreCase("text/plain")
      || mstrFormat.equalsIgnoreCase("text/html")
      || mstrFormat.equalsIgnoreCase("text/plain;charset=utf-8")
      || mstrFormat.equalsIgnoreCase("text/plain;charset=utf-16")
      || mstrFormat.equalsIgnoreCase("text/plain")  // <=
      || mstrFormat.equalsIgnoreCase("text/richtext")
      || mstrFormat.equalsIgnoreCase("UTF8_STRING")
      || mstrFormat.equalsIgnoreCase("TEXT")
      || mstrFormat.equalsIgnoreCase("STRING"))
  {
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '!RTStrICmp(pszFormat, "text/plain")' to the left and to the right of the '||' operator. vboxdnd.cpp 834

The GTK+ Project

V501 There are identical sub-expressions '(box->corner[GTK_CSS_TOP_RIGHT].horizontal)' to the left and to the right of the '>' operator. gtkcssshadowvalue.c 685


static void
draw_shadow_corner (....
                    GtkRoundedBox       *box,
                                         ....)
{
  ....
  overlapped = FALSE;
  if (corner == GTK_CSS_TOP_LEFT ||
      corner == GTK_CSS_BOTTOM_LEFT)
    {
      ....
      max_other = MAX(box->corner[GTK_CSS_TOP_RIGHT].horizontal,
                      box->corner[GTK_CSS_TOP_RIGHT].horizontal);
      ....
    }
  else
    {
      ....
      max_other = MAX(box->corner[GTK_CSS_TOP_LEFT].horizontal
                      box->corner[GTK_CSS_TOP_LEFT].horizontal);
      ....
    }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '(box->corner[GTK_CSS_TOP_LEFT].horizontal)' to the left and to the right of the '>' operator. gtkcssshadowvalue.c 696

The GTK+ Project

V501 There are identical sub-expressions 'G_PARAM_EXPLICIT_NOTIFY' to the left and to the right of the '|' operator. gtkcalendar.c 400


static void
gtk_calendar_class_init (GtkCalendarClass *class)
{
  ....
  g_object_class_install_property (gobject_class,
    PROP_YEAR,
    g_param_spec_int ("year",
      P_("Year"),
      P_("The selected year"),
      0, G_MAXINT >> 9, 0,
      GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY|
                          G_PARAM_EXPLICIT_NOTIFY));
  ....
}

The GTK+ Project

V501 There are identical sub-expressions 'G_PARAM_DEPRECATED' to the left and to the right of the '|' operator. gtkmenubar.c 275


static void
gtk_menu_bar_class_init (GtkMenuBarClass *class)
{
  ....
  gtk_widget_class_install_style_property (widget_class,
    g_param_spec_int ("internal-padding",
      P_("Internal padding"),
      P_("Amount of border space between ...."),
      0, G_MAXINT, 0,
      GTK_PARAM_READABLE |
      G_PARAM_DEPRECATED|G_PARAM_DEPRECATED));
  ....
}

Serious Engine 1 v.1.10

V501 There are identical sub-expressions to the left and to the right of the '==' operator: tp_iAnisotropy == tp_iAnisotropy gfx_wrapper.h 180


class CTexParams {
public:

  inline BOOL IsEqual( CTexParams tp) {
    return tp_iFilter     == tp.tp_iFilter &&
           tp_iAnisotropy == tp_iAnisotropy &&
           tp_eWrapU      == tp.tp_eWrapU &&
           tp_eWrapV      == tp.tp_eWrapV; };
  ....
};

Serious Engine 1 v.1.10

V501 There are identical sub-expressions 'GetShadingMapWidth() < 32' to the left and to the right of the '||' operator. terrain.cpp 561


void CTerrain::SetShadowMapsSize(....)
{
  ....
  if(GetShadowMapWidth()<32 || GetShadingMapHeight()<32) {
    ....
  }

  if(GetShadingMapWidth()<32 || GetShadingMapWidth()<32) {
    tr_iShadingMapSizeAspect = 0;
  }
  ....
  PIX pixShadingMapWidth  = GetShadingMapWidth();
  PIX pixShadingMapHeight = GetShadingMapHeight();
  ....
}

Serious Engine 1 v.1.10

V501 There are identical sub-expressions '(vfp_ptPrimitiveType == vfpToCompare.vfp_ptPrimitiveType)' to the left and to the right of the '&&' operator. worldeditor.h 580


inline BOOL CValuesForPrimitive::operator==(....)
{
  return (
 (....) &&
 (vfp_ptPrimitiveType == vfpToCompare.vfp_ptPrimitiveType) &&
 ....
 (vfp_ptPrimitiveType == vfpToCompare.vfp_ptPrimitiveType) &&
 ....
);

OpenToonz

V501 There are identical sub-expressions to the left and to the right of the '||' operator: m_cutLx || m_cutLx canvassizepopup.cpp 271


bool m_cutLx, m_cutLy;

void PeggingWidget::on00()
{
 ....
 m_11->setIcon(...).rotate(m_cutLx || m_cutLx ? -90 : 90),....));
 ....
}

OpenToonz

V501 There are identical sub-expressions 'parentTask->m_status == Aborted' to the left and to the right of the '||' operator. tfarmcontroller.cpp 1857


void FarmController::taskSubmissionError(....)
{
  ....
  if (parentTask->m_status == Aborted ||
      parentTask->m_status == Aborted) {
      parentTask->m_completionDate = task->m_completionDate;
      if (parentTask->m_toBeDeleted)
        m_tasks.erase(itParent);
  }
  ....
}

OpenToonz

V501 There are identical sub-expressions 'cornerCoords.y > upperBound' to the left and to the right of the '||' operator. tellipticbrush.cpp 1020


template <typename T>
void tellipticbrush::OutlineBuilder::addMiterSideCaps(....)
{
  ....
  if (cornerCoords == TConsts::napd ||
    cornerCoords.x < lowerBound || cornerCoords.y > upperBound ||
    cornerCoords.y < lowerBound || cornerCoords.y > upperBound) {
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 's.m_repoStatus == "modified"' to the left and to the right of the '||' operator. svnupdatedialog.cpp 210
  • V501 There are identical sub-expressions 'm_lineEdit->hasFocus()' to the left and to the right of the '||' operator. framenavigator.cpp 44

ReactOS

V501 There are identical sub-expressions 'uFlags == 0x00000002' to the left and to the right of the '||' operator. cdefaultcontextmenu.cpp 1793


#define GCS_HELPTEXTA    0x00000001
#define GCS_VALIDATEA    0x00000002
#define GCS_HELPTEXTW    0x00000005
#define GCS_VALIDATEW    0x00000006

HRESULT WINAPI CDefaultContextMenu::GetCommandString(....)
{
  if (uFlags == GCS_HELPTEXTA || uFlags == GCS_HELPTEXTW)
  {
    ....
  }
  ....
  if (uFlags == GCS_VALIDATEA || uFlags == GCS_VALIDATEA)
      return S_OK;
  ....
}

Firebird

V501 There are identical sub-expressions 'c != '_'' to the left and to the right of the '&&' operator. reader.c 1203


void advance_to_start()
{
  ....
  if (!isalpha(c) && c != '_' && c != '.' && c != '_')
    syntax_error(lineno, line, cptr);
  ....
}

7-Zip

V501 There are identical sub-expressions 'Id == k_PPC' to the left and to the right of the '||' operator. 7zupdate.cpp 41


void SetDelta()
{
  if (Id == k_IA64)
    Delta = 16;
  else if (Id == k_ARM || Id == k_PPC || Id == k_PPC)
    Delta = 4;
  else if (Id == k_ARMT)
    Delta = 2;
  else
    Delta = 0;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: offs >= nodeSize || offs >= nodeSize hfshandler.cpp 915

Open X-Ray Engine

V501 There are identical sub-expressions '(mstate_rl & mcLanding)' to the left and to the right of the '||' operator. actoranimation.cpp 290


void CActor::g_SetSprintAnimation(u32 mstate_rl,
                                  MotionID &head,
                                  MotionID &torso,
                                  MotionID &legs)
{
  SActorSprintState& sprint = m_anims->m_sprint;

  bool jump = (mstate_rl&mcFall)     ||
              (mstate_rl&mcLanding)  ||
              (mstate_rl&mcLanding)  ||
              (mstate_rl&mcLanding2) ||
              (mstate_rl&mcJump);
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'HudItemData()' to the left and to the right of the '&&' operator. huditem.cpp 338
  • V501 There are identical sub-expressions 'list_idx == e_outfit' to the left and to the right of the '||' operator. uimptradewnd_misc.cpp 392
  • V501 There are identical sub-expressions '(D3DFMT_UNKNOWN == fTarget)' to the left and to the right of the '||' operator. hw.cpp 312

OpenJDK

V501 There are identical sub-expressions 'arg1 == c_rarg3' to the left and to the right of the '||' operator. c1_Runtime1_x86.cpp 174


int StubAssembler::call_RT(....) {
#ifdef _LP64
  // if there is any conflict use the stack
  if (arg1 == c_rarg2 || arg1 == c_rarg3 ||
      arg2 == c_rarg1 || arg1 == c_rarg3 ||
      arg3 == c_rarg1 || arg1 == c_rarg2) {
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'arg1 == c_rarg2' to the left and to the right of the '||' operator. c1_Runtime1_x86.cpp 174

Nana

V501 There are identical sub-expressions 'fgcolor.invisible()' to the left and to the right of the '&&' operator. text_editor.cpp 1316


void text_editor::set_highlight(const std::string& name,
                                const ::nana::color& fgcolor,
                                const ::nana::color& bgcolor)
{
  if (fgcolor.invisible() && fgcolor.invisible())
  {
    keywords_->schemes.erase(name);
    return;
  }
  ....
}

OpenSSL

V501 There are identical sub-expressions '(c == ' ')' to the left and to the right of the '||' operator. a_print.c 77


int ASN1_PRINTABLE_type(const unsigned char *s, int len)
{
  int c;
  int ia5 = 0;
  ....
  if (!(((c >= 'a') && (c <= 'z')) ||
        ((c >= 'A') && (c <= 'Z')) ||
        (c == ' ') ||
        ((c >= '0') && (c <= '9')) ||
        (c == ' ') || (c == '\'') ||    // <=
        (c == '(') || (c == ')') ||
        (c == '+') || (c == ',') ||
        (c == '-') || (c == '.') ||
        (c == '/') || (c == ':') ||
        (c == '=') || (c == '?')))
    ia5 = 1;
  ....
}

CryEngine V

V501 There are identical sub-expressions to the left and to the right of the '-' operator: q2.v.z - q2.v.z entitynode.cpp 93


bool
CompareRotation(const Quat& q1, const Quat& q2, float epsilon)
{
  return (fabs_tpl(q1.v.x - q2.v.x) <= epsilon)
      && (fabs_tpl(q1.v.y - q2.v.y) <= epsilon)
      && (fabs_tpl(q2.v.z - q2.v.z) <= epsilon)
      && (fabs_tpl(q1.w - q2.w) <= epsilon);
}

CryEngine V

V501 There are identical sub-expressions '(m_eTFSrc == eTF_BC6UH)' to the left and to the right of the '||' operator. texturestreaming.cpp 919


//! Texture formats.
enum ETEX_Format : uint8
{
  ....
  eTF_BC4U,     //!< 3Dc+.
  eTF_BC4S,
  eTF_BC5U,     //!< 3Dc.
  eTF_BC5S,
  eTF_BC6UH,
  eTF_BC6SH,
  eTF_BC7,
  eTF_R9G9B9E5,
  ....
};

bool CTexture::StreamPrepare(CImageFile* pIM)
{
  ....
  if ((m_eTFSrc == eTF_R9G9B9E5) ||
      (m_eTFSrc == eTF_BC6UH)    ||
      (m_eTFSrc == eTF_BC6UH))       // <=
  {
    m_cMinColor /= m_cMaxColor.a;
    m_cMaxColor /= m_cMaxColor.a;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '(td.m_eTF == eTF_BC6UH)' to the left and to the right of the '||' operator. texture.cpp 1214
  • V501 There are identical sub-expressions 'geom_colltype_solid' to the left and to the right of the '|' operator. attachmentmanager.cpp 1004

Inkscape

V501 There are identical sub-expressions 'Ar.maxExtent() < tol' to the left and to the right of the '&&' operator. path-intersection.cpp 313


void mono_intersect(....)
{
  if(depth > 12 ||
      (Ar.maxExtent() < tol && Ar.maxExtent() < tol))
  {
    ....
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'Ar.maxExtent() < 0.1' to the left and to the right of the '&&' operator. path-intersection.cpp 364

GCC

V501 There are identical sub-expressions '!strcmp(a->v.val_vms_delta.lbl1, b->v.val_vms_delta.lbl1)' to the left and to the right of the '&&' operator. dwarf2out.c 1428


static bool
dw_val_equal_p (dw_val_node *a, dw_val_node *b)
{
  ....
  case dw_val_class_vms_delta:
    return (!strcmp (a->v.val_vms_delta.lbl1,
                     b->v.val_vms_delta.lbl1)
            && !strcmp (a->v.val_vms_delta.lbl1,
                        b->v.val_vms_delta.lbl1));
  ....
}

GCC

V501 There are identical sub-expressions 'entry_ptr->mode == mode' to the left and to the right of the '&&' operator. expmed.c 2573


struct alg_hash_entry {
  unsigned HOST_WIDE_INT t;
  machine_mode mode;
  enum alg_code alg;
  struct mult_cost cost;
  bool speed;
};

static void synth_mult (....)
{
  ....
  struct alg_hash_entry *entry_ptr;
  ....
  if (entry_ptr->t == t
      && entry_ptr->mode == mode
      && entry_ptr->mode == mode
      && entry_ptr->speed == speed
      && entry_ptr->alg != alg_unknown)
  {
  ....
}

Blender

V501 There are identical sub-expressions to the left and to the right of the '-' operator: iA->getPoint2D() - iA->getPoint2D() curve.cpp 136


CurvePoint::CurvePoint(CurvePoint *iA, CurvePoint *iB, float t3)
{
  ....
  if ((iA->getPoint2D() -
       iA->getPoint2D()).norm() < 1.0e-6) {
    ....
  }
  ....
}

Blender

V501 There are identical sub-expressions to the left and right of the '!=' operator: m_cols != m_cols jacobisvd.h 819


template<typename MatrixType, int QRPreconditioner>
void JacobiSVD<MatrixType, QRPreconditioner>::allocate(....)
{
  ....
  if(m_cols>m_rows)m_qr_precond_morecols.allocate(*this);
  if(m_rows>m_cols)m_qr_precond_morerows.allocate(*this);
  if(m_cols!=m_cols)m_scaledMatrix.resize(rows,cols);
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '==' operator: left.rows() == left.rows() numeric.cc 112
  • V501 There are identical sub-expressions to the left and to the right of the '>' operator: (from[0][3]) > (from[0][3]) stereoimbuf.c 120
  • V501 There are identical sub-expressions to the left and to the right of the '>' operator: (from[0][3]) > (from[0][3]) stereoimbuf.c 157
  • And 1 additional diagnostic messages.

Blender

V501 There are identical sub-expressions 'lh2->v' to the left and right of the '&&' operator. editmesh_knife.c 781


static void knife_add_single_cut(....)
{
  ....
  if ((lh1->v && lh2->v) &&
     (lh1->v->v && lh2->v && lh2->v->v) &&
     (e_base = BM_edge_exists(lh1->v->v, lh2->v->v)))
     {
       ....
       return;
     }
  ....
}

GNU GRUB

V501 There are identical sub-expressions 'cmdline_state != GRUB_PARSER_STATE_QUOTE' to the left and to the right of the '&&' operator. completion.c 502


typedef enum
{
  GRUB_PARSER_STATE_TEXT = 1,
  GRUB_PARSER_STATE_ESC,
  GRUB_PARSER_STATE_QUOTE,
  GRUB_PARSER_STATE_DQUOTE,
  ....
} grub_parser_state_t;

char * grub_normal_do_completion (....)
{
  ....
  if (*escstr == ' '
      && cmdline_state != GRUB_PARSER_STATE_QUOTE
      && cmdline_state != GRUB_PARSER_STATE_QUOTE)  // <=
        *(newstr++) = '\\';
  ....
}

Chromium

V501 There are identical sub-expressions 'request_body_send_buf_ == nullptr' to the left and to the right of the '&&' operator. http_stream_parser.cc 1222


bool HttpStreamParser::SendRequestBuffersEmpty()
{
  return request_headers_ == nullptr &&
         request_body_send_buf_ == nullptr &&
         request_body_send_buf_ == nullptr;
}

LLVM/Clang

V501 There are identical sub-expressions 'OpcodeLHS == BO_LE' to the left and to the right of the '||' operator. RedundantExpressionCheck.cpp 174


static bool areExclusiveRanges(BinaryOperatorKind OpcodeLHS,
                               const APSInt &ValueLHS,
                               BinaryOperatorKind OpcodeRHS,
                               const APSInt &ValueRHS) {
  ....
  // Handle cases where the constants are different.
  if ((OpcodeLHS == BO_EQ ||
       OpcodeLHS == BO_LE ||
       OpcodeLHS == BO_LE)
      &&
      (OpcodeRHS == BO_EQ ||
       OpcodeRHS == BO_GT ||
       OpcodeRHS == BO_GE))
    return true;
  ....
}

This is a classic typo. The variable OpcodeLHS is compared with the BO_LE constant twice. It seems to me that one of the BO_LE constants should be replaced by BO_LT.


LLVM/Clang

V501 There are identical sub-expressions 'InitArgTypes.size()' to the left and to the right of the '==' operator. ModuleUtils.cpp 107


std::pair<Function *, Function *>
llvm::createSanitizerCtorAndInitFunctions(
    ....
    ArrayRef<Type *> InitArgTypes, ArrayRef<Value *> InitArgs,
    ....)
{
  assert(!InitName.empty() && "Expected init function name");
  assert(InitArgTypes.size() == InitArgTypes.size() &&
    "Sanitizer's init function expects "
    "different number of arguments");
  ....
}

Most likely this is what should be written here: InitArgTypes.size() == InitArgs.size().


Alembic

V501 There are identical sub-expressions 'm_uKnot' to the left and to the right of the '||' operator. ONuPatch.h 253


class Sample
{
  public:
    ....
    bool hasKnotSampleData() const
    {
      if( (m_numU != ABC_GEOM_NUPATCH_NULL_INT_VALUE) ||
          (m_numV != ABC_GEOM_NUPATCH_NULL_INT_VALUE) ||
          (m_uOrder != ABC_GEOM_NUPATCH_NULL_INT_VALUE) ||
          (m_vOrder != ABC_GEOM_NUPATCH_NULL_INT_VALUE) ||
           m_uKnot || m_uKnot)                            // <=
           return true;
      else
          return false;
    }
    ....
  protected:
    ....
    Abc::FloatArraySample m_uKnot;
    Abc::FloatArraySample m_vKnot;
    ....
}

Universal Scene Description

V501 There are identical sub-expressions 'HdChangeTracker::DirtyPrimVar' to the left and to the right of the '|' operator. basisCurves.cpp 563


HdBasisCurves::_GetInitialDirtyBits() const
{
  int mask = HdChangeTracker::Clean;
  mask |= HdChangeTracker::DirtyPrimVar
       |  HdChangeTracker::DirtyWidths
       |  HdChangeTracker::DirtyRefineLevel
       |  HdChangeTracker::DirtyPoints
       |  HdChangeTracker::DirtyNormals
       |  HdChangeTracker::DirtyPrimVar     // <=
       |  HdChangeTracker::DirtyTopology
       ....
      ;

  return (HdChangeTracker::DirtyBits)mask;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'HdChangeTracker::DirtyPrimVar' to the left and to the right of the '|' operator. mesh.cpp 1199

Far2l

V501 There are identical sub-expressions 'Key == MCODE_F_BM_GET' to the left and to the right of the '||' operator. macro.cpp 4819


int KeyMacro::GetKey()
{
  ....
  switch (Key)
  {
  ....
  case MCODE_F_BM_POP:
  {
    TVar p1, p2;

    if (Key == MCODE_F_BM_GET)
      VMStack.Pop(p2);

    if (   Key == MCODE_F_BM_GET
        || Key == MCODE_F_BM_DEL
        || Key == MCODE_F_BM_GET    // <=
        || Key == MCODE_F_BM_GOTO)
    {
      VMStack.Pop(p1);
    }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '!StrCmpN(CurStr, L"!/", 2)' to the left and to the right of the '||' operator. fnparce.cpp 291
  • V501 There are identical sub-expressions '!StrCmpN(CurStr, L"!=/", 3)' to the left and to the right of the '||' operator. fnparce.cpp 291
  • V501 There are identical sub-expressions 'KEY_RCTRL' to the left and to the right of the '|' operator. keyboard.cpp 1830

LLVM/Clang

V501 There are identical sub-expressions 'RA.getSubReg() != 0' to the left and to the right of the '||' operator. hexagonearlyifconv.cpp 485


unsigned HexagonEarlyIfConversion::computePhiCost(....) const {
  ....
  const MachineOperand &RA = MI.getOperand(1);
  const MachineOperand &RB = MI.getOperand(3);
  assert(RA.isReg() && RB.isReg());
  // Must have a MUX if the phi uses a subregister.
  if (RA.getSubReg() != 0 || RA.getSubReg() != 0) {
    Cost++;
    continue;
  }
  ....
}

CryEngine V

V501 There are identical sub-expressions to the left and to the right of the '==' operator: bActive == bActive LightEntity.h 124


void SetActive(bool bActive)
{
  if (bActive == bActive)
    return;

  m_bActive = bActive;
  OnResetState();
}

FreeBSD Kernel

V501 There are identical sub-expressions 'G_Addr->g_addr.s_addr' to the left and to the right of the '==' operator. alias_sctp.c 2132


static struct sctp_nat_assoc*
FindSctpLocalT(struct libalias *la,
               struct in_addr g_addr,
               uint32_t l_vtag, uint16_t g_port,
               uint16_t l_port)
{
  ....
  struct sctp_GlobalAddress *G_Addr = NULL;
  ....
  LIST_FOREACH(G_Addr, &(assoc->Gaddr), list_Gaddr) {
    if(G_Addr->g_addr.s_addr == G_Addr->g_addr.s_addr)  // <=
      return(assoc); /* full match */
  }
  ....
}

Most likely this is what should be written here: if(G_Addr->g_addr.s_addr == g_addr.s_addr)


CryEngine V

V501 There are identical sub-expressions 'm_staticObjects' to the left and to the right of the '||' operator. FeatureCollision.h 66


class CFeatureCollision : public CParticleFeature
{
public:
  CRY_PFX2_DECLARE_FEATURE

public:
  CFeatureCollision();
  ....

  bool  IsActive() const  { return m_terrain ||
                                   m_staticObjects ||
                                   m_staticObjects; }
  ....
  bool m_terrain;
  bool m_staticObjects;
  bool m_dynamicObjects;
};

CryEngine V

V501 There are identical sub-expressions 'm_joints[i].limits[1][j]' to the left and to the right of the '-' operator. articulatedentity.cpp 1326


int CArticulatedEntity::Step(float time_interval)
{
  ....
  for (j=0;j<3;j++) if (!(m_joints[i].flags & angle0_locked<<j)&&
    isneg(m_joints[i].limits[0][j]-m_joints[i].qext[j]) +
    isneg(m_joints[i].qext[j]-m_joints[i].limits[1][j]) +
    isneg(m_joints[i].limits[1][j]-m_joints[i].limits[1][j]) < 2)
  {
    ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'm_joints[op[1]].limits[1][i]' to the left and to the right of the '-' operator. articulatedentity.cpp 513

Notepad++

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: subject != subject verifysignedfile.cpp 250


bool VerifySignedLibrary(...., const wstring& cert_subject, ....)
{
  wstring subject;
  ....
  if ( status && !cert_subject.empty() && subject != subject)
  {
    status = false;
    OutputDebugString(
      TEXT("VerifyLibrary: Invalid certificate subject\n"));
  }
  ....
}

Scilab

V501 There are identical sub-expressions 'strncmp(tx, "%pi", 3) == 0' to the left and to the right of the '||' operator. stringtocomplex.c 276


static int ParseNumber(const char* tx)
{
  ....
  else if (strlen(tx) >= 4 && (strncmp(tx, "%eps", 4) == 0
    || strncmp(tx, "+%pi", 4) == 0 || strncmp(tx, "-%pi", 4) == 0
    || strncmp(tx, "+Inf", 4) == 0 || strncmp(tx, "-Inf", 4) == 0
    || strncmp(tx, "+Nan", 4) == 0 || strncmp(tx, "-Nan", 4) == 0
    || strncmp(tx, "%nan", 4) == 0 || strncmp(tx, "%inf", 4) == 0
          ))
  {
      return 4;
  }
  else if (strlen(tx) >= 3
    && (strncmp(tx, "+%e", 3) == 0
     || strncmp(tx, "-%e", 3) == 0
     || strncmp(tx, "%pi", 3) == 0
     || strncmp(tx, "Nan", 3) == 0
     || strncmp(tx, "Inf", 3) == 0
     || strncmp(tx, "%pi", 3) == 0)) // <=
  {
      return 3;
  }
  ....
}

Aspell

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: out_ && out_ != stdout && out_ != stdout checker_string.cpp 74


CheckerString::~CheckerString()
{
  ....
  if (out_ && out_ != stdout && out_ != stdout)
    fclose(out_);
}

Bind

V501 There are identical sub-expressions '(revoked_zsk[i] != 0)' to the left and to the right of the '||' operator. dnssectool.c 1832


void
verifyzone(dns_db_t *db, dns_dbversion_t *ver,
     dns_name_t *origin, isc_mem_t *mctx,
     isc_boolean_t ignore_kskflag, isc_boolean_t keyset_kskonly)
{
  ....
  unsigned char revoked_ksk[256];
  unsigned char revoked_zsk[256];
  unsigned char standby_ksk[256];
  unsigned char standby_zsk[256];
  unsigned char ksk_algorithms[256];
  unsigned char zsk_algorithms[256];
  ....
  for (i = 0; i < 256; i++) {
    if ((ksk_algorithms[i] != 0) ||
        (standby_ksk[i] != 0) ||
        (revoked_zsk[i] != 0) ||    // revoked_ksk
        (zsk_algorithms[i] != 0) ||
        (standby_zsk[i] != 0) ||
        (revoked_zsk[i] != 0)) {    // revoked_zsk => revoked_ksk
  ....
}

EFL Core Libraries

V501 There are identical sub-expressions to the left and to the right of the '>' operator: ob->priv.last > ob->priv.last evas_outbuf.c 684


Render_Engine_Swap_Mode
evas_outbuf_buffer_state_get(Outbuf *ob)
{
  ....
  int delta;

  delta = (ob->priv.last - ob->priv.curr +
           (ob->priv.last > ob->priv.last ?
               0 : ob->priv.num)) % ob->priv.num;

  switch (delta)
  {
   case 0:
     return MODE_COPY;
   case 1:
     return MODE_DOUBLE;
   case 2:
     return MODE_TRIPLE;
   case 3:
     return MODE_QUADRUPLE;
   default:
     return MODE_FULL;
  }
  ....
}

EFL Core Libraries

V501 There are identical sub-expressions '(pd->map.colors[i]->b != 255)' to the left and to the right of the '||' operator. edje_edit.c 14052


static void _edje_generate_source_state_map(....)
{
  ....
  for (i = 0; i < pd->map.colors_count; ++i)
  {
     if ((pd->map.colors[i]->r != 255) ||
         (pd->map.colors[i]->g != 255) ||
         (pd->map.colors[i]->b != 255) ||
         (pd->map.colors[i]->b != 255))
  ....
}

Tizen

V501 There are identical sub-expressions to the left and to the right of the '<' operator: m_len < m_len segmentor.h 65


bool operator <(const TSegment& other) const {
  if (m_start < other.m_start)
    return true;

  if (m_start == other.m_start)
    return m_len < m_len;

  return false;
}

Tizen

V501 There are identical sub-expressions '0 == safeStrCmp(btn_str, setting_gettext("IDS_ST_BUTTON_OK"))' to the left and to the right of the '||' operator. setting-common-general-func.c 919


EXPORT_PUBLIC
int get_popup_btn_response_type(Evas_Object *obj)
{
  ....
  if (0 == safeStrCmp(btn_str, _("IDS_CST_BUTTON_CLOSE"))
    || 0 == safeStrCmp(btn_str, _("IDS_SAPPS_SK_TRY_ABB"))
    || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_OK"))
    || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_OK"))      // <=
    || 0 == safeStrCmp(btn_str, _("IDS_ST_SK_YES"))
    || 0 == safeStrCmp(btn_str, _("IDS_ST_BUTTON_STOP"))
  ....
}

Enlightenment

V501 There are identical sub-expressions '(!eina_str_has_extension(cfdata->bg, ".mov"))' to the left and to the right of the '&&' operator. e_int_config_wallpaper.c 517


static int
_basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
   E_Config_Wallpaper *cw;

   if (!cfdata->bg) return 0;
   cw = cfd->data;
   if ((!eina_str_has_extension(cfdata->bg, ".edj")) &&
       (!eina_str_has_extension(cfdata->bg, ".gif")) &&
       (!eina_str_has_extension(cfdata->bg, ".png")) &&
       (!eina_str_has_extension(cfdata->bg, ".jpg")) &&
       (!eina_str_has_extension(cfdata->bg, ".jpeg")) &&
       (!eina_str_has_extension(cfdata->bg, ".mp4")) &&
       (!eina_str_has_extension(cfdata->bg, ".m4v")) &&
       (!eina_str_has_extension(cfdata->bg, ".mp2")) &&
       (!eina_str_has_extension(cfdata->bg, ".mpg")) &&
       (!eina_str_has_extension(cfdata->bg, ".mpeg")) &&
       (!eina_str_has_extension(cfdata->bg, ".avi")) &&
       (!eina_str_has_extension(cfdata->bg, ".mov")) &&
       (!eina_str_has_extension(cfdata->bg, ".ogg")) &&
       (!eina_str_has_extension(cfdata->bg, ".ogv")) &&
       (!eina_str_has_extension(cfdata->bg, ".ts")) &&
       (!eina_str_has_extension(cfdata->bg, ".mov"))       // <=
      )
  ....
}

Enlightenment

V501 There are identical sub-expressions '(!strcasecmp(ext, ".ttx"))' to the left and to the right of the '||' operator. e_thumb_main.c 461


static void
_e_thumb_generate(E_Thumb *eth)
{
  ....
  else if ((ext) &&
           ((!strcasecmp(ext, ".ttf")) ||
            (!strcasecmp(ext, ".pcf")) ||
            (!strcasecmp(ext, ".bdf")) ||
            (!strcasecmp(ext, ".ttx")) ||
            (!strcasecmp(ext, ".pfa")) ||
            (!strcasecmp(ext, ".pfb")) ||
            (!strcasecmp(ext, ".afm")) ||
            (!strcasecmp(ext, ".sfd")) ||
            (!strcasecmp(ext, ".snf")) ||
            (!strcasecmp(ext, ".otf")) ||
            (!strcasecmp(ext, ".psf")) ||
            (!strcasecmp(ext, ".ttc")) ||
            (!strcasecmp(ext, ".ttx")) ||            // <=
            (!strcasecmp(ext, ".gsf")) ||
            (!strcasecmp(ext, ".spd"))
          ))
  ....
}

EFL Core Libraries

V501 There are identical sub-expressions 'stacking2->stacking' to the left and to the right of the '>' operator. ephysics_body.cpp 450


static int
_ephysics_body_evas_stacking_sort_cb(const void *d1,
                                     const void *d2)
{
   const EPhysics_Body_Evas_Stacking *stacking1, *stacking2;

   stacking1 = (const EPhysics_Body_Evas_Stacking *)d1;
   stacking2 = (const EPhysics_Body_Evas_Stacking *)d2;

   if (!stacking1) return 1;
   if (!stacking2) return -1;

   if (stacking1->stacking < stacking2->stacking) return -1;
   if (stacking2->stacking > stacking2->stacking) return 1;

   return 0;
}

ClickHouse

V501 Instantiate FunctionComparison < EqualsOp, NameEquals >: There are identical sub-expressions '(left_is_date_time && right_is_date_time)' to the left and to the right of the '||' operator. FunctionsComparison.h 1057


DataTypePtr
getReturnTypeImpl(const DataTypes & arguments) const override
{
  ....
  if (!((.....))
      || ((left_is_string || left_is_fixed_string) && (.....))
      || (left_is_date && right_is_date)
      || (left_is_date && right_is_string)
      || (left_is_string && right_is_date)
      || (left_is_date_time && right_is_date_time)         // 1
      || (left_is_date_time && right_is_string)            // 1
      || (left_is_string && right_is_date_time)            // 1
      || (left_is_date_time && right_is_date_time)         // 2
      || (left_is_date_time && right_is_string)            // 2
      || (left_is_string && right_is_date_time)            // 2
      || (left_is_uuid && right_is_uuid)
      || (left_is_uuid && right_is_string)
      || (left_is_string && right_is_uuid)
      || (left_is_enum && right_is_enum && .....)
      || (left_is_enum && right_is_string)
      || (left_is_string && right_is_enum)
      || (left_tuple && right_tuple && .....)
      || (arguments[0]->equals(*arguments[1]))))
      throw Exception(....);
  ....
}

Similar errors can be found in some other places:

  • V501 Instantiate FunctionComparison < EqualsOp, NameEquals >: There are identical sub-expressions '(left_is_date_time && right_is_string)' to the left and to the right of the '||' operator. FunctionsComparison.h 1057
  • V501 Instantiate FunctionComparison < EqualsOp, NameEquals >: There are identical sub-expressions '(left_is_string && right_is_date_time)' to the left and to the right of the '||' operator. FunctionsComparison.h 1057

MuseScore

V501 There are identical sub-expressions to the left and to the right of the '-' operator: i - i text.cpp 1429


void Text::layout1()
{
  ....
  for (int i = 0; i < rows(); ++i) {
    TextBlock* t = &_layout[i];
    t->layout(this);
    const QRectF* r = &t->boundingRect();

    if (r->height() == 0)
      r = &_layout[i-i].boundingRect(); // <=
    y += t->lineSpacing();
    t->setY(y);
    bb |= r->translated(0.0, y);
  }
  ....
}

Audacity

V501 There are identical sub-expressions 'buffer[remaining - WindowSizeInt - 2]' to the left and to the right of the '-' operator. VoiceKey.cpp 309


sampleCount VoiceKey::OnBackward (
   const WaveTrack & t, sampleCount end, sampleCount len)
{
  ....
  int atrend = sgn(buffer[remaining - 2]-buffer[remaining - 1]);
  int ztrend = sgn(buffer[remaining - WindowSizeInt - 2] -
                   buffer[remaining - WindowSizeInt - 2]);
  ....
}

Tizen

V501 There are identical sub-expressions 'strcmp(cmd, "listen_app_status") == 0' to the left and to the right of the '||' operator. aul_test.c 898


static gboolean run_func(void *data)
{
  callfunc(cmd);
  if (strcmp(cmd, "launch_res") == 0 || strcmp(cmd, "all") == 0
      || strcmp(cmd, "dbuslaunch") == 0
      || strcmp(cmd, "listen_app_status") == 0
      || strcmp(cmd, "open_svc_res") == 0 ||
         strcmp(cmd, "listen_app_status") == 0)   // <=
    return 0;
  else
    g_main_loop_quit(mainloop);
  return 0;
}

V8 JavaScript Engine

V501 There are identical sub-expressions 'StandardFrameConstants::kCallerPCOffset' to the left and to the right of the '-' operator. linkage.h 66


static LinkageLocation ForSavedCallerReturnAddress() {
  return ForCalleeFrameSlot(
    (StandardFrameConstants::kCallerPCOffset -
     StandardFrameConstants::kCallerPCOffset) /
       kPointerSize,
    MachineType::Pointer());
}

Apparently, here's a typo. It makes no sense to subtract a constant from itself, and divide something on the resulting 0.


PDFium

V501 CWE-570 There are identical sub-expressions 'that.BeginPos > EndPos' to the left and to the right of the '||' operator. cpvt_wordrange.h 46


CPVT_WordRange Intersect(const CPVT_WordRange& that) const {
  if (that.EndPos < BeginPos || that.BeginPos > EndPos ||
      EndPos < that.BeginPos || BeginPos > that.EndPos) {
    return CPVT_WordRange();
  }
  return CPVT_WordRange(std::max(BeginPos, that.BeginPos),
                        std::min(EndPos, that.EndPos));
}

The condition is spelled wrong. Let's reduce the condition so that it was easier to notice an error: if (E2 < B1 || B2 > E1 || E1 < B2 || B1 > E2) Note, that (E2 < B1) and (B1 > E2) are the same things. Similarly, (B2 > E1) is the same thing as (E1 < B2).

Similar errors can be found in some other places:

  • V501 CWE-570 There are identical sub-expressions 'that.EndPos < BeginPos' to the left and to the right of the '||' operator. cpvt_wordrange.h 46

PDFium

V501 CWE-571 There are identical sub-expressions 'FXSYS_iswalpha(* iter)' to the left and to the right of the '&&' operator. cpdf_textpage.cpp 1218


inline bool FXSYS_iswalpha(wchar_t wch) {
  return FXSYS_isupper(wch) || FXSYS_islower(wch);
}

bool CPDF_TextPage::IsHyphen(wchar_t curChar) const {
  WideStringView curText = m_TempTextBuf.AsStringView();
  ....
  auto iter = curText.rbegin();
  ....
  if ((iter + 1) != curText.rend()) {
    iter++;
    if (FXSYS_iswalpha(*iter) && FXSYS_iswalpha(*iter))    // <=
      return true;
  }
  ....
}

There is an error in a condition, as it's pointless to check one and the same character twice.


Protocol Buffers

V501 CWE-570 There are identical sub-expressions to the left and to the right of the '||' operator. utility.cc 351


bool IsMap(const google::protobuf::Field& field,
           const google::protobuf::Type& type) {
 return
   field.cardinality() ==
     google::protobuf::Field_Cardinality_CARDINALITY_REPEATED
   &&
   (GetBoolOptionOrDefault(type.options(), "map_entry", false) ||
    GetBoolOptionOrDefault(type.options(),
      "google.protobuf.MessageOptions.map_entry", false) ||
    GetBoolOptionOrDefault(type.options(),
      "google.protobuf.MessageOptions.map_entry", false));  // <=
}

Sub-expressions are repeated. Most likely, there's some sort of a typo.

Similar errors can be found in some other places:

  • V501 CWE-570 There are identical sub-expressions to the left and to the right of the '||' operator. utility.cc 360

SwiftShader

V501 CWE-570 There are identical sub-expressions '!negY->hasDirtyContents()' to the left and to the right of the '||' operator. texture.cpp 1268


void TextureCubeMap::updateBorders(int level)
{
  egl::Image *posX = image[CubeFaceIndex(..._POSITIVE_X)][level];
  egl::Image *negX = image[CubeFaceIndex(..._NEGATIVE_X)][level];
  egl::Image *posY = image[CubeFaceIndex(..._POSITIVE_Y)][level];
  egl::Image *negY = image[CubeFaceIndex(..._NEGATIVE_Y)][level];
  egl::Image *posZ = image[CubeFaceIndex(..._POSITIVE_Z)][level];
  egl::Image *negZ = image[CubeFaceIndex(..._NEGATIVE_Z)][level];
  ....
  if(!posX->hasDirtyContents() ||
     !posY->hasDirtyContents() ||
     !posZ->hasDirtyContents() ||
     !negX->hasDirtyContents() ||
     !negY->hasDirtyContents() ||          // <=
     !negY->hasDirtyContents())            // <=
  {
    return;
  }
  ....
}

At the very end of the condition, a pointer negZ should have been used instead of a pointer negY.


EA WebKit

V501 CWE-571 There are identical sub-expressions 'inherited_rotation.IsNone()' to the left and to the right of the '==' operator. cssrotateinterpolationtype.cpp 166


bool IsValid(....) const final {
  OptionalRotation inherited_rotation =
    GetRotation(*state.ParentStyle());
  if (inherited_rotation_.IsNone() ||
      inherited_rotation.IsNone())
    return inherited_rotation.IsNone() ==
           inherited_rotation.IsNone();
  ....
}

A typo. One underscore _ was missed. It should be as follows: return inherited_rotation_.IsNone() == inherited_rotation.IsNone();


XNU kernel

V501 CWE-570 There are identical sub-expressions 'm->M_dat.MH.MH_pkthdr.len' to the left and to the right of the '!=' operator. key.c 9442


int
key_parse(
      struct mbuf *m,
      struct socket *so)
{
  ....
  if ((m->m_flags & M_PKTHDR) == 0 ||
      m->m_pkthdr.len != m->m_pkthdr.len) {
    ipseclog((LOG_DEBUG,
              "key_parse: invalid message length.\n"));
    PFKEY_STAT_INCREMENT(pfkeystat.out_invlen);
    error = EINVAL;
    goto senderror;
  }
  ....
}

Apparently, it's a typo. The member m->m_pkthdr.len is compared with itself.


TDLib

V501 CWE-570 There are identical sub-expressions to the left and to the right of the '<' operator: a.atime_nsec < a.atime_nsec filegcworker.cpp 125


void FileGcWorker::run_gc(const FileGcParameters ¶meters,
                          std::vector<FullFileInfo> files,
                          Promise<FileStats> promise)
{
  ....
  // sort by max(atime, mtime)
  std::sort(files.begin(), files.end(),
            [](const auto &a, const auto &b)
            {
              return a.atime_nsec < a.atime_nsec;
            });
  ....
}

Krita

V501 There are identical sub-expressions 'sensor(FUZZY_PER_DAB, true)' to the left and to the right of the '||' operator. kis_pressure_size_option.cpp 43


void KisPressureSizeOption::lodLimitations(....) const
{
  if (sensor(FUZZY_PER_DAB, true) ||
      sensor(FUZZY_PER_DAB, true)) {
      l->limitations << KoID("size-fade", i18nc("...."));
  }

  if (sensor(FADE, true)) {
      l->blockers << KoID("...."));
  }
}

Krita

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !iterator.atEnd() &&!iterator.atEnd() KoTextDebug.cpp 867


void KoTextDebug::dumpFrame(const QTextFrame *frame,
                            QTextStream &out)
{
    ....

    QTextFrame::iterator iterator = frame->begin();

    for (; !iterator.atEnd() &&
           !iterator.atEnd(); ++iterator) {
        ....
    }

    ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !iterator.atEnd() &&!iterator.atEnd() KoTextDebug.cpp 909

Android

V501 CWE-571 There are identical sub-expressions to the left and to the right of the '==' operator: pr2.mStretchMode == pr2.mStretchMode AudioResamplerPublic.h 107


static inline bool isAudioPlaybackRateEqual(
  const AudioPlaybackRate &pr1,
  const AudioPlaybackRate &pr2)
{
    return fabs(pr1.mSpeed - pr2.mSpeed) <
             AUDIO_TIMESTRETCH_SPEED_MIN_DELTA &&
           fabs(pr1.mPitch - pr2.mPitch) <
             AUDIO_TIMESTRETCH_PITCH_MIN_DELTA &&
           pr2.mStretchMode == pr2.mStretchMode &&
           pr2.mFallbackMode == pr2.mFallbackMode;
}

Similar errors can be found in some other places:

  • V501 CWE-571 There are identical sub-expressions to the left and to the right of the '==' operator: pr2.mFallbackMode == pr2.mFallbackMode AudioResamplerPublic.h 108

Android

V501 CWE-570 There are identical sub-expressions to the left and to the right of the '||' operator: ns != 1 || 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;
}

Amazon Lumberyard

V501 There are identical sub-expressions to the left and to the right of the '||' operator: hotX < 0 || hotX < 0 editorutils.cpp 166


QCursor CMFCUtils::LoadCursor(....)
{
  ....
  if (!pm.isNull() && (hotX < 0 || hotX < 0))
  {
    QFile f(path);
    f.open(QFile::ReadOnly);
    QDataStream stream(&f);
    stream.setByteOrder(QDataStream::LittleEndian);
    f.read(10);
    quint16 x;
    stream >> x;
    hotX = x;
    stream >> x;
    hotY = x;
  }
  ....
}

Amazon Lumberyard

V501 There are identical sub-expressions 'sp.m_pTexture == m_pTexture' to the left and to the right of the '&&' operator. shadercomponents.h 487


bool operator != (const SCGTexture& sp) const
{
  if (sp.m_RegisterOffset == m_RegisterOffset &&
      sp.m_Name == m_Name &&
      sp.m_pTexture == m_pTexture &&
      sp.m_RegisterCount == m_RegisterCount &&
      sp.m_eCGTextureType == m_eCGTextureType &&
      sp.m_BindingSlot == m_BindingSlot &&
      sp.m_Flags == m_Flags &&
      sp.m_pAnimInfo == m_pAnimInfo &&
      sp.m_pTexture == m_pTexture &&              // <= 1
      sp.m_eCGTextureType == m_eCGTextureType &&  // <= 2
      sp.m_bSRGBLookup == m_bSRGBLookup &&
      sp.m_bGlobal == m_bGlobal)
  {
      return false;
  }
  return true;
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'sp.m_eCGTextureType == m_eCGTextureType' to the left and to the right of the '&&' operator. shadercomponents.h 487

Amazon Lumberyard

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: pTS->pRT_ALD_1 && pTS->pRT_ALD_1 d3d_svo.cpp 857


void CSvoRenderer::ConeTracePass(SSvoTargetsSet* pTS)
{
  ....
  if (pTS->pRT_ALD_1 && pTS->pRT_ALD_1)
  {
    static int nPrevWidth = 0;
    if (....)
    {
      ....
    }
    else
    {
      pTS->pRT_ALD_1->Apply(10, m_nTexStateLinear);
      pTS->pRT_RGB_1->Apply(11, m_nTexStateLinear);
    }
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '||' operator: !pTS->pRT_ALD_0 ||!pTS->pRT_ALD_0 d3d_svo.cpp 1041
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: m_pRT_AIR_MIN && m_pRT_AIR_MIN d3d_svo.cpp 1808
  • V501 There are identical sub-expressions to the left and to the right of the '&&' operator: m_pRT_AIR_MAX && m_pRT_AIR_MAX d3d_svo.cpp 1819
  • And 22 additional diagnostic messages.

Azure Service Fabric

V501 CWE-571 There are identical sub-expressions to the left and to the right of the '==' operator: iter->PackageName == iter->PackageName DigestedApplicationDescription.cpp 247


ErrorCode
DigestedApplicationDescription::ComputeAffectedServiceTypes(....)
{
  ....
  if (iter->PackageName == iter->PackageName &&
    originalRG != this->ResourceGovernanceDescriptions.end() &&
    targetRG != targetDescription.ResourceGovernanceDes....end())
  {
    ....
  }
  ....
}

Azure Service Fabric

V501 CWE-571 There are identical sub-expressions '(dataSizeInRecordIoBuffer > 0)' to the left and to the right of the '&&' operator. OverlayStream.cpp 4966


VOID
OverlayStream::AsyncMultiRecordReadContextOverlay::FSMContinue(
    __in NTSTATUS Status
    )
{
  ULONG dataSizeInRecordMetadata = 0;
  ULONG dataSizeInRecordIoBuffer = 0;
  ....
  if ((dataSizeInRecordIoBuffer > 0) &&
      (dataSizeInRecordIoBuffer > 0))
  {
    ....
  }
  ....
}

Vangers: One For The Road

V501 CWE-570 There are identical sub-expressions 'uvsReturnTreasureStatus(UVS_ITEM_TYPE::PIPKA, uvsTreasureInShop)' to the left and to the right of the '||' operator. univang.cpp 10230


int uvsgetDGdata(int code)
{
  switch (code)
  {
    ....
    // about 230 lines of case
    ....
    case DG_EXTERNS::HERE_PALOCHKA:
      return
        (uvsReturnTreasureStatus
          (UVS_ITEM_TYPE::PALOCHKA, uvsTreasureInShop)
         ||
         uvsReturnTreasureStatus
          (UVS_ITEM_TYPE::PALOCHKA, 0));
      break;
    case DG_EXTERNS::HERE_NOBOOL:
      return
        (uvsReturnTreasureStatus
          (UVS_ITEM_TYPE::NOBOOL, uvsTreasureInShop)
         ||
         uvsReturnTreasureStatus
          (UVS_ITEM_TYPE::NOBOOL, 0));
      break;
    case DG_EXTERNS::HERE_PIPKA:
      return
        (uvsReturnTreasureStatus
          (UVS_ITEM_TYPE::PIPKA, uvsTreasureInShop)
         ||
         uvsReturnTreasureStatus
          (UVS_ITEM_TYPE::PIPKA, uvsTreasureInShop));
      break;
      ....
      // 40 more lines
      ....
  } // end switch

  return 0;
}

Qt

V501 CWE-571 There are identical sub-expressions to the left and to the right of the '&&' operator: !waitingReaders &&!waitingReaders qreadwritelock.cpp 632


void QReadWriteLockPrivate::release()
{
  Q_ASSERT(!recursive);
  Q_ASSERT(!waitingReaders && !waitingReaders &&
           !readerCount && !writerCount);
  freelist->release(id);
}

Similar errors can be found in some other places:

  • V501 CWE-571 There are identical sub-expressions to the left and to the right of the '&&' operator: !d->waitingReaders &&!d->waitingReaders qreadwritelock.cpp 625

Qt

V501 CWE-571 There are identical sub-expressions 'QWindowsContext::user32dll.getWindowDpiAwarenessContext' to the left and to the right of the '&&' operator. qwindowscontext.cpp 150


static inline int windowDpiAwareness(HWND hwnd)
{
  return QWindowsContext::user32dll.getWindowDpiAwarenessContext &&
         QWindowsContext::user32dll.getWindowDpiAwarenessContext
    ? QWindowsContext::user32dll.getAwarenessFromDpiAwarenessContext(
        QWindowsContext::user32dll.getWindowDpiAwarenessContext(hwnd))
    : -1;
}

Godot Engine

V501 CWE-570 There are identical sub-expressions 'bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW' to the left and to the right of the '||' operator. test_shader_lang.cpp 183


static String dump_node_code(SL::Node *p_node, int p_level) {
  ....
  if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW ||
      bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
    code += scode; //use directly
  } else {
    code += _mktab(p_level) + scode + ";\n";
  }
  ....
}

Godot Engine

V501 CWE-570 There are identical sub-expressions '!exists_export_template("uwp_" + platform_infix + "_debug.zip", & err)' to the left and to the right of the '||' operator. export.cpp 1135


virtual bool can_export(....)
{
  ....
  if (!exists_export_template("uwp_" + platform_infix + "_debug.zip", &err) ||
      !exists_export_template("uwp_" + platform_infix + "_debug.zip", &err)) {
    valid = false;
    r_missing_templates = true;
  }
  ....
}

The second line in the condition should look like this: !exists_export_template("uwp_" + platform_infix + "_release.zip", &err)


Godot Engine

V501 CWE-570 There are identical sub-expressions 'p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT' to the left and to the right of the '||' operator. editor_spin_slider.cpp 157


void EditorSpinSlider::_notification(int p_what) {
  if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT ||
      p_what == MainLoop::NOTIFICATION_WM_FOCUS_OUT) {
    if (grabbing_spinner) {
      Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
      grabbing_spinner = false;
      grabbing_spinner_attempt = false;
    }
  }
  ....
}

Godot Engine

V501 CWE-570 There are identical sub-expressions to the left and to the right of the '||' operator. soft_body.cpp 399


String SoftBody::get_configuration_warning() const {
  ....
  Transform t = get_transform();
  if ((ABS(t.basis.get_axis(0).length() - 1.0) > 0.05 ||
       ABS(t.basis.get_axis(1).length() - 1.0) > 0.05 ||
       ABS(t.basis.get_axis(0).length() - 1.0) > 0.05)) {
    if (!warning.empty())
  ....
}

NCBI Genome Workbench

V501 There are identical sub-expressions '(!loc1.IsInt() &&!loc1.IsWhole())' to the left and to the right of the '||' operator. nw_aligner.cpp 480


CRef<CSeq_align> CNWAligner::Run(CScope &scope, const CSeq_loc &loc1,
                                 const CSeq_loc &loc2,
                                 bool trim_end_gaps)
{
  if ((!loc1.IsInt() && !loc1.IsWhole()) ||
      (!loc1.IsInt() && !loc1.IsWhole()))
  {
    NCBI_THROW(CException, eUnknown,
               "Only whole and interval locations supported");
  }
  ....
}

NCBI Genome Workbench

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: bd.bit_.bits[i] != bd.bit_.bits[i] bm.h 296


bool compare_state(const iterator_base& ib) const
{
  ....
  if (this->block_type_ == 0
  {
    if (bd.bit_.ptr != ib_db.bit_.ptr) return false;
    if (bd.bit_.idx != ib_db.bit_.idx) return false;
    if (bd.bit_.cnt != ib_db.bit_.cnt) return false;
    if (bd.bit_.pos != ib_db.bit_.pos) return false;
    for (unsigned i = 0; i < bd.bit_.cnt; ++i)
    {
      if (bd.bit_.bits[i] != bd.bit_.bits[i]) return false;
    }
  }
  ....
}

NCBI Genome Workbench

V501 There are identical sub-expressions 'CFieldHandler::QualifierNamesAreEquivalent(field, kFieldTypeSeqId)' to the left and to the right of the '||' operator. field_handler.cpp 152


bool CFieldHandlerFactory::s_IsSequenceIDField(const string& field)
{
  if (   CFieldHandler::QualifierNamesAreEquivalent(field, kFieldTypeSeqId)
      || CFieldHandler::QualifierNamesAreEquivalent(field, kFieldTypeSeqId)) {
    return true;
  } else {
    return false;
  }
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'uf->GetData().IsBool()' to the left and to the right of the '&&' operator. variation_utils.cpp 1711
  • V501 There are identical sub-expressions 'uf->GetData().IsBool()' to the left and to the right of the '&&' operator. variation_utils.cpp 1735

LibreOffice

V501 There are identical sub-expressions 'mpTable[ocArrayColSep] != mpTable[eOp]' to the left and to the right of the '&&' operator. formulacompiler.cxx 632


void FormulaCompiler::OpCodeMap::putOpCode(....)
{
  ....
  case ocSep:
      bPutOp = true;
      bRemoveFromMap = (mpTable[eOp] != ";" &&
              mpTable[ocArrayColSep] != mpTable[eOp] &&
              mpTable[ocArrayColSep] != mpTable[eOp]);
  break;
  ....
}

Stellarium

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. UT ox3dtabview.cpp 230


class StelProjectorCylinder : public StelProjector
{
  ....
  virtual bool
  intersectViewportDiscontinuityInternal(const Vec3d& capN,
                                         double capD) const
  {
    static const SphericalCap cap1(1,0,0);
    static const SphericalCap cap2(-1,0,0);
    static const SphericalCap cap3(0,0,-1);
    SphericalCap cap(capN, capD);
    return cap.intersects(cap1)
        && cap.intersects(cap2)
        && cap.intersects(cap2);
  }
};

Most likely this is cap3 should be written in the last line.


LibrePCB

V501 CWE-571 There are identical sub-expressions 'symbVarItemUuid' to the left and to the right of the '&&' operator. symbolpreviewgraphicsitem.cpp 74


SymbolPreviewGraphicsItem::SymbolPreviewGraphicsItem(
    const IF_GraphicsLayerProvider& layerProvider,
    const QStringList& localeOrder, const Symbol& symbol, const Component* cmp,
    const tl::optional<Uuid>& symbVarUuid,
    const tl::optional<Uuid>& symbVarItemUuid) noexcept
{
  if (mComponent && symbVarUuid && symbVarItemUuid)
  ....
  if (mComponent && symbVarItemUuid && symbVarItemUuid)      // <=
  ....
}

Qalculate!

V501 There are identical sub-expressions '!mtr2.number().isReal()' to the left and to the right of the '||' operator. BuiltinFunctions.cc 6274


int IntegrateFunction::calculate(....)
{
  ....
  if(!mtr2.isNumber() || !mtr2.number().isReal() ||
      !mtr.isNumber() || !mtr2.number().isReal()) b_unknown_precision = true;
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'vargs[1].representsNonPositive()' to the left and to the right of the '||' operator. BuiltinFunctions.cc 5788
  • V501 There are identical sub-expressions 'append' to the left and to the right of the '&&' operator. MathStructure.cc 1780
  • V501 There are identical sub-expressions 'append' to the left and to the right of the '&&' operator. MathStructure.cc 2043
  • And 1 additional diagnostic messages.

LLVM/Clang

V501 [CWE-570] There are identical sub-expressions 'Name.startswith("avx512.mask.permvar.")' to the left and to the right of the '||' operator. AutoUpgrade.cpp 73


static bool ShouldUpgradeX86Intrinsic(Function *F, StringRef Name) {
  if (Name == "addcarryx.u32" || // Added in 8.0
    ....
    Name == "avx512.mask.cvtps2pd.128" || // Added in 7.0
    Name == "avx512.mask.cvtps2pd.256" || // Added in 7.0
    Name == "avx512.cvtusi2sd" || // Added in 7.0
    Name.startswith("avx512.mask.permvar.") || // Added in 7.0
    Name.startswith("avx512.mask.permvar.") || // Added in 7.0  // <=
    Name == "sse2.pmulu.dq" || // Added in 7.0
    Name == "sse41.pmuldq" || // Added in 7.0
    Name == "avx2.pmulu.dq" || // Added in 7.0
  ....
}

LLVM/Clang

V501 There are identical sub-expressions 'CXNameRange_WantQualifier' to the left and to the right of the '|' operator. CIndex.cpp 7245


enum CXNameRefFlags {
  CXNameRange_WantQualifier = 0x1,
  CXNameRange_WantTemplateArgs = 0x2,
  CXNameRange_WantSinglePiece = 0x4
};

void AnnotateTokensWorker::HandlePostPonedChildCursor(
    CXCursor Cursor, unsigned StartTokenIndex) {
  const auto flags = CXNameRange_WantQualifier | CXNameRange_WantQualifier;
  ....
}

Haiku Operation System

V501 There are identical sub-expressions to the left and to the right of the '-' operator: (addr_t) b - (addr_t) b BitmapManager.cpp 51


int
compare_app_pointer(const ServerApp* a, const ServerApp* b)
{
  return (addr_t)b - (addr_t)b;
}

Haiku Operation System

V501 There are identical sub-expressions to the left and to the right of the '||' operator: input == __null || input == __null MediaClient.cpp 182


status_t
BMediaClient::Unbind(BMediaInput* input, BMediaOutput* output)
{
  CALLED();

  if (input == NULL
    || input == NULL)
    return B_ERROR;

  if (input->fOwner != this || output->fOwner != this)
    return B_ERROR;

  input->fBind = NULL;
  output->fBind = NULL;
  return B_OK;
}

Haiku Operation System

V501 There are identical sub-expressions to the left and to the right of the '>' operator: fg[order_type::R] > fg[order_type::R] agg_span_image_filter_rgba.h 898


typedef Source source_type;
typedef typename source_type::color_type color_type;
typedef typename source_type::order_type order_type;

void generate(color_type* span, int x, int y, unsigned len)
{
 ....
 if(fg[0] < 0) fg[0] = 0;
 if(fg[1] < 0) fg[1] = 0;
 if(fg[2] < 0) fg[2] = 0;
 if(fg[3] < 0) fg[3] = 0;

 if(fg[order_type::A] > base_mask)        fg[order_type::A] = base_mask;
 if(fg[order_type::R] > fg[order_type::R])fg[order_type::R] = fg[order_type::R];
 if(fg[order_type::G] > fg[order_type::G])fg[order_type::G] = fg[order_type::G];
 if(fg[order_type::B] > fg[order_type::B])fg[order_type::B] = fg[order_type::B];
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '>' operator: fg[order_type::G] > fg[order_type::G] agg_span_image_filter_rgba.h 899
  • V501 There are identical sub-expressions to the left and to the right of the '>' operator: fg[order_type::B] > fg[order_type::B] agg_span_image_filter_rgba.h 900

Bullet Physics SDK

V501 There are identical sub-expressions 'cs.m_fJacCoeffInv[0] == 0' to the left and to the right of the '&&' operator. b3CpuRigidBodyPipeline.cpp 169


float m_fJacCoeffInv[2];
static inline void b3SolveFriction(b3ContactConstraint4& cs, ....)
{
  if (cs.m_fJacCoeffInv[0] == 0 && cs.m_fJacCoeffInv[0] == 0)
  {
    return;
  }
  ....
}

PPSSPP

V501 There are identical sub-expressions '!Memory::IsValidAddress(psmfData)' to the left and to the right of the '||' operator. scePsmf.cpp 703


static u32 scePsmfSetPsmf(u32 psmfStruct, u32 psmfData) {
  if (!Memory::IsValidAddress(psmfData) ||
      !Memory::IsValidAddress(psmfData)) {
    return hleReportError(ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "bad address");
  }
  ....
}

Mozilla Thunderbird

V501 There are identical sub-expressions '(!strcmp(header, "Reply-To"))' to the left and to the right of the '||' operator. nsEmitterUtils.cpp 28


extern "C" bool EmitThisHeaderForPrefSetting(int32_t dispType,
                                             const char *header) {
  ....
  if (nsMimeHeaderDisplayTypes::NormalHeaders == dispType) {
    if ((!strcmp(header, HEADER_DATE)) || (!strcmp(header, HEADER_TO)) ||
        (!strcmp(header, HEADER_SUBJECT)) || (!strcmp(header, HEADER_SENDER)) ||
        (!strcmp(header, HEADER_RESENT_TO)) ||
        (!strcmp(header, HEADER_RESENT_SENDER)) ||
        (!strcmp(header, HEADER_RESENT_FROM)) ||
        (!strcmp(header, HEADER_RESENT_CC)) ||
        (!strcmp(header, HEADER_REPLY_TO)) ||
        (!strcmp(header, HEADER_REFERENCES)) ||
        (!strcmp(header, HEADER_NEWSGROUPS)) ||
        (!strcmp(header, HEADER_MESSAGE_ID)) ||
        (!strcmp(header, HEADER_FROM)) ||
        (!strcmp(header, HEADER_FOLLOWUP_TO)) || (!strcmp(header, HEADER_CC)) ||
        (!strcmp(header, HEADER_ORGANIZATION)) ||
        (!strcmp(header, HEADER_REPLY_TO)) || (!strcmp(header, HEADER_BCC)))
      return true;
    else
      return false;
  ....
}

Mozilla Thunderbird

V501 There are identical sub-expressions 'obj->options->headers != MimeHeadersCitation' to the left and to the right of the '&&' operator. mimemsig.cpp 536


static int MimeMultipartSigned_emit_child(MimeObject *obj) {
  ....
  if (obj->options && obj->options->headers != MimeHeadersCitation &&
      obj->options->write_html_p && obj->options->output_fn &&
      obj->options->headers != MimeHeadersCitation && sig->crypto_closure) {
    ....
  }
  ....
}

Celestia

V501 There are identical sub-expressions to the left and to the right of the '<' operator: b.nAttributes < b.nAttributes cmodfix.cpp 378


bool operator<(const Mesh::VertexDescription& a,
               const Mesh::VertexDescription& b)
{
  if (a.stride < b.stride)
    return true;
  if (b.stride < a.stride)
    return false;

  if (a.nAttributes < b.nAttributes)
    return true;
  if (b.nAttributes < b.nAttributes)  // <=
    return false;

  for (uint32_t i = 0; i < a.nAttributes; i++)
  {
    if (a.attributes[i] < b.attributes[i])
      return true;
    else if (b.attributes[i] < a.attributes[i])
      return false;
  }

  return false;
}

TON

V501 There are identical sub-expressions to the left and to the right of the '==' operator: zero_state_id_ == zero_state_id_ LastBlock.cpp 66


class LastBlock : public td::actor::Actor {
  ....
  ton::ZeroStateIdExt zero_state_id_;
  ....
};

void LastBlock::update_zero_state(ton::ZeroStateIdExt zero_state_id) {
  ....
  if (zero_state_id_ == zero_state_id_) {
    return;
  }

  LOG(FATAL) << ....;
}

ROOT

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: module && module rootcling_impl.cxx 3650


virtual void HandleDiagnostic(....) override
{
  ....
  bool isROOTSystemModuleDiag = module && ....;
  bool isSystemModuleDiag = module && module && module->IsSystem;
  if (!isROOTSystemModuleDiag && !isSystemModuleDiag)
    fChild->HandleDiagnostic(DiagLevel, Info);
  ....
}

ROOT

V501 There are identical sub-expressions 'strchr(fHostAuth->GetHost(), '*')' to the left and to the right of the '||' operator. TAuthenticate.cxx 300


TAuthenticate::TAuthenticate(TSocket *sock, const char *remote,
                             const char *proto, const char *user)
{
  ....
  // If generic THostAuth (i.e. with wild card or user == any)
  // make a personalized memory copy of this THostAuth
  if (strchr(fHostAuth->GetHost(),'*') || strchr(fHostAuth->GetHost(),'*') ||
     fHostAuth->GetServer() == -1 ) {
    fHostAuth = new THostAuth(*fHostAuth);
    fHostAuth->SetHost(fqdn);
    fHostAuth->SetUser(checkUser);
    fHostAuth->SetServer(servtype);
  }
  ....
}

Zephyr

V501 [CWE-571] There are identical sub-expressions to the left and to the right of the '&&' operator: link.tx.cb && link.tx.cb pb_adv.c 377


typedef void (*prov_bearer_send_complete_t)(int err, void *cb_data);

struct pb_adv {
  ....
  struct {
    ....
    prov_bearer_send_complete_t cb;
    void *cb_data;
    ....
  } tx;
  ....
};

static struct pb_adv link = { .rx = { .buf = &rx_buf } };

static void gen_prov_ack(struct prov_rx *rx, struct net_buf_simple *buf)
{
  ....
  if (link.tx.cb && link.tx.cb) {
    link.tx.cb(0, link.tx.cb_data);
  }
  ....
}

GCC

V501 There are identical sub-expressions 'wi_zero_p(type, lh_lb, lh_ub)' to the left and to the right of the '||' operator. range-op.cc 2657


void
pointer_and_operator::wi_fold (value_range &r, tree type,
             const wide_int &lh_lb,
             const wide_int &lh_ub,
             const wide_int &rh_lb ATTRIBUTE_UNUSED,
             const wide_int &rh_ub ATTRIBUTE_UNUSED) const
{
  // For pointer types, we are really only interested in asserting
  // whether the expression evaluates to non-NULL.
  if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub))
    r = range_zero (type);
  else
    r = value_range (type);
}

Command & Conquer

V501 There are identical sub-expressions to the left and to the right of the '||' operator: dest == 0 || dest == 0 CONQUER.CPP 5576


void List_Copy(short const * source, int len, short * dest)
{
  if (dest == NULL || dest == NULL) {
    return;
  }
  ....
}

ORCT2

V501 There are identical sub-expressions '(1ULL << WIDX_MONTH_BOX)' to the left and to the right of the '|' operator. libopenrct2ui Cheats.cpp 487


static uint64_t window_cheats_page_enabled_widgets[] =
{
  MAIN_CHEAT_ENABLED_WIDGETS |
  (1ULL << WIDX_NO_MONEY) |
  (1ULL << WIDX_ADD_SET_MONEY_GROUP) |
  (1ULL << WIDX_MONEY_SPINNER) |
  (1ULL << WIDX_MONEY_SPINNER_INCREMENT) |
  (1ULL << WIDX_MONEY_SPINNER_DECREMENT) |
  (1ULL << WIDX_ADD_MONEY) |
  (1ULL << WIDX_SET_MONEY) |
  (1ULL << WIDX_CLEAR_LOAN) |
  (1ULL << WIDX_DATE_SET) |
  (1ULL << WIDX_MONTH_BOX) |
  (1ULL << WIDX_MONTH_UP) |
  (1ULL << WIDX_MONTH_DOWN) |
  (1ULL << WIDX_YEAR_BOX) |
  (1ULL << WIDX_YEAR_UP) |
  (1ULL << WIDX_YEAR_DOWN) |
  (1ULL << WIDX_DAY_BOX) |
  (1ULL << WIDX_DAY_UP) |
  (1ULL << WIDX_DAY_DOWN) |
  (1ULL << WIDX_MONTH_BOX) |  // <=
  (1ULL << WIDX_DATE_GROUP) |
  (1ULL << WIDX_DATE_RESET),
  ....
};

LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: !T1.isNull() && !T1.isNull() SemaOverload.cpp 9493


class ReturnValueSlot {
  ....
  bool isNull() const { return !Addr.isValid(); }
  ....
};

static bool haveSameParameterTypes(ASTContext &Context, const FunctionDecl *F1,
                                   const FunctionDecl *F2, unsigned NumParams) {
  ....
  unsigned I1 = 0, I2 = 0;
  for (unsigned I = 0; I != NumParams; ++I) {
    QualType T1 = NextParam(F1, I1, I == 0);
    QualType T2 = NextParam(F2, I2, I == 0);
    if (!T1.isNull() && !T1.isNull() && !Context.hasSameUnqualifiedType(T1, T2))
      return false;
  }
  return true;
}

Amnesia: The Dark Descent

V501 There are identical sub-expressions 'aObjectDataA.mpObject->GetVertexBuffer()' to the left and to the right of the '<' operator. WorldLoaderHplMap.cpp 1123


static bool SortStaticSubMeshesForBodies(const ....& aObjectDataA,
                                         const ....& aObjectDataB)
{
  //Is shadow caster check
  if(   aObjectDataA.mpObject->GetRenderFlagBit(....)
     != aObjectDataB.mpObject->GetRenderFlagBit(....))
  {
    return  aObjectDataA.mpObject->GetRenderFlagBit(....)
          < aObjectDataB.mpObject->GetRenderFlagBit(....);
  }
  //Material check
  if( aObjectDataA.mpPhysicsMaterial != aObjectDataB.mpPhysicsMaterial)
  {
    return aObjectDataA.mpPhysicsMaterial < aObjectDataB.mpPhysicsMaterial;
  }

  //Char collider or not
  if( aObjectDataA.mbCharCollider  != aObjectDataB.mbCharCollider)
  {
    return aObjectDataA.mbCharCollider < aObjectDataB.mbCharCollider;
  }

  return  aObjectDataA.mpObject->GetVertexBuffer()
        < aObjectDataA.mpObject->GetVertexBuffer();
}

Amnesia: The Dark Descent

V501 There are identical sub-expressions to the left and to the right of the '==' operator: edge1.tri1 == edge1.tri1 Math.cpp 2914


static bool EdgeTriEqual(const cTriEdge &edge1, const cTriEdge &edge2)
{
  if(edge1.tri1 == edge2.tri1 && edge1.tri2 == edge2.tri2)
    return true;
  if(edge1.tri1 == edge1.tri1 && edge1.tri2 == edge2.tri1)
    return true;
  return false;
}

Amnesia: The Dark Descent

V501 There are identical sub-expressions 'lType == eLuxJournalState_OpenNote' to the left and to the right of the '||' operator. LuxJournal.cpp 2262


enum eLuxJournalState
{
  eLuxJournalState_Main,
  eLuxJournalState_Notes,
  eLuxJournalState_Diaries,
  eLuxJournalState_QuestLog,
  eLuxJournalState_OpenNote,
  eLuxJournalState_OpenDiary,
  eLuxJournalState_OpenNarratedDiary,

  eLuxJournalState_LastEnum,
};

bool cLuxJournal::UIListenerButtonPress(iWidget* apWidget,
                                        const cGuiMessageData& aData)
{
  int lType = apWidget->GetUserValue();

  if(!(    lType == eLuxJournalState_OpenNote
       || lType == eLuxJournalState_OpenDiary
       || lType == eLuxJournalState_OpenNote
       || lType == eLuxJournalState_OpenNarratedDiary))
    return false;
  ....
}

Amnesia: The Dark Descent

V501 There are identical sub-expressions to the left and to the right of the '||' operator: avSubDiv.x > 1 || avSubDiv.x > 1 ParticleEmitter.cpp 199


void iParticleEmitter::SetSubDivUV(const cVector2l &avSubDiv)
{
  //Check so that there is any subdivision
  // and that no sub divison axis is
  //equal or below zero
  if( (avSubDiv.x > 1 || avSubDiv.x > 1) && (avSubDiv.x >0 && avSubDiv.y >0))
  {
    ....
  }
  ....
}

GTK

V501 There are identical sub-expressions 'G_PARAM_EXPLICIT_NOTIFY' to the left and to the right of the '|' operator. gtklistbase.c 1151


static void
gtk_list_base_class_init (GtkListBaseClass *klass)
{
  ....
  properties[PROP_ORIENTATION] =
    g_param_spec_enum ("orientation",
                       P_("Orientation"),
                       P_("The orientation of the orientable"),
                       GTK_TYPE_ORIENTATION,
                       GTK_ORIENTATION_VERTICAL,
                       G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY |
                                           G_PARAM_EXPLICIT_NOTIFY);
  ....
}

Qt

V501 [CWE-570] There are identical sub-expressions to the left and to the right of the '||' operator: node->isGroup() || node->isGroup() docbookgenerator.cpp 2599


class Node
{
  ....
  bool isGroup() const { return m_nodeType == Group; }
  ....
};

void DocBookGenerator::generateDocBookSynopsis(const Node *node)
{
  ....
  if (node->isGroup() || node->isGroup()
      || node->isSharedCommentNode() || node->isModule()
      || node->isJsModule() || node->isQmlModule() || node->isPageNode())
    return;
  ....
}

MuseScore

V501 There are identical sub-expressions to the left and to the right of the '==' operator: desiredLen == desiredLen importmidi_simplify.cpp 44


bool areDurationsEqual(
  const QList<std::pair<ReducedFraction, TDuration> >& durations,
  const ReducedFraction& desiredLen)
{
  ReducedFraction sum(0, 1);
  for (const auto& d: durations) {
    sum += ReducedFraction(d.second.fraction()) / d.first;
  }

  return desiredLen == desiredLen;
}

MuseScore

V501 There are identical sub-expressions to the left and to the right of the '-' operator: i - i textbase.cpp 1986


void TextBase::layout1()
{
  ....
  for (int i = 0; i < rows(); ++i) {
    TextBlock* t = &_layout[i];
    t->layout(this);
    const QRectF* r = &t->boundingRect();

    if (r->height() == 0) {
      r = &_layout[i - i].boundingRect(); // <=
    }
    y += t->lineSpacing();
    t->setY(y);
    bb |= r->translated(0.0, y);
  }
  ....
}

Snort

V501 There are identical sub-expressions '!info->sip.__in6_u.__u6_addr32[0]' to the left and to the right of the '&&' operator. pkt_tracer.c 160


static inline void debugParse(...., DebugSessionConstraints *info)
{
  ....
    if (!info->sip.s6_addr32[0] && !info->sip.s6_addr32[0] &&
      !info->sip.s6_addr16[4] && info->sip.s6_addr16[5] == 0xFFFF)
    {
      ....
    }

  if (!info->dip.s6_addr32[0] && !info->dip.s6_addr32[0] &&
    !info->dip.s6_addr16[4] && info->dip.s6_addr16[5] == 0xFFFF)
  {
    ....
  }
  ....
}

LFortran

V501 [CWE-571] There are identical sub-expressions to the left and to the right of the '&&' operator: kind_str[0] != '0' && kind_str[0] != '0' asr_utils.h 330


static inline int extract_kind_from_ttype_t(const ASR::ttype_t* curr_type) {
  ....
  if( kind_str[0] != '0' && kind_str[1] == '0'  ) {
    return kind_str[0] - '0';
  } else if( kind_str[0] != '0' && kind_str[0] != '0' ) {
    return (kind_str[0] - '0')*10 + (kind_str[1] - '0');
  }
  ....
}

LLVM/Clang

V501 [CWE-571] There are identical sub-expressions 'any_of(S, isIntegerOrPtr)' to the left and to the right of the '&&' operator. CodeGenDAGPatterns.cpp 479


bool TypeInfer::EnforceSmallerThan(TypeSetByHwMode &Small,
                                   TypeSetByHwMode &Big) {
  ....
  for (unsigned M : Modes) {
    TypeSetByHwMode::SetType &S = Small.get(M);
    TypeSetByHwMode::SetType &B = Big.get(M);

    if (any_of(S, isIntegerOrPtr) && any_of(S, isIntegerOrPtr)) {   // <=
      auto NotInt = [](MVT VT) { return !isIntegerOrPtr(VT); };
      Changed |= berase_if(S, NotInt);
      Changed |= berase_if(B, NotInt);
    } else if (any_of(S, isFloatingPoint) && any_of(B, isFloatingPoint)) {
      auto NotFP = [](MVT VT) { return !isFloatingPoint(VT); };
      Changed |= berase_if(S, NotFP);
      Changed |= berase_if(B, NotFP);
    } else if (S.empty() || B.empty()) {
      Changed = !S.empty() || !B.empty();
      S.clear();
      B.clear();
    } else {
      TP.error("Incompatible types");
      return Changed;
    }
  ....
}

LLVM/Clang

V501 [CWE-571] There are identical sub-expressions to the left and to the right of the '==' operator: OriginalValue == OriginalValue RewriteStatepointsForGC.cpp 758


bool operator==(const BDVState &Other) const {
  return OriginalValue == OriginalValue && BaseValue == Other.BaseValue &&
    Status == Other.Status;
}

DuckStation

V501 There are identical sub-expressions 'c != ' '' to the left and to the right of the '&&' operator. file_system.cpp 560


static inline bool FileSystemCharacterIsSane(char c, ....)
{
  if    (!(c >= 'a' && c <= 'z')
     && !(c >= 'A' && c <= 'Z')
     && !(c >= '0' && c <= '9')
     &&   c != ' '
     &&   c != ' '
     &&   c != '_'
     &&   c != '-'
     &&   c != '.')
  {
    ....
  }
  ....
}

DuckStation

V501 There are identical sub-expressions to the left and to the right of the '|' operator: KMOD_LCTRL | KMOD_LCTRL sdl_key_names.h 271


typedef enum
{
  KMOD_NONE   = 0x0000,
  KMOD_LSHIFT = 0x0001,
  KMOD_RSHIFT = 0x0002,
  KMOD_LCTRL  = 0x0040,
  ....
}
....
static const std::array<SDLKeyModifierEntry, 4> s_sdl_key_modifiers =
{
  {{KMOD_LSHIFT, static_cast<SDL_Keymod>(KMOD_LSHIFT | KMOD_RSHIFT),
    SDLK_LSHIFT, SDLK_RSHIFT, "Shift"},
  {KMOD_LCTRL, static_cast<SDL_Keymod>(KMOD_LCTRL | KMOD_LCTRL), // <=
    SDLK_LCTRL, SDLK_RCTRL, "Control"},
  {KMOD_LALT, static_cast<SDL_Keymod>(KMOD_LALT | KMOD_RALT),
    SDLK_LALT, SDLK_RALT, "Alt"},
  {KMOD_LGUI, static_cast<SDL_Keymod>(KMOD_LGUI | KMOD_RGUI),
    SDLK_LGUI, SDLK_RGUI, "Meta"}}
};

DuckStation

V501 There are identical sub-expressions 'TokenMatch(command, "CATALOG")' to the left and to the right of the '||' operator. cue_parser.cpp 196


bool File::ParseLine(const char* line, ....)
{
  const std::string_view command(GetToken(line));
  ....
  if (   TokenMatch(command, "CATALOG")
      || TokenMatch(command, "CDTEXTFILE")
      || TokenMatch(command, "CATALOG") // <=
      || TokenMatch(command, "ISRC")
      || TokenMatch("command", "TRACK_ISRC")
      || TokenMatch(command, "TITLE")
      ||  ....)
  {
    ....
  }
  ....
}

TheXTech

V501 There are identical sub-expressions '(evt.AutoSection) >= (0)' to the left and to the right of the '&&' operator. thextech layers.cpp 568


#define IF_INRANGE(x, l, r)  ((x) >= (l) && (x) <= (r))

else if(  IF_INRANGE(evt.AutoSection, 0, maxSections)
       && IF_INRANGE(evt.AutoSection, 0, maxEvents))
{
  // Buggy behavior, see https://github.com/Wohlstand/TheXTech/issues/44
  AutoX[evt.AutoSection] = Events[evt.AutoSection].AutoX;
  AutoY[evt.AutoSection] = Events[evt.AutoSection].AutoY;
}

TheXTech

V501 There are identical sub-expressions to the left and to the right of the '!=' operator: NPC[A].Projectile != NPC[A].Projectile thextech npc_hit.cpp 2105


else if (  NPC[A].Location.SpeedX != oldNPC.Location.SpeedX
        || NPC[A].Location.SpeedY != oldNPC.Location.SpeedY
        || NPC[A].Projectile != NPC[A].Projectile  // <=
        || NPC[A].Killed != oldNPC.Killed
        || NPC[A].Type != oldNPC.Type
        || NPC[A].Inert != oldNPC.Inert)
{ .... }

TheXTech

V501 There are identical sub-expressions 'MenuMode == MENU_SELECT_SLOT_1P_DELETE' to the left and to the right of the '||' operator. thextech menu_main.cpp 1004


// Delete gamesave
else if(  MenuMode == MENU_SELECT_SLOT_1P_DELETE
       || MenuMode == MENU_SELECT_SLOT_1P_DELETE)
{
  if(MenuMouseMove)
    s_handleMouseMove(2, 300, 350, 300, 30);
....

Chromium

V501 There are identical sub-expressions 'user_blocking_count_ == 0' to the left and to the right of the '&&' operator. process_priority_aggregator.cc 98


bool ProcessPriorityAggregator::Data::IsEmpty() const {
#if DCHECK_IS_ON()
  if (lowest_count_)
    return false;
#endif
  return user_blocking_count_ == 0 && user_blocking_count_ == 0;
}

Chromium

V501 There are identical sub-expressions 'file.MatchesExtension(L".xlsb")' to the left and to the right of the '||' operator. download_type_util.cc 60


ClientDownloadRequest::DownloadType GetDownloadType(const base::FilePath& file)
{
  ....
  if (file.MatchesExtension(FILE_PATH_LITERAL(".apk")))
    return ClientDownloadRequest::ANDROID_APK;
  ....
  else if (file.MatchesExtension(FILE_PATH_LITERAL(".pdf")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".doc")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".docx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".docm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".docb")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".dot")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".dotm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".dotx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xls")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xlsb")) ||  // <=
           file.MatchesExtension(FILE_PATH_LITERAL(".xlt")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xlm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xlsx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xldm")) ||  // <=
           file.MatchesExtension(FILE_PATH_LITERAL(".xltx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xltm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xlsb")) ||  // <=
           file.MatchesExtension(FILE_PATH_LITERAL(".xla")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xlam")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xll")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xlw")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".ppt")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".pot")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".pps")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".pptx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".pptm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".potx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".potm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".ppam")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".ppsx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".ppsm")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".sldx")) ||
           file.MatchesExtension(FILE_PATH_LITERAL(".xldm")) ||  // <=
           file.MatchesExtension(FILE_PATH_LITERAL(".rtf")))
    return ClientDownloadRequest::DOCUMENT;
  ....
}

Chromium

V501 There are identical sub-expressions to the left and to the right of the '&&' operator. password_form.cc 265


bool operator==(const PasswordForm& lhs, const PasswordForm& rhs) {
  return lhs.scheme == rhs.scheme && lhs.signon_realm == rhs.signon_realm &&
         lhs.url == rhs.url && lhs.action == rhs.action &&
         lhs.submit_element == rhs.submit_element &&
         lhs.username_element == rhs.username_element &&
         lhs.username_element_renderer_id == rhs.username_element_renderer_id &&
         lhs.username_value == rhs.username_value &&
         lhs.all_possible_usernames == rhs.all_possible_usernames &&
         lhs.all_possible_passwords == rhs.all_possible_passwords &&
         lhs.form_has_autofilled_value == rhs.form_has_autofilled_value &&
         lhs.password_element == rhs.password_element &&
         lhs.password_element_renderer_id == rhs.password_element_renderer_id &&
         lhs.password_value == rhs.password_value &&
         lhs.new_password_element == rhs.new_password_element &&
         lhs.confirmation_password_element_renderer_id ==                // <=
             rhs.confirmation_password_element_renderer_id &&            // <=
         lhs.confirmation_password_element ==
             rhs.confirmation_password_element &&
         lhs.confirmation_password_element_renderer_id ==                // <=
             rhs.confirmation_password_element_renderer_id &&            // <=
         lhs.new_password_value == rhs.new_password_value &&
         lhs.date_created == rhs.date_created &&
         lhs.date_last_used == rhs.date_last_used &&
         lhs.date_password_modified == rhs.date_password_modified &&
         lhs.blocked_by_user == rhs.blocked_by_user && lhs.type == rhs.type &&
         lhs.times_used == rhs.times_used &&
         lhs.form_data.SameFormAs(rhs.form_data) &&
         lhs.generation_upload_status == rhs.generation_upload_status &&
         lhs.display_name == rhs.display_name && lhs.icon_url == rhs.icon_url &&
         // We compare the serialization of the origins here, as we want unique
         // origins to compare as '=='.
         lhs.federation_origin.Serialize() ==
             rhs.federation_origin.Serialize() &&
         lhs.skip_zero_click == rhs.skip_zero_click &&
         lhs.was_parsed_using_autofill_predictions ==
             rhs.was_parsed_using_autofill_predictions &&
         lhs.is_public_suffix_match == rhs.is_public_suffix_match &&
         lhs.is_affiliation_based_match == rhs.is_affiliation_based_match &&
         lhs.affiliated_web_realm == rhs.affiliated_web_realm &&
         lhs.app_display_name == rhs.app_display_name &&
         lhs.app_icon_url == rhs.app_icon_url &&
         lhs.submission_event == rhs.submission_event &&
         lhs.only_for_fallback == rhs.only_for_fallback &&
         lhs.is_new_password_reliable == rhs.is_new_password_reliable &&
         lhs.in_store == rhs.in_store &&
         lhs.moving_blocked_for_list == rhs.moving_blocked_for_list &&
         lhs.password_issues == rhs.password_issues;
}

Chromium

V501 There are identical sub-expressions 'StandardFrameConstants::kCallerPCOffset' to the left and to the right of the '-' operator. linkage.h 90


static LinkageLocation ForCalleeFrameSlot(int32_t slot, MachineType type)
{
  // TODO(titzer): bailout instead of crashing here.
  DCHECK(slot >= 0 && slot < LinkageLocation::MAX_STACK_SLOT);
  return LinkageLocation(STACK_SLOT, slot, type);
}

static LinkageLocation ForSavedCallerReturnAddress()
{
  return ForCalleeFrameSlot((StandardFrameConstants::kCallerPCOffset
                           - StandardFrameConstants::kCallerPCOffset)
                           / kSystemPointerSize,
                             MachineType::Pointer());
}

FlipperZero

V501 [CWE-570] There are identical sub-expressions 'storage_type_is_not_valid(type_old)' to the left and to the right of the '||' operator. storage-processing.c 380


static FS_Error storage_process_common_rename(Storage* app, const char* old,
                                              const char* new)
{
  FS_Error ret = FSE_INTERNAL;
  StorageType type_old = storage_get_type_by_path(old);
  StorageType type_new = storage_get_type_by_path(new);

  if(storage_type_is_not_valid(type_old) || storage_type_is_not_valid(type_old))
  {
    ret = FSE_INVALID_NAME;
  }
  else
  ....
}

Ogre3D

V501 There are identical sub-expressions to the left and to the right of the '-' operator. Audacity voicekey.cpp 304


sampleCount VoiceKey::OnBackward (....) {
  ....
  int atrend = sgn(buffer[samplesleft - 2]-
                   buffer[samplesleft - 1]);
  int ztrend = sgn(buffer[samplesleft - WindowSizeInt-2]-
                   buffer[samplesleft - WindowSizeInt-2]);
  ....
}

A Copy-Paste error. In the last line 1 should be subtracted instead of 2.


DAW JSON Link

V501 [CWE-570] There are identical sub-expressions to the left and to the right of the '!=' operator: lhs.member1 != lhs.member1 cookbook_unknown_types_and_raw_parsing2_test.cpp 76


bool operator==( MyClass2 const &lhs, MyClass2 const &rhs ) {
  if( lhs.member0 != rhs.member0 or lhs.member1 != lhs.member1 ) {
    return false;
  }
  using namespace daw::json;
  return from_json<MyDelayedClass>( rhs.member_later ) ==
         from_json<MyDelayedClass>( rhs.member_later );
}

Similar errors can be found in some other places:

  • V501 [CWE-571] There are identical sub-expressions 'from_json < MyDelayedClass > (rhs.member_later)' to the left and to the right of the '==' operator. cookbook_unknown_types_and_raw_parsing2_test.cpp 80

LLVM/Clang

V501 [CWE-571] There are identical sub-expressions 'arrayAttr[0].cast < FloatAttr > ().getValue().isZero()' to the left and to the right of the '&&' operator. Merger.cpp 812


bool Merger::maybeZero(unsigned e) const {
  if (tensorExps[e].kind == kInvariant) {
    if (auto c = tensorExps[e].val.getDefiningOp<complex::ConstantOp>()) {
      ArrayAttr arrayAttr = c.getValue();
      return arrayAttr[0].cast<FloatAttr>().getValue().isZero() &&
             arrayAttr[0].cast<FloatAttr>().getValue().isZero();
    }
    if (auto c = tensorExps[e].val.getDefiningOp<arith::ConstantIntOp>())
      return c.value() == 0;
    if (auto c = tensorExps[e].val.getDefiningOp<arith::ConstantFloatOp>())
      return c.value().isZero();
  }
  return true;
}

LLVM/Clang

V501 [CWE-570] There are identical sub-expressions '(SrcTy.isPointer() && DstTy.isScalar())' to the left and to the right of the '||' operator. CallLowering.cpp 1198


static bool isCopyCompatibleType(LLT SrcTy, LLT DstTy) {
  if (SrcTy == DstTy)
    return true;

  if (SrcTy.getSizeInBits() != DstTy.getSizeInBits())
    return false;

  SrcTy = SrcTy.getScalarType();
  DstTy = DstTy.getScalarType();

  return (SrcTy.isPointer() && DstTy.isScalar()) ||
         (DstTy.isScalar() && SrcTy.isPointer());
}

LLVM/Clang

V501 [CWE-570] There are identical sub-expressions 'name == "__builtin_ieee_support_divide"' to the left and to the right of the '||' operator. fold-logical.cpp 218


template <int KIND>
Expr<Type<TypeCategory::Logical, KIND>> FoldIntrinsicFunction(....)
{
  ....
  } else if (name == "__builtin_ieee_support_datatype" ||
      name == "__builtin_ieee_support_denormal" ||
      name == "__builtin_ieee_support_divide" ||
      name == "__builtin_ieee_support_divide" ||
      name == "__builtin_ieee_support_inf" ||
      name == "__builtin_ieee_support_io" ||
      name == "__builtin_ieee_support_nan" ||
      name == "__builtin_ieee_support_sqrt" ||
      name == "__builtin_ieee_support_standard" ||
      name == "__builtin_ieee_support_subnormal" ||
      name == "__builtin_ieee_support_underflow_control") {
    return Expr<T>{true};
  }
  ....
}

LLVM/Clang

V501 [CWE-570] There are identical sub-expressions 'kind != ImportKind::Only' to the left and to the right of the '||' operator. scope.cpp 275


std::optional<parser::MessageFixedText> Scope::SetImportKind(ImportKind kind) {
  ....
  } else if (kind != *importKind_ &&
      (kind != ImportKind::Only || kind != ImportKind::Only)) {
    return
      "Every IMPORT must have ONLY specifier if one of them does"_err_en_US;
  } else {
  ....
}

LLVM/Clang

V501 [CWE-570] There are identical sub-expressions to the left and to the right of the '||' operator: !rhs ||!rhs ShapeUtils.h 141


static ValueKnowledge meet(const ValueKnowledge &lhs,
                           const ValueKnowledge &rhs) {
  ValueKnowledge result = getPessimisticValueState();
  result.hasError = true;

  if (!rhs || !rhs || lhs.dtype != rhs.dtype)
    return result;

  result.hasError = false;
  result.dtype = lhs.dtype;
  ....
}

Captain Blood

V501 [CWE-571] There are identical sub-expressions 'lleg.to >= 0' to the left and to the right of the '&&' operator. CharacterLegs.cpp 51


void CharacterLegs::Invalidate()
{
  lleg.th = ani->FindBone("Bedro_left_joint"  ,true);
  lleg.kn = ani->FindBone("Golen_left_joint"  ,true);
  lleg.fo = ani->FindBone("Foolt_left_joint"  ,true);
  lleg.to = ani->FindBone("Foolt_left_joint_2",true);

  rleg.th = ani->FindBone("Bedro_right_joint"  ,true);
  rleg.kn = ani->FindBone("Golen_right_joint"  ,true);
  rleg.fo = ani->FindBone( "Foot_right_joint"  ,true);
  rleg.to = ani->FindBone( "Foot_right_joint_2",true);

  if (   lleg.th >= 0 && lleg.kn >= 0
      && lleg.fo >= 0 && lleg.to >= 0
      && rleg.th >= 0 && rleg.kn >= 0
      && lleg.fo >= 0 && lleg.to >= 0 )
  {
    // ....
  }

  // ....
}

Similar errors can be found in some other places:

  • V501 [CWE-571] There are identical sub-expressions 'lleg.fo >= 0' to the left and to the right of the '&&' operator. CharacterLegs.cpp 51

VCMI

V501 There are identical sub-expressions to the left and to the right of the '&' operator: h & h Rect.h 158


template <typename Handler>
void serialize(Handler &h, const int version)
{
  h & x;
  h & y;
  h & w;
  h & h;
}

CodeLite

V501 There are identical sub-expressions 'result.second.empty()' to the left and to the right of the '||' operator. RemotyNewWorkspaceDlg.cpp:19


void RemotyNewWorkspaceDlg::OnBrowse(wxCommandEvent& event)
{
  auto result = ::clRemoteFileSelector(_("Seelct a folder"));
  if (result.second.empty() || result.second.empty())
  {
    return;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '!sshSettings.IsRemoteUploadEnabled()' to the left and to the right of the '||' operator. PhpSFTPHandler.cpp:104
  • V501 There are identical sub-expressions 'output.Contains("username for")' to the left and to the right of the '||' operator. git.cpp:1715

FreeCAD

V501 [CWE-570] There are identical sub-expressions 'mimeData->hasText()' to the left and to the right of the '||' operator. SheetTableView.cpp 1115


void SheetTableView::contextMenuEvent(QContextMenuEvent*)
{
  const QMimeData* mimeData = QApplication::clipboard()->mimeData();
  ....
  actionPaste->setEnabled(
    mimeData && (mimeData->hasText() || mimeData->hasText()));
  ....
}

GTK

V501 [CWE-570] There are identical sub-expressions to the left and to the right of the '||' operator: op == Sass_OP::DIV || op == Sass_OP::DIV operators.cpp 250


Value* op_color_number(enum Sass_OP op, ....)
{
  double rval = rhs.value();

  if ((op == Sass_OP::DIV || op == Sass_OP::DIV) && rval == 0) {
    // comparison of Fixnum with Float failed?
    throw Exception::ZeroDivisionError(lhs, rhs);
  }
  ....
}

Microsoft PowerToys

V501 There are identical sub-expressions '!m_reparent_event_handle' to the left and to the right of the '||' operator. main.cpp 191


int WINAPI wWinMain(....)
{
  // Start a thread to listen on the events.
  m_reparent_event_handle = CreateEventW(....);
  m_thumbnail_event_handle = CreateEventW(....);
  m_exit_event_handle = CreateEventW(....);
  if (   !m_reparent_event_handle
      || !m_reparent_event_handle
      || !m_exit_event_handle)
  {
    ....
  }
}

YTsaurus

V501 There are identical sub-expressions '(i32) LeapYearAD(RealYear())' to the left and to the right of the '-' operator. datetime.cpp:154:1


TSimpleTM& TSimpleTM::Add(EField f, i32 amount)
{
  ....
  case F_YEAR:
  {
    i32 y = amount + (i32)Year;
        y = ::Min<i32>(Max<i32>(y, 0), 255 /*max year*/);

    // YDay may correspond to different MDay if
    // it's March or greater and the years have different leap status
    if (Mon > 1)
    {
      YDay += (i32)LeapYearAD(RealYear()) - (i32)LeapYearAD(RealYear());
    }

    Year = y;
    IsLeap = LeapYearAD(RealYear());
    return RegenerateFields();
  }
  ....
}

YTsaurus

V501 There are identical sub-expressions 'lhs.CountByPoolTree.size()' to the left and to the right of the '!=' operator. structs.cpp:191


bool operator == (const TCompositePendingJobCount& lhs,
                  const TCompositePendingJobCount& rhs)
{
  if (lhs.DefaultCount != rhs.DefaultCount)
  {
    return false;
  }

  if (lhs.CountByPoolTree.size() != lhs.CountByPoolTree.size())
  {
    return false;
  }

  for (const auto& [tree, lhsCount] : lhs.CountByPoolTree)
  {
    ....
  }
  return true;
}

Qt Creator

V501 [CWE-571] There are identical sub-expressions to the left and to the right of the '&&' operator: d->m_maximumValue && d->m_maximumValue aspects.cpp 2198


void IntegerAspect::addToLayout(Layouting::LayoutItem &parent)
{
  QTC_CHECK(!d->m_spinBox);
  d->m_spinBox = createSubWidget<QSpinBox>();
  d->m_spinBox->setDisplayIntegerBase(d->m_displayIntegerBase);
  d->m_spinBox->setPrefix(d->m_prefix);
  d->m_spinBox->setSuffix(d->m_suffix);
  d->m_spinBox->setSingleStep(d->m_singleStep);
  d->m_spinBox->setSpecialValueText(d->m_specialValueText);
  if (d->m_maximumValue && d->m_maximumValue)
    d->m_spinBox->setRange(
      int(d->m_minimumValue.value() / d->m_displayScaleFactor),
      int(d->m_maximumValue.value() / d->m_displayScaleFactor)
    );

  // Must happen after setRange()
  d->m_spinBox->setValue(int(value() / d->m_displayScaleFactor));
  addLabeledItem(parent, d->m_spinBox);
  connect(d->m_spinBox.data(), &QSpinBox::valueChanged,
          this, &IntegerAspect::handleGuiChanged);
}

qdEngine

V501 There are identical sub-expressions 'QD_OBJ_STATE_CHANGE_FLAG' to the left and to the right of the '|' operator. qd_game_object.cpp 176


bool qdGameObject::init()
{
  drop_flag(QD_OBJ_SCREEN_COORDS_FLAG);

  drop_flag(QD_OBJ_STATE_CHANGE_FLAG | QD_OBJ_IS_IN_TRIGGER_FLAG |
            QD_OBJ_STATE_CHANGE_FLAG | QD_OBJ_IS_IN_INVENTORY_FLAG);

#ifndef _QUEST_EDITOR
  drop_flag(QD_OBJ_HIDDEN_FLAG);
#endif

  return true;
}

ReactOS

V501 There are identical sub-expressions 'DCDest->dctype == DCTYPE_INFO' to the left and to the right of the '||' operator. bitblt.c 64


BOOL APIENTRY
NtGdiAlphaBlend(....)
{
  PDC DCDest;
  PDC DCSrc;
  ....
  if (DCDest->dctype == DCTYPE_INFO || DCDest->dctype == DCTYPE_INFO)  // <=
  {
    GDIOBJ_vUnlockObject(&DCSrc->BaseObject);
    GDIOBJ_vUnlockObject(&DCDest->BaseObject);
    /* Yes, Windows really returns TRUE in this case */
    return TRUE;
  }
  ....
}

LLVM/Clang

V501 There are identical sub-expressions 'FirstStmt->getStmtClass()' to the left and to the right of the '!=' operator. ASTUtils.cpp:99


bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt,
                            const ASTContext &Context, bool Canonical)
{
  ....

  if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass())
    return false;
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions to the left and to the right of the '!=' operator: Fn1->isVariadic() != Fn1->isVariadic(). SemaOverload.cpp:10190
  • V501 There are identical sub-expressions to the left and to the right of the '<' operator: G1->Rank < G1->Rank. SCCIterator.h:285
  • V501 There are identical sub-expressions 'slice1.getMixedOffsets().size()' to the left and to the right of the '==' operator. ValueBoundsOpInterface.cpp:581
  • And 14 additional diagnostic messages.

OpenVINO

V501 There are identical sub-expressions 'std::any_of(pad_begin.begin(), pad_begin.end(), pred)' to the left and to the right of the '||' operator. convert_pad_to_group_conv.cpp 66


ov::pass::ConvertPadToGroupConvolution::
                       ConvertPadToGroupConvolution()
{
  ....
  const auto& pad_begin = pad->get_pads_begin();
  const auto& pad_end = pad->get_pads_end();

  if (pad_begin.empty() || pad_end.empty())
  {
    // pads will be empty if inputs are not constants
    return false;
  }

  // check that Pad has non-negative values
  auto pred = [](int64_t a)
              {
                return a < 0;
              };
  if (std::any_of(pad_begin.begin(), pad_begin.end(), pred) ||
      std::any_of(pad_begin.begin(), pad_begin.end(), pred))
  {
    return false;
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions '!reshape_after' to the left and to the right of the '||' operator. shuffle_channels_fusion.cpp 115

OpenVINO

V501 There are identical sub-expressions 'isa == x64::avx512_core' to the left and to the right of the '||' operator. jit_eltwise_emitters.cpp 705


template <x64::cpu_isa_t isa>
void jit_power_dynamic_emitter::
              emit_isa(const std::vector<size_t> &in_vec_idxs,
                       const std::vector<size_t> &out_vec_idxs) const
{
  ....
  if (isa == x64::avx512_core || isa == x64::avx512_core)
  {
    h->sub(h->rsp, n_k_regs_to_save * k_mask_size);
    for (size_t i = 0; i < n_k_regs_to_save; ++i)
    {
      if (x64::mayiuse(x64::avx512_core))
        h->kmovq(h->ptr[h->rsp + i * k_mask_size], Opmask(i));
      else
        h->kmovw(h->ptr[h->rsp + i * k_mask_size], Opmask(i));
    }
  }
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'isa == x64::avx512_core' to the left and to the right of the '||' operator. jit_eltwise_emitters.cpp 754
  • V501 There are identical sub-expressions 'isa == x64::avx512_core' to the left and to the right of the '||' operator. jit_eltwise_emitters.cpp 1609
  • V501 There are identical sub-expressions 'isa == x64::avx512_core' to the left and to the right of the '||' operator. jit_eltwise_emitters.cpp 1658

OpenVINO

V501 There are identical sub-expressions 'jcp.l_pad <= jcp.ur_w' to the left and to the right of the '&&' operator. bin_conv.cpp 1088


void BinaryConvolution::createPrimitive()
{
  ....
   bool args_ok = jcp.l_pad <= jcp.ur_w &&
          (r_pad_no_tail <= jcp.ur_w) && (jcp.l_pad <= jcp.ur_w) &&
            IMPLICATION(jcp.kw > 7, (jcp.t_pad == 0 && jcp.l_pad == 0) ||
              (jcp.stride_w == 1 && jcp.stride_h == 1));
  ....
}

OpenVINO

V501 There are identical sub-expressions 'state->get_element_type()' to the left and to the right of the '==' operator. variable_state.hpp 23


void set_state(const ov::SoPtr<ov::ITensor>& state) override
{
  OPENVINO_ASSERT(state->get_shape() ==
                           m_state->get_shape(),
                              "Wrong tensor shape.");
  OPENVINO_ASSERT(state->get_element_type() ==
                           state->get_element_type(),
                              "Wrong tensor type."   );
  OPENVINO_ASSERT(state->get_byte_size() ==
                           state->get_byte_size(),
                              "Blob size of tensors are not equal.");
  std::memcpy(m_state->data(), state->data(), state->get_byte_size());
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'state->get_byte_size()' to the left and to the right of the '==' operator. variable_state.hpp 24

Godot Engine

V501 There are identical sub-expressions 'RenderingServer::ARRAY_FORMAT_VERTEX' to the left and to the right of the '|' operator. mesh_storage.cpp 1414


void MeshStorage::update_mesh_instances()
{
  ....
  uint64_t mask = RS::ARRAY_FORMAT_VERTEX | RS::ARRAY_FORMAT_NORMAL
                | RS::ARRAY_FORMAT_VERTEX;
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'RenderingServer::ARRAY_FORMAT_VERTEX' to the left and to the right of the '|' operator. mesh_storage.cpp 1300

DPDK

V501 There are identical sub-expressions '(flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE)' to the left and to the right of the '||' operator. test_cryptodev.c 12173


static int
test_tls_record_proto_all(const struct tls_record_test_flags *flags)
{
  ....
  if (flags->zero_len &&
      ((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
      (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
      (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE))) {
    if (ret == TEST_SUCCESS)
      return TEST_FAILED;
    goto skip_decrypt;
  }
  ....
}

DPDK

V501 There are identical sub-expressions 'w2->s.enc_type == ROC_IE_OT_SA_ENC_AES_CCM' to the left and to the right of the '||' operator. cnxk_security.c 177


static int
ot_ipsec_sa_common_param_fill(....)
{
  ....
  if (w2->s.enc_type == ROC_IE_OT_SA_ENC_AES_CBC ||
      w2->s.enc_type == ROC_IE_OT_SA_ENC_AES_CCM ||
      w2->s.enc_type == ROC_IE_OT_SA_ENC_AES_CTR ||
      w2->s.enc_type == ROC_IE_OT_SA_ENC_AES_GCM ||
      w2->s.enc_type == ROC_IE_OT_SA_ENC_AES_CCM ||
      w2->s.auth_type == ROC_IE_OT_SA_AUTH_AES_GMAC) {
  ....
}

Similar errors can be found in some other places:

  • V501 There are identical sub-expressions 'ctl->enc_type == ROC_IE_ON_SA_ENC_AES_CCM' to the left and to the right of the '||' operator. cnxk_security.c 885

LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '==' operator: lowerBound[0] == lowerBound[0] ScalableValueBoundsConstraintSet.cpp 110


FailureOr<ConstantOrScalableBound>
ScalableValueBoundsConstraintSet::computeScalableBound(....)
{
  ....
  SmallVector<AffineMap, 1> lowerBound(1), upperBound(1);
  scalableCstr.cstr.getSliceBounds(pos, 1, value.getContext(), &lowerBound,
                                   &upperBound, closedUB);

  auto invalidBound = [](auto &bound) {
    return !bound[0] || bound[0].getNumResults() != 1;
  };

  AffineMap bound = [&] {
    if (boundType == BoundType::EQ && !invalidBound(lowerBound) &&
        lowerBound[0] == lowerBound[0]) {                                 // <=
      return lowerBound[0];
    } else if (boundType == BoundType::LB && !invalidBound(lowerBound)) {
      return lowerBound[0];
    } else if (boundType == BoundType::UB && !invalidBound(upperBound)) {
      return upperBound[0];
    }
    return AffineMap{};
  }();
  ....
}

LLVM/Clang

V501 There are identical sub-expressions 'isInteger(arg1)' to the left and to the right of the '&&' operator. LinalgOps.cpp 502


Value buildTernaryFn(TernaryFn ternaryFn, Value arg0, Value arg1,
                     Value arg2) {
  bool headBool =
      isInteger(arg0) && arg0.getType().getIntOrFloatBitWidth() == 1;
  bool tailFloatingPoint =
      isFloatingPoint(arg0) && isFloatingPoint(arg1) && isFloatingPoint(arg2);
  bool tailInteger = isInteger(arg0) && isInteger(arg1) && isInteger(arg1);
  OpBuilder::InsertionGuard g(builder);
  builder.setInsertionPointToEnd(&block);
  ....
}

LLVM/Clang

V501 There are identical sub-expressions 'Mnemonic != "vqmovnt"' to the left and to the right of the '&&' operator. ARMAsmParser.cpp 6633


StringRef ARMAsmParser::splitMnemonic(StringRef Mnemonic, ....) {
  ....
  if (isMnemonicVPTPredicable(Mnemonic, ExtraToken) && Mnemonic != "vmovlt" &&
      Mnemonic != "vshllt" && Mnemonic != "vrshrnt" && Mnemonic != "vshrnt" &&
      Mnemonic != "vqrshrunt" && Mnemonic != "vqshrunt" &&
      Mnemonic != "vqrshrnt" && Mnemonic != "vqshrnt" && Mnemonic != "vmullt" &&
      Mnemonic != "vqmovnt" && Mnemonic != "vqmovunt" &&
      Mnemonic != "vqmovnt" && Mnemonic != "vmovnt" && Mnemonic != "vqdmullt" &&
      Mnemonic != "vpnot" && Mnemonic != "vcvtt" && Mnemonic != "vcvt") {
  ....
}

LLVM/Clang

V501 There are identical sub-expressions to the left and to the right of the '&&' operator: bits2.is_nan() && bits2.is_nan() Compare.h 23


template <typename T>
LIBC_NAMESPACE::cpp::enable_if_t<LIBC_NAMESPACE::cpp::is_floating_point_v<T>,
                                 bool>
ValuesEqual(T x1, T x2) {
  LIBC_NAMESPACE::fputil::FPBits<T> bits1(x1);
  LIBC_NAMESPACE::fputil::FPBits<T> bits2(x2);
  // If either is NaN, we want both to be NaN.
  if (bits1.is_nan() || bits2.is_nan())
    return bits2.is_nan() && bits2.is_nan();

  // For all other values, we want the values to be bitwise equal.
  return bits1.uintval() == bits2.uintval();
}

LLVM/Clang

V501 There are identical sub-expressions 'OpenACCDevicePtrClause::classof(C)' to the left and to the right of the '||' operator. OpenACCClause.cpp 31


bool OpenACCClauseWithVarList::classof(const OpenACCClause *C) {
  return OpenACCPrivateClause::classof(C) ||
         OpenACCFirstPrivateClause::classof(C) ||
         OpenACCDevicePtrClause::classof(C) ||
         OpenACCDevicePtrClause::classof(C) ||
         OpenACCAttachClause::classof(C) || OpenACCNoCreateClause::classof(C) ||
         OpenACCPresentClause::classof(C) || OpenACCCopyClause::classof(C) ||
         OpenACCCopyInClause::classof(C) || OpenACCCopyOutClause::classof(C) ||
         OpenACCReductionClause::classof(C) || OpenACCCreateClause::classof(C);
}