Examples of errors detected by the V501 diagnostic.

V501. There are identical sub-expressions to the left and to the right of the '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);
  }
  ...
}

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

Identical 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


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


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

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


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]).


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

Identical 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

V501 There are identical sub-expressions '(!gameon && gamestarted)' 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;
  }
  ...
}

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

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


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.


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

Identical 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


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.


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


Clang

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

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


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

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()).


Clang

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

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

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

V501 There are identical sub-expressions to the left and to the right of the '==' operator: Src2.DoubleVal == Src2.DoubleVal LLVMInterpreter execution.cpp 429


static GenericValue executeFCMP_ORD(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;
}

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

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


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

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


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.


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.


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

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

Identical 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))".

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

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.


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

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


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

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

Identical 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

MAME

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

V501 There are identical sub-expressions 'offset != (0x3c0 >> 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)
  )
  ...
}

Identical errors can be found in some other places:

  • 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

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

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

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


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;


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

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

Identical 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

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


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

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

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

Identical 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) && ....)
  ....
}

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

Identical 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;
}

Identical 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

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


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

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

Identical 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

V501 There are identical sub-expressions '(float) nScreenHeight' 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 );
  ....
}

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

  ....
}

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

Identical 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()) {
  ....
}

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

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

Identical 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()) )
  ....
}

Identical 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

V501 There are identical sub-expressions 'p->nToken > 0' 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
  );
  ....
}

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

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

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

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

Identical 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

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

A check for the 'pModel' pointer is most likely missing as it is pointers passed into the function that are checked in this fragment.

Identical 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                // <= 1
                        | DECODE_VARARG
                        | DECODE_PSP_SYM                // <= 1
                        | DECODE_GENERICS_INST_CONTEXT  // <= 2
                        | DECODE_GC_LIFETIMES
                        | DECODE_GENERICS_INST_CONTEXT  // <= 2
                        | DECODE_PROLOG_LENGTH),
   0);
  ....
}

Identical 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)))
  {
    ....
  }
  ....
}

Identical 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")
   {
     ....
   }
  ....
}

Identical 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;
}

Identical 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"))
  {
  ....
}

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

Identical 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) {
    ....
  }
  ....
}

Identical 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;
}

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

Identical 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) {
  ....
}

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

Identical 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))
  {
    ....
  }
  ....
}

Identical 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);   //<=
}

Identical 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;     // <=
}

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.


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

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

Identical 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

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

Identical 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


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;