Examples of errors detected by the V517 diagnostic.

V517. The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence.


EIB Suite

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. GSM gsm_sms_codec.cc 175


string TimePeriod::toString() const
{
  ...
  if (_relativeTime <= 143)
    os << ((int)_relativeTime + 1) * 5 << _(" minutes");
  else if (_relativeTime <= 167)
    os << 12 * 60 + ((int)_relativeTime - 143) *
                    30 << _(" minutes");
  else if (_relativeTime <= 196)
    os << (int)_relativeTime - 166 << _(" days");
  else if (_relativeTime <= 143)
    os << (int)_relativeTime - 192 << _(" weeks");
  ...
}

The (_relativeTime <= 143) check is repeated twice.


Ultimate Toolbox

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. UT oxprocess.h 583


inline COXProcessIterator& operator+(int nOffset)
{
  if(nOffset>0)
    Next(nOffset);
  else if(nOffset>0)
    Prev(-nOffset);
  return *this;
}

The V517 warning points at an error in the program logic. The "Prev(-nOffset);" branch will never be executed.

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. UT oxprocess.h 596
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. UT oxprocess.h 610
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. UT oxprocess.h 624

TickerTape

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. TickerTape wind.cpp 118


void GetWindAtSingleTornado(....)
{
  ...
  if(radius < THRESH * 5)                      // <=
      *yOut = THRESH * 10 / radius;
  else if (radius < THRESH * 5)                // <=
      *yOut = -3.0f / (THRESH * 5.0f) *
              (radius - THRESH * 5.0f) + 3.0f;
  else
      *yOut = 0.0f;
  ...
}

TickerTape

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. TickerTape dxut.cpp 6217


void DXUTUpdateD3D10DeviceStats(....)
{
  ...
  else if( DeviceType == D3D10_DRIVER_TYPE_SOFTWARE )  // <=
    wcscpy_s( pstrDeviceStats, 256, L"WARP" );
  else if( DeviceType == D3D10_DRIVER_TYPE_HARDWARE )
    wcscpy_s( pstrDeviceStats, 256, L"HARDWARE" );
  else if( DeviceType == D3D10_DRIVER_TYPE_SOFTWARE )  // <=
    wcscpy_s( pstrDeviceStats, 256, L"SOFTWARE" );
  ...
}

SAGA GIS

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 697, 700. ta_channels watersheds_ext.cpp 697


CSG_String CWatersheds_ext::GraveliusType(....) {
  ...
  if (fGraveliusIndex > 1.75) {
    sType = "Rectangular";
  }
  else if (fGraveliusIndex > 1.5) {             // <=
    sType = "Ovalooblonga-rectangularoblonga";
  }
  else if (fGraveliusIndex > 1.5) {             // <=
    sType = "Ovaloredonda-ovalooblonga";
  }
  else {
    sType = "Redonda-ovaloredonda";
  }
  ...
}

ICU

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 800, 808. icui18n msgfmt.cpp 800


UnicodeString&
MessageFormat::toPattern(UnicodeString& appendTo) const {
  ...
  else if (formatAlias == *defaultTimeTemplate) {
    appendTo += ID_TIME;
  }
  ...
  else if (formatAlias == *defaultTimeTemplate) {
    appendTo += ID_TIME;
    appendTo += COMMA;
    appendTo += ID_MEDIUM;
  }
  ...
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 777, 785. icui18n msgfmt.cpp 777

Libwebpdecode

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 353, 355. libwebp frame.c 353


void VP8ReconstructBlock(VP8Decoder* const dec) {
  ...
  if (dec->non_zero_ & (1 << n)) {
    VP8Transform(coeffs + n * 16, dst);
  } else if (dec->non_zero_ & (1 << n)) {
    VP8TransformDC(coeffs + n * 16, dst);
  }
  ...
}

Qt

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 230, 233. QtGui qtextcontrol.cpp 230


bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
{
  ...
  else if (e == QKeySequence::MoveToNextLine) {
    op = QTextCursor::Down;
  }
  else if (e == QKeySequence::MoveToPreviousLine) {  // <=
    op = QTextCursor::Up;
  }
  else if (e == QKeySequence::MoveToPreviousLine) {  // <=
    op = QTextCursor::Up;
  }
  else if (e == QKeySequence::MoveToStartOfLine) {
    op = QTextCursor::StartOfLine;
  ...
}

Qt

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 504, 508. QtMultimedia qvideosurfaceformat.cpp 504


QVariant QVideoSurfaceFormat::property(const char *name) const
{
  if (qstrcmp(name, "handleType") == 0) {         // <=
    return qVariantFromValue(d->handleType);
  } else if (qstrcmp(name, "pixelFormat") == 0) {
    return qVariantFromValue(d->pixelFormat);
  } else if (qstrcmp(name, "handleType") == 0) {  // <=
    return qVariantFromValue(d->handleType);
  } else if (qstrcmp(name, "frameSize") == 0) {
  ...
}

Qt

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 2303, 2305. lrelease profileevaluator.cpp 2303


QStringList ProFileEvaluator::Private::values(....)
{
  ...
  else if (ver == QSysInfo::WV_NT)
    ret = QLatin1String("WinNT");
  else if (ver == QSysInfo::WV_2000)
    ret = QLatin1String("Win2000");
  else if (ver == QSysInfo::WV_2000)  // <= 2003 !
    ret = QLatin1String("Win2003");
  else if (ver == QSysInfo::WV_XP)
    ret = QLatin1String("WinXP");
  ...
}

TrueCrypt

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 7477, 7523. Format tcformat.c 7477


BOOL CALLBACK PageDialogProc(....)
{
  ...
  else if (nCurPageNo == HIDDEN_VOL_HOST_PRE_CIPHER_PAGE)
  ...
  else if (nCurPageNo == HIDDEN_VOL_HOST_PRE_CIPHER_PAGE)
  ...
}

ReactOS

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1190, 1198. setupapi devclass.c 1190


BOOL WINAPI
SetupDiGetClassDevPropertySheetsW(....)
{
  ...
  else if (!PropertySheetHeader)               // <=
    SetLastError(ERROR_INVALID_PARAMETER);

  else if (PropertySheetHeader->dwFlags & PSH_PROPSHEETPAGE)
    ...

  else if (!PropertySheetHeader)
    SetLastError(ERROR_INVALID_PARAMETER);     // <=
  ...
}

ReactOS

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 177, 182. mmixer filter.c 177


ULONG
MMixerGetControlTypeFromTopologyNode(IN LPGUID NodeType)
{
  ...
  else if (IsEqualGUIDAligned(NodeType,
                              (LPGUID)&KSNODETYPE_MUX))
  {
    /* mux control */
    return MIXERCONTROL_CONTROLTYPE_MUX;
  }
  else if (IsEqualGUIDAligned(NodeType,
                              (LPGUID)&KSNODETYPE_MUX))
  {
    /* mux control */
    return MIXERCONTROL_CONTROLTYPE_MUX;
  }
  ...
}

Chromium

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 2520, 2522. osmesa meta.c 2520


static GLenum
get_temp_image_type(GLcontext *ctx, GLenum baseFormat)
{
  ...
  if (ctx->DrawBuffer->Visual.redBits <= 8)       // <=
     return GL_UNSIGNED_BYTE;
  else if (ctx->DrawBuffer->Visual.redBits <= 8)  // <=
     return GL_UNSIGNED_SHORT;
  else
     return GL_FLOAT;
  ...
}

Chromium

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1324, 1327. media_file media_file_utility.cc 1324


WebRtc_Word32 ModuleFileUtility::UpdateWavHeader(OutStream& wav)
{
  ...
  if(STR_CASE_CMP(codec_info_.plname, "L16") == 0)
  {
     res = WriteWavHeader(wav, codec_info_.plfreq, 2, channels,
                         kWaveFormatPcm, _bytesWritten);
  }
  else if(STR_CASE_CMP(codec_info_.plname, "PCMU") == 0) // <=
  {
     res = WriteWavHeader(wav, 8000, 1, channels,
                          kWaveFormatMuLaw, _bytesWritten);
  }
  else if(STR_CASE_CMP(codec_info_.plname, "PCMU") == 0) // <=
  {
     res = WriteWavHeader(wav, 8000, 1, channels,
                          kWaveFormatALaw, _bytesWritten);
  } else {
    return 0;
  }
  return res;
}

Chromium

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 61, 63. browser content_settings_origin_identifier_value_map.cc 61


enum ContentSettingsType;
struct EntryMapKey {
  ContentSettingsType content_type;
  ...
};

bool OriginIdentifierValueMap::EntryMapKey::operator<(
    const OriginIdentifierValueMap::EntryMapKey& other) const {
  if (content_type < other.content_type)
    return true;
  else if (other.content_type > content_type)
    return false;
  return (resource_identifier < other.resource_identifier);
}

Most likely this is what should be written here: if (content_type > other.content_type) return false.


Doom 3

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 524, 533. Game anim_blend.cpp 524


const char *idAnim::AddFrameCommand(....)
{
  ...
  } else if ( token == "muzzle_flash" ) {
  ...
  } else if ( token == "muzzle_flash" ) {
  ...
}

Doom 3

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 364, 402. DoomDLL model_liquid.cpp 364


void idRenderModelLiquid::InitFromFile(....)
{
  ...
  if ( !token.Icmp( "seed" ) ) {
  ...
  } else if ( !token.Icmp( "seed" ) ) {
  ...
}

Quake-III-Arena

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 3333, 3335. Radiant mainfrm.cpp 3333


void CMainFrame::OnClipSelected()
{
  ...
  if (g_bPatchBendMode)
    Patch_BendHandleENTER();
  else if (g_bPatchBendMode)
    Patch_InsDelHandleENTER();
  ...
}

Notepad++

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 130, 133. lexvhdl.cxx 130


static void ColouriseVHDLDoc(....)
{
  ...
  } else if (sc.Match('-', '-')) {    // <=
    sc.SetState(SCE_VHDL_COMMENT);
    sc.Forward();
  } else if (sc.Match('-', '-')) {    // <=
    if (sc.Match("--!"))
      sc.SetState(SCE_VHDL_COMMENTLINEBANG);
    else
      sc.SetState(SCE_VHDL_COMMENT);
  }
  ...
}

MAME

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 549, 579. cdrom.c 549


static void cdrom_get_info_from_type_string(....)
{

  ...
  else if (!strcmp(typestring, "MODE2/2336"))
  {
    *trktype = CD_TRACK_MODE2;
    *datasize = 2336;
  }
  ...
  else if (!strcmp(typestring, "MODE2/2336"))
  {
    *trktype = CD_TRACK_MODE2_FORM_MIX;
    *datasize = 2336;
  }
  ...
}

MAME

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 577, 584. tms7000.c 577


static WRITE8_HANDLER( tms70x0_pf_w )
{
  ...
  if( ((cpustate->pf[0x03] & 0x80) == 0) &&
      ((data & 0x80) == 0x80 ) )
  {
    ...
  }
  else if( ((data & 0x80) == 0x80 ) &&
           ((cpustate->pf[0x03] & 0x80) == 0) )
  {
    ...
  }
  ...
}

Visualization Toolkit (VTK)

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 224, 227. lproj lproj.c 224


static void vprocess(FILE *fid) {
  char *s;
  ...
  if (*s == 'I' || *s == 'i') {         // <=
    linvers = 1;
    ++s;
  } else if (*s == 'I' || *s == 'i') {  // <=
    linvers = 0;
    ++s;
  } else
  ...
}

Tor

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 547, 561. nodelist.c 547


const node_t *
node_get_by_nickname(const char *nickname, int warn_if_unnamed)
{
  ....
  if (smartlist_len(matches)>1 && warn_if_unnamed) {
    ....
  } else if (smartlist_len(matches)>1 && warn_if_unnamed) {
  ....
}

ReactOS

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1193, 1195. locale.c 1193


#define LOCALE_SSHORTDATE 31
#define LOCALE_SLONGDATE 32

MSVCRT__locale_t CDECL MSVCRT__create_locale(....)
{
  ....
  if (time_data[i]==
      LOCALE_SSHORTDATE && !lcid[LC_TIME]) {
    size += ....;
  } else if(time_data[i]==
            LOCALE_SSHORTDATE && !lcid[LC_TIME]) {
    size += ....;
  } else {
  ....
}

Most likely this is what should be written here: else if (time_data[i]==LOCALE_SLONGDATE && !lcid[LC_TIME])

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1225, 1228. locale.c 1225
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1241, 1244. locale.c 1241

Windows 8 Driver Samples

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 5641, 5645. sensor.cpp 5641


HRESULT CSensor::HandleSetReportingAndPowerStates(....)
{
  ....
  else if (SENSOR_POWER_STATE_LOW_POWER == ulCurrentPowerState)
  {
    Trace(TRACE_LEVEL_ERROR,
      "%s Power State value is not correct = LOW_POWER, "
      "hr = %!HRESULT!", m_SensorName, hr);
  }
  else if (SENSOR_POWER_STATE_LOW_POWER == ulCurrentPowerState)
  {
    Trace(TRACE_LEVEL_ERROR,
      "%s Power State value is not correct = FULL_POWER, "
      "hr = %!HRESULT!", m_SensorName, hr);
  }
  ....
}

WebRTC

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 680, 735. acm_codec_database.cc 680


ACMGenericCodec* ACMCodecDB::CreateCodecInstance(....) {
  ....
  } else if (!STR_CASE_CMP(codec_inst->plname, "CN")) {
    int codec_id;
    switch (codec_inst->plfreq) {
      ....
  } else if ....
  ....
  } else if (!STR_CASE_CMP(codec_inst->plname, "CN")) {
    int codec_id;
    switch (codec_inst->plfreq) {
  ....
}

Skia Graphics Engine

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 301, 311. skobjectparser.cpp 301


SkString*
SkObjectParser::SaveFlagsToString(SkCanvas::SaveFlags flags)
{
  SkString* mFlags = new SkString("SkCanvas::SaveFlags: ");

  if(flags == SkCanvas::kMatrixClip_SaveFlag) {
    mFlags->append("kMatrixClip_SaveFlag");
  ....
  } else if (flags == SkCanvas::kMatrixClip_SaveFlag) {
    mFlags->append("kMatrixClip_SaveFlag");
  ....
}

Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 227, 229. G4navigation g4propagatorinfield.cc 227


G4double
G4PropagatorInField::ComputeStep(
                G4FieldTrack&      pFieldTrack,
                G4double           CurrentProposedStepLength,
                G4double&          currentSafety, // IN/OUT
                G4VPhysicalVolume* pPhysVol)
{
  ....
  if( stepTrial > 100.0*fZeroStepThreshold )
    decreaseFactor = 0.35;     // Try decreasing slower
  else if( stepTrial > 100.0*fZeroStepThreshold )
    decreaseFactor= 0.5;       // Try yet slower decreases
  else if( stepTrial > 10.0*fZeroStepThreshold )
    decreaseFactor= 0.75;      // Try even slower decreases
  else
    decreaseFactor= 0.9;       // Try very slow decreases
  ....
}

Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 207, 211. G4mctruth g4persistencycentermessenger.cc 207


G4String G4PersistencyCenterMessenger::GetCurrentValue(
  G4UIcommand* command)
{
  G4String s="Undefined";

  if (command==select)
  {
    return pc->VerboseLevel();
  }
  else if (command==select)
  {
    return pc->CurrentSystem();
  }
  else if (command==regHitIO)
  {
  ....
}

Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 8373, 8380. G4hadronic_body_ci g4qenvironment.cc 8373


void G4QEnvironment::DecayBaryon(G4QHadron* qH)
{
  ....
  else if(qM<mSzPi) // Only Lambda+PiM is possible
  {
    fQPDG=lQPDG;    // Baryon is Lambda
    fMass=mLamb;
    sQPDG=pimQPDG;  // Meson is Pi-
    sMass=mPi;
  }
  else if(qM<mSzPi) // Both Lambda+PiM & Sigma0+PiM are possible
  {
    if(G4UniformRand()<.6)
    {
  ....
}

Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 680, 684. G4geomtext g4tgbvolume.cc 680


G4VSolid* G4tgbVolume::FindOrConstructG4Solid(
  const G4tgrSolid* sol )
{
  ....
  if( solParam[jj+11] == 0 )
  {
    vertexType = ABSOLUTE;
  }
  else if( solParam[jj+11] == 0 )
  {
    vertexType = RELATIVE;
  }
  else
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 707, 711. G4geomtext g4tgbvolume.cc 707

Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 209, 212. G4specsolids g4polyhedra.cc 209


void G4Polyhedra::Create( G4double phiStart,
                          G4double phiTotal,
                          G4int    theNumSide,
                          G4ReduciblePolygon *rz  )
{
  ....
  G4double rzArea = rz->Area();
  if (rzArea < -kCarTolerance)
    rz->ReverseOrder();

  else if (rzArea < -kCarTolerance)
  {
    G4cerr << "ERROR - G4Polyhedra::Create() "
           << GetName() << G4endl
           << "        R/Z cross section is zero or near zero: "
           << rzArea << G4endl;
    G4Exception("G4Polyhedra::Create()", "InvalidSetup",
                FatalException, "Illegal input parameters.");
  }
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 165, 168. G4specsolids g4polycone.cc 165

Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 793, 802. G4specsolids g4vtwistsurface.cc 793


void G4VTwistSurface::GetBoundaryLimit(G4int areacode,
                                       G4double limit[]) const
{
  ....
  if (areacode & sC0Min1Max) {
     limit[0] = fAxisMin[0];
     limit[1] = fAxisMin[1];
  } else if (areacode & sC0Max1Min) {
     limit[0] = fAxisMax[0];
     limit[1] = fAxisMin[1];
  } else if (areacode & sC0Max1Max) {
     limit[0] = fAxisMax[0];
     limit[1] = fAxisMax[1];
  } else if (areacode & sC0Min1Max) {
     limit[0] = fAxisMin[0];
     limit[1] = fAxisMax[1];
  }
  ....
}

Most likely this is what should be written here: if (areacode & sC0Min1Min) { limit[0] = fAxisMin[0]; limit[1] = fAxisMin[1]; }


Geant4 software

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 195, 196. G4phys_builders g4qmessenger.cc 195


void G4QMessenger::SetNewValue(G4UIcommand* aComm, G4String aS)
{
  if(photoDir)
  {
    if     (aComm==theSynchR) thePhoto->SetSynchRadOnOff(aS);
    else if(aComm==minGamSR)  thePhoto->SetMinGammaSR(....
    else if(aComm==theGamN)   thePhoto->SetGammaNuclearOnOff(aS);
    else if(aComm==theMuoN)   thePhoto->SetElPosNuclearOnOff(aS);
    else if(aComm==theMuoN)   thePhoto->SetMuonNuclearOnOff(aS);
    else if(aComm==theMuoN)   thePhoto->SetTauNuclearOnOff(aS);
    else if(aComm==biasPhotoN)thePhoto->SetPhotoNucBias(....
  }
  ....
}

CryEngine 3 SDK

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 610, 612. movementtransitions.cpp 610


#define MovementTransitionsLog if (false) CryLog

STransitionSelectionParams::STransitionSelectionParams(....)
{
  ....
  if (!(allowedTransitionFlags & (1<<eTT_Start)))
    MovementTransitionsLog(....);
  else
    MovementTransitionsLog(....);
  ....
}

CryEngine 3 SDK

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 255, 261. vicinitydependentobjectmover.cpp 255


void CVicinityDependentObjectMover::HandleEvent(....)
{
  ....
  else if ( strcmp(szEventName, "ForceToTargetPos") == 0 )
  {
    SetState(eObjectRangeMoverState_MovingTo);
    SetState(eObjectRangeMoverState_Moved);
    ActivateOutputPortBool( "OnForceToTargetPos" );
  }
  else if ( strcmp(szEventName, "ForceToTargetPos") == 0 )
  {
    SetState(eObjectRangeMoverState_MovingTo);
    SetState(eObjectRangeMoverState_Moved);
    ActivateOutputPortBool( "OnForceToTargetPos" );
  }
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 964, 968. environmentalweapon.cpp 964
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 610, 617. persistantstats.cpp 610
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 714, 721. persistantstats.cpp 714
  • And 1 additional diagnostic messages.

Micro-Manager

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1455, 1457. LeicaDMR.cpp 1455


const char* g_Out = "Out";

int FieldDiaphragm::OnCondensor(....)
{
  ....
  std::string value;
  ....
  if (value == g_Out)
    return
      g_hub.SetCondensorPosition(*this, *GetCoreCallback(), 0);
  else if (value == g_Out)
    return
      g_hub.SetCondensorPosition(*this, *GetCoreCallback(), 1);
  ....
}

Micro-Manager

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 645, 654. Ludl.cpp 645


class Wheel : public CStateDeviceBase<Wheel>
{
  ....
  unsigned wheelNumber_;
  ....
};

int Wheel::SetWheelPosition(int position)
{
  unsigned char cmd[4];
  cmd[0] = moduleId_; cmd[2] = 0; cmd[3] = 58;
  if (wheelNumber_ == 1) {
    switch (position) {
      case 0: cmd[1] = 49; break;
      case 1: cmd[1] = 50; break;
      case 2: cmd[1] = 51; break;
      case 3: cmd[1] = 52; break;
      case 4: cmd[1] = 53; break;
      case 5: cmd[1] = 54; break;
    }
  } else if (wheelNumber_ == 1) {
    switch (position) {
      case 0: cmd[1] = 33; break;
      case 1: cmd[1] = 64; break;
      case 2: cmd[1] = 35; break;
      case 3: cmd[1] = 36; break;
      case 4: cmd[1] = 37; break;
      case 5: cmd[1] = 94; break;
    }
  ....
}

FFmpeg

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 881, 884. imc.c 881


static int imc_decode_block(....)
{
  ....
  if (stream_format_code & 0x1)
    imc_decode_level_coefficients_raw(....);
  else if (stream_format_code & 0x1)
    imc_read_level_coeffs_raw(....);
  ....
}

Scilab

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 175, 398. sci_xset.c 175


int sci_xset( char *fname, unsigned long fname_len )
{
  ....
  else if ( strcmp(cstk(l1), "mark size") == 0)
  ....
  else if ( strcmp(cstk(l1), "mark") == 0)
  ....
  ....
  else if ( strcmp(cstk(l1), "mark") == 0)
  ....
  else if ( strcmp(cstk(l1), "colormap") == 0)
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 159, 405. sci_xset.c 159
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1148, 1152. h5_readdatafromfile_v1.c 1148
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1010, 1014. h5_readdatafromfile.c 1010

Qt

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 386, 392. node.cpp 386


void Node::setPageType(const QString& t)
{
  if ((t == "API") || (t == "api"))
    pageType_ = ApiPage;
  else if (t == "howto")             // <=
    pageType_ = HowToPage;
  else if (t == "overview")
    pageType_ = OverviewPage;
  else if (t == "tutorial")
    pageType_ = TutorialPage;
  else if (t == "howto")             // <=
    pageType_ = HowToPage;
  else if (t == "article")
    pageType_ = ArticlePage;
  else if (t == "example")
    pageType_ = ExamplePage;
  else if (t == "ditamap")
    pageType_ = DitaMapPage;
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 188, 195. qmaintainingreader_tpl_p.h 188
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 299, 303. mfmetadatacontrol.cpp 299

WebRTC

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 676, 681. packet_buffer.c 676


int WebRtcNetEQ_GetDefaultCodecSettings(....)
{
  ....
  else if (codecID[i] == kDecoderOpus)
  {
    codecBytes = 15300;
    codecBuffers = 30;
  }
  else if (codecID[i] == kDecoderOpus)
  {
    codecBytes = 15300;
    codecBuffers = 30;
  }
  ....
}

WebRTC

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 196, 202. ccsip_pmh.c 196


sipMethod_t
sippmh_get_method_code (const char *method)
{
  ....
  else if (strcmp(method, SIP_METHOD_INFO) == 0)     // <=
    ret = sipMethodInfo;
  else if (strcmp(method, SIP_METHOD_PUBLISH) == 0)
    ret = sipMethodPublish;
  else if (strcmp(method, SIP_METHOD_MESSAGE) == 0)
    ret = sipMethodMessage;
  else if (strcmp(method, SIP_METHOD_INFO) == 0)     // <=
    ret = sipMethodInfo;
  ....
}

Wine Is Not an Emulator

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1754, 1765. msi.c 1754


UINT WINAPI MsiGetPatchInfoExW(....LPCWSTR szProperty....)
{
  if(!strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW)) // <=
  {
    ...
  }
  else if (!strcmpW( szProperty, INSTALLPROPERTY_INSTALLDATEW ))
  {
    ...
  }
  else
  if(!strcmpW( szProperty, INSTALLPROPERTY_LOCALPACKAGEW)) // <=
  {
    ...
  }
  else if(!strcmpW(szProperty,INSTALLPROPERTY_UNINSTALLABLEW) ||
          !strcmpW( szProperty, INSTALLPROPERTY_PATCHSTATEW ) ||
          !strcmpW( szProperty, INSTALLPROPERTY_DISPLAYNAMEW ) ||
          !strcmpW( szProperty, INSTALLPROPERTY_MOREINFOURLW ))
  {
    ...
  }
  else
  {
    ...
  }
}

Asterisk

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 851, 853. manager_channels.c 851


static void channel_hangup_handler_cb(....)
{
  const char *event;
  ....
  if (!strcmp(action, "type")) {
    event = "HangupHandlerRun";
  } else if (!strcmp(action, "type")) {
    event = "HangupHandlerPop";
  } else if (!strcmp(action, "type")) {
    event = "HangupHandlerPush";
  } else {
    return;
  }
  ....
}

ITK

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 654, 658. itkdiffusiontensor3dreconstructionimagefilter.hxx 654


void DiffusionTensor3DReconstructionImageFilter<....>
::PrintSelf(std::ostream & os, Indent indent) const
{
  ....
  if ( this->m_GradientImageTypeEnumeration ==
       GradientIsInManyImages )
  {
    os << indent
       << "Gradient images haven been supplied "
       << std::endl;
  }
  else if ( this->m_GradientImageTypeEnumeration ==
             GradientIsInManyImages )
  {
    os << indent
       << "A multicomponent gradient image has been supplied"
       << std::endl;
  }
  ....
}

ITK

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 948, 968. itkvtkpolydatameshio.h 948


template< typename T >
void WriteCellDataBufferAsASCII(....)
{
  ....
  if( this->m_NumberOfCellPixelComponents == 3 )
  {
    ....
  }
  else if( this->m_NumberOfCellPixelComponents == 3 )
  {
    ....
  }
  ....
}

Miranda NG

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 243, 256. PluginUpdater options.cpp 243


#define CPN_COLOURCHANGED     1
#define CBN_SELCHANGE       1

INT_PTR CALLBACK DlgPopupOpts(....)
{
  ....
  if (wNotifyCode == CPN_COLOURCHANGED) {
    ....
  }
  else if (wNotifyCode == CBN_SELCHANGE) {
    ....
  }
  ....
}

Linux Kernel

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 530, 533. ioctl.c 530


int private_ioctl(struct vnt_private *pDevice, struct ifreq *rq)
{
  ....
  if (sStartAPCmd.byBasicRate & BIT3) {
    pMgmt->abyIBSSSuppRates[2] |= BIT7;
    pMgmt->abyIBSSSuppRates[3] |= BIT7;
    pMgmt->abyIBSSSuppRates[4] |= BIT7;
    pMgmt->abyIBSSSuppRates[5] |= BIT7;
  } else if (sStartAPCmd.byBasicRate & BIT2) {
    pMgmt->abyIBSSSuppRates[2] |= BIT7;
    pMgmt->abyIBSSSuppRates[3] |= BIT7;
    pMgmt->abyIBSSSuppRates[4] |= BIT7;
  } else if (sStartAPCmd.byBasicRate & BIT1) {  // <=
    pMgmt->abyIBSSSuppRates[2] |= BIT7;
    pMgmt->abyIBSSSuppRates[3] |= BIT7;
  } else if (sStartAPCmd.byBasicRate & BIT1) {  // <=
    pMgmt->abyIBSSSuppRates[2] |= BIT7;
  } else {
    /* default 1,2M */
    pMgmt->abyIBSSSuppRates[2] |= BIT7;
    pMgmt->abyIBSSSuppRates[3] |= BIT7;
  }
  ....
}

Linux Kernel

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1755, 1759. r8192U_dm.c 1755


enum dm_dig_op_sta {
  DIG_TYPE_THRESH_HIGH          = 0,
  DIG_TYPE_THRESH_LOW           = 1,
  DIG_TYPE_THRESH_HIGHPWR_HIGH  = 2,
  DIG_TYPE_THRESH_HIGHPWR_LOW   = 3,
  DIG_TYPE_DBG_MODE             = 4,
  DIG_TYPE_RSSI                 = 5,
  DIG_TYPE_ALGORITHM            = 6,
  DIG_TYPE_BACKOFF              = 7,
  DIG_TYPE_PWDB_FACTOR          = 8,
  DIG_TYPE_RX_GAIN_MIN          = 9,
  DIG_TYPE_RX_GAIN_MAX          = 10,
  DIG_TYPE_ENABLE               = 20,
  DIG_TYPE_DISABLE              = 30,
  DIG_OP_TYPE_MAX
};

void dm_change_dynamic_initgain_thresh(
  struct net_device *dev, u32 dm_type, u32 dm_value)
{
  ....
  if (dm_type == DIG_TYPE_THRESH_HIGH)
  {
    dm_digtable.rssi_high_thresh = dm_value;
  }
  else if (dm_type == DIG_TYPE_THRESH_LOW)
  {
    dm_digtable.rssi_low_thresh = dm_value;
  }
  else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)      // <=
  {                                                      // <=
    dm_digtable.rssi_high_power_highthresh = dm_value;   // <=
  }                                                      // <=
  else if (dm_type == DIG_TYPE_THRESH_HIGHPWR_HIGH)      // <=
  {                                                      // <=
    dm_digtable.rssi_high_power_highthresh = dm_value;   // <=
  }                                                      // <=
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1670, 1672. rtl_dm.c 1670

LibreOffice

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 177, 178. elementexport.cxx 177


#define CHECK_N_TRANSLATE( name ) \
  else if (sServiceName == SERVICE_PERSISTENT_COMPONENT_##name) \
    sToWriteServiceName = SERVICE_##name

void OElementExport::exportServiceNameAttribute()
{
  ....
  CHECK_N_TRANSLATE( FORM );
  CHECK_N_TRANSLATE( FORM );
  CHECK_N_TRANSLATE( LISTBOX );
  CHECK_N_TRANSLATE( COMBOBOX );
  CHECK_N_TRANSLATE( RADIOBUTTON );
  CHECK_N_TRANSLATE( GROUPBOX );
  CHECK_N_TRANSLATE( FIXEDTEXT );
  CHECK_N_TRANSLATE( COMMANDBUTTON );
  CHECK_N_TRANSLATE( CHECKBOX );
  CHECK_N_TRANSLATE( GRID );
  CHECK_N_TRANSLATE( IMAGEBUTTON );
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 3486, 3519. querydesignview.cxx 3486
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 3484, 3517. querydesignview.cxx 3484

.NET CoreCLR

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 2353, 2391. utilcode util.cpp 2353


void  PutIA64Imm22(UINT64 * pBundle, UINT32 slot, INT32 imm22)
{
  if (slot == 0)             // <=
  {
    const UINT64 mask0 = UI64(0xFFFFFC000603FFFF);
    /* Clear all bits used as part of the imm22 */
    pBundle[0] &= mask0;

    UINT64 temp0;

    temp0  = (UINT64) (imm22 & 0x200000) << 20;     //  1 s
    temp0 |= (UINT64) (imm22 & 0x1F0000) << 11;     //  5 imm5c
    temp0 |= (UINT64) (imm22 & 0x00FF80) << 25;     //  9 imm9d
    temp0 |= (UINT64) (imm22 & 0x00007F) << 18;     //  7 imm7b

    /* Or in the new bits used in the imm22 */
    pBundle[0] |= temp0;
  }
  else if (slot == 1)
  {
    ....
  }
  else if (slot == 0)        // <=
  {
    const UINT64 mask1 = UI64(0xF000180FFFFFFFFF);
    /* Clear all bits used as part of the imm22 */
    pBundle[1] &= mask1;

    UINT64 temp1;

    temp1  = (UINT64) (imm22 & 0x200000) << 37;     //  1 s
    temp1 |= (UINT64) (imm22 & 0x1F0000) << 32;     //  5 imm5c
    temp1 |= (UINT64) (imm22 & 0x00FF80) << 43;     //  9 imm9d
    temp1 |= (UINT64) (imm22 & 0x00007F) << 36;     //  7 imm7b

    /* Or in the new bits used in the imm22 */
    pBundle[1] |= temp1;
  }
  FlushInstructionCache(GetCurrentProcess(),pBundle,16);
}

Unreal Engine 4

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 289, 299. automationreport.cpp 289


void FAutomationReport::ClustersUpdated(const int32 NumClusters)
{
  ...
  //Fixup Results array
  if( NumClusters > Results.Num() )
  {
    for( int32 ClusterIndex = Results.Num();
         ClusterIndex < NumClusters;
         ++ClusterIndex )
    {
      //Make sure we have enough results for a single pass
      TArray<FAutomationTestResults> AutomationTestResult;
      AutomationTestResult.Add( FAutomationTestResults() );
      Results.Add( AutomationTestResult );
    }
  }
  else if( NumClusters > Results.Num() )
  {
    Results.RemoveAt(NumClusters, Results.Num() - NumClusters);
  }
  ....
}

Unreal Engine 4

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 3649, 3653. editorserver.cpp 3649


if(WarningCount > 0)
{
  MapCheckLog.Notify(LOCTEXT("MapCheckGenErrors",
    "Map check generated errors!"));
}
else if (WarningCount > 0)
{
  MapCheckLog.Notify(LOCTEXT("MapCheckGenWarnings",
    "Map check generated warnings!"));
}

Unreal Engine 4

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 408, 414. behaviortreedebugger.cpp 408


void FBehaviorTreeDebugger::SetCompositeDecoratorFlags(....)
{
  ....
  if (bMatchesNodeIndex)
  {
    Node->bDebuggerMarkSearchTrigger = SearchStep.bTrigger;
    Node->bDebuggerMarkSearchFailedTrigger = SearchStep....;
    bTriggerOnly = true;
  }
  else if (bMatchesNodeIndex)
  {
    SearchPathIdx = i;
    bTriggerOnly = false;
  }
  ....
}

FreeCAD

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1465, 1467. application.cpp 1465


pair<string, string> customSyntax(const string& s)
{
#if defined(FC_OS_MACOSX)
    if (s.find("-psn_") == 0)
        return make_pair(string("psn"), s.substr(5));
#endif
    if (s.find("-display") == 0)
        return make_pair(string("display"), string("null"));
    else if (s.find("-style") == 0)
        return make_pair(string("style"), string("null"));
    ....
    else if (s.find("-button") == 0)                        // <=
        return make_pair(string("button"), string("null")); // <=
    else if (s.find("-button") == 0)                        // <=
        return make_pair(string("button"), string("null")); // <=
    else if (s.find("-btn") == 0)
        return make_pair(string("btn"), string("null"));
    ....
}

FreeCAD

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 191, 199. blendernavigationstyle.cpp 191


SbBool BlenderNavigationStyle::processSoEvent(....)
{
  ....
  else if (!press &&
   (this->currentmode == NavigationStyle::DRAGGING)) {      // <=
      SbTime tmp = (ev->getTime() - this->centerTime);
      float dci = (float)QApplication::....;
      if (tmp.getValue() < dci) {
          newmode = NavigationStyle::ZOOMING;
      }
      processed = TRUE;
  }
  else if (!press &&
   (this->currentmode == NavigationStyle::DRAGGING)) {      // <=
      this->setViewing(false);
      processed = TRUE;
  }
  ....
}

GNU Octave

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1956, 1962. cellfun.cc 1956


DEFUN(....)
{
  ....
  octave_value array = args(0);
  ....
  if(....)
  else if (array.is_object())                           // <=
    retval = do_object2cell(array, dimv);
  else if (array.is_map())
    retval = do_num2cell(array.map_value (), dimv);
  else if (array.is_cell())
    retval = do_num2cell(array.cell_value (), dimv);
  else if (array.is_object())                           // <=
    retval = do_num2cell(array.cell_value (), dimv);
  ....
}

FreeSWITCH

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 141, 168. mod_easyroute.c 141


static switch_status_t load_config(void)
{
  ....
  if (globals.db_dsn) {                                     // <=
    ....
  } else if (globals.db_dsn) {                              // <=
    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
      "Cannot Open ODBC Connection (did you enable it?!)\n");
  }
  ....
}

Mozilla Thunderbird

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1060, 1062. nsstylestruct.cpp 1060


nsStyleClipPath::nsStyleClipPath(const nsStyleClipPath& aSource)
{
  if (aSource.mType == NS_STYLE_CLIP_PATH_URL) {
    SetURL(aSource.mURL);
  } else if (aSource.mType == NS_STYLE_CLIP_PATH_SHAPE) {
    SetBasicShape(aSource.mBasicShape, aSource.mSizingBox);
  } else if (aSource.mType == NS_STYLE_CLIP_PATH_SHAPE) {
    SetSizingBox(aSource.mSizingBox);
  }
}

OpenMW

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 32, 34. pathgridcheck.cpp 32


void CSMTools::PathgridCheckStage::perform(....)
{
  ....
  // check the number of pathgrid points
  if (pathgrid.mData.mS2 >
      static_cast<int>(pathgrid.mPoints.size()))
    ....
  else if (pathgrid.mData.mS2 >
           static_cast<int>(pathgrid.mPoints.size()))
    ....
  ....
}

ChakraCore

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 3220, 3231. lower.cpp 3220


bool Lowerer::GenerateFastBrSrEq(....,
                                 IR::RegOpnd * srcReg1,
                                 IR::RegOpnd * srcReg2,
                                 ....)
{
  if (srcReg2 && IsConstRegOpnd(srcReg2))
  {
    ....
  }
  else if (srcReg1 && IsConstRegOpnd(srcReg1))
  {
    ....
  }
  else if (srcReg2 && (srcReg2->m_sym->m_isStrConst))
  {
    ....
  }
  else if (srcReg1 && (srcReg1->m_sym->m_isStrConst))       // <=
  {
    ....
  }
  else if (srcReg2 && (srcReg2->m_sym->m_isStrEmpty))
  {
    ....
  }
  else if (srcReg1 && (srcReg1->m_sym->m_isStrConst))       // <=
  {
    ....
  }

  return false;
}

Oracle VM Virtual Box

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 411, 418. mp-r0drv-nt.cpp 411


static int rtMpCallUsingDpcs(....)
{
  ....
  if (enmCpuid == RT_NT_CPUID_SPECIFIC)       // <=
  {
    KeInitializeDpc(&paExecCpuDpcs[0], rtmpNtDPCWrapper, pArgs);
    KeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
    KeSetTargetProcessorDpc(&paExecCpuDpcs[0], (int)idCpu);
    pArgs->idCpu = idCpu;
  }
  else if (enmCpuid == RT_NT_CPUID_SPECIFIC) // <=
  {
    KeInitializeDpc(&paExecCpuDpcs[0], rtmpNtDPCWrapper, pArgs);
    KeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
    KeSetTargetProcessorDpc(&paExecCpuDpcs[0], (int)idCpu);
    pArgs->idCpu = idCpu;

    KeInitializeDpc(&paExecCpuDpcs[1], rtmpNtDPCWrapper, pArgs);
    KeSetImportanceDpc(&paExecCpuDpcs[1], HighImportance);
    KeSetTargetProcessorDpc(&paExecCpuDpcs[1], (int)idCpu2);
    pArgs->idCpu2 = idCpu2;
  }
  ....
}

OpenToonz

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1448, 1454. tcenterlineskeletonizer.cpp 1448


inline void Event::processVertexEvent()
{
  ....
  if (newLeftNode->m_concave) {        // <=
    newLeftNode->m_notOpposites = m_generator->m_notOpposites;
    append<vector<ContourEdge *>, vector<ContourEdge *>::....

    newLeftNode->m_notOpposites.push_back(newRightNode->m_edge);
    newLeftNode->m_notOpposites.push_back(newRightNode->....);
  } else if (newLeftNode->m_concave) { // <=
    newRightNode->m_notOpposites = m_generator->m_notOpposites;
    append<vector<ContourEdge *>, vector<ContourEdge *>::....

    newRightNode->m_notOpposites.push_back(newLeftNode->m_edge);
    newRightNode->m_notOpposites.push_back(newLeftNode->....);
  }
  ....
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 750, 825. tpalette.cpp 750
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 123, 126. igs_density.cpp 123

7-Zip

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 388, 390. archivecommandline.cpp 388


namespace NRecursedType {
  enum EEnum {
    kRecursed,
    kWildcardOnlyRecursed,
    kNonRecursed
  };
}
....
static void AddRenamePair(...., NRecursedType::EEnum type, ....)
{
  ....
  if (type == NRecursedType::kRecursed)
    val.AddAscii("-r");
  else if (type == NRecursedType::kRecursed)    // <=
    val.AddAscii("-r0");
  ....
}

Open X-Ray Engine

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1502, 1505. gstats.c 1502


/* process a single statement */
static void ProcessStatement(char *buff, int len)
{
  ....
  if (strncmp(buff,"\\pauthr\\",8) == 0)
  {
    ProcessPlayerAuth(buff, len);
  } else if (strncmp(buff,"\\getpidr\\",9) == 0)
  {
    ProcessGetPid(buff, len);
  } else if (strncmp(buff,"\\getpidr\\",9) == 0)
  {
    ProcessGetPid(buff, len);
  } else if (strncmp(buff,"\\getpdr\\",8) == 0)
  {
    ProcessGetData(buff, len);
  } else if (strncmp(buff,"\\setpdr\\",8) == 0)
  {
    ProcessSetData(buff, len);
  }
}

OpenJDK

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1873, 1877. awt_ImagingLib.c 1873


static int
setImageHints(....)
{
  ....
  if (dstCMP->isDefaultCompatCM) {
      hintP->allocDefaultDst = FALSE;
      hintP->cvtToDst = FALSE;
  }
  else if (dstCMP->isDefaultCompatCM) {
      hintP->allocDefaultDst = FALSE;
      hintP->cvtToDst = FALSE;
  }
  ....
}

CryEngine V

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 266, 268. d3dhwshader.cpp 266


int SD3DShader::Release(EHWShaderClass eSHClass, int nSize)
{
  ....
  if (eSHClass == eHWSC_Pixel)
    return ((ID3D11PixelShader*)pHandle)->Release();
  else if (eSHClass == eHWSC_Vertex)
    return ((ID3D11VertexShader*)pHandle)->Release();
  else if (eSHClass == eHWSC_Geometry)                   // <=
    return ((ID3D11GeometryShader*)pHandle)->Release();  // <=
  else if (eSHClass == eHWSC_Geometry)                   // <=
    return ((ID3D11GeometryShader*)pHandle)->Release();  // <=
  else if (eSHClass == eHWSC_Hull)
    return ((ID3D11HullShader*)pHandle)->Release();
  else if (eSHClass == eHWSC_Compute)
    return ((ID3D11ComputeShader*)pHandle)->Release();
  else if (eSHClass == eHWSC_Domain)
    return ((ID3D11DomainShader*)pHandle)->Release()
  ....
}

CryEngine V

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 970, 974. environmentalweapon.cpp 970


void CEnvironmentalWeapon::UpdateDebugOutput() const
{
  ....
  const char* attackStateName = "None";
  if(m_currentAttackState &                       // <=
     EAttackStateType_EnactingPrimaryAttack)      // <=
  {
    attackStateName = "Primary Attack";
  }
  else if(m_currentAttackState &                  // <=
          EAttackStateType_EnactingPrimaryAttack) // <=
  {
    attackStateName = "Charged Throw";
  }
  ....
}

Inkscape

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 640, 643. font-variants.cpp 640


void
FontVariants::fill_css( SPCSSAttr *css )
{
  ....
  if( _caps_normal.get_active() ) {
    css_string = "normal";
    caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
  } else if( _caps_small.get_active() ) {
    ....
  } else if( _caps_all_small.get_active() ) {
    ....
  } else if( _caps_all_petite.get_active() ) { // <=
    css_string = "petite";                     // <=
    caps_new = SP_CSS_FONT_VARIANT_CAPS_PETITE;
  } else if( _caps_all_petite.get_active() ) { // <=
    css_string = "all-petite";                 // <=
    caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE;
  }
  ....
}

CodeLite

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 383, 386. MainFrame.cpp 383


void MainFrame::OnSignal(wxCommandEvent& e)
{
  if(m_process) {
    int sigid = e.GetId();
    if(sigid == ID_SIGHUP)
        wxKill(m_process->GetPid(), wxSIGHUP);

    else if(sigid == ID_SIGINT)
        wxKill(m_process->GetPid(), wxSIGINT);

    else if(sigid == ID_SIGKILL)                  // <=
        wxKill(m_process->GetPid(), wxSIGKILL);

    else if(sigid == ID_SIGKILL)                  // <=
        wxKill(m_process->GetPid(), wxSIGTERM);
  }
}

Identical errors can be found in some other places:

  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 212, 222. new_quick_watch_dlg.cpp 212

Linux Kernel

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 375, 377. trx.c 375


bool rtl92ee_rx_query_desc(struct ieee80211_hw *hw,
         struct rtl_stats *status,
         struct ieee80211_rx_status *rx_status,
         u8 *pdesc, struct sk_buff *skb)
{
  struct rtl_priv *rtlpriv = rtl_priv(hw);
  struct rx_fwinfo *p_drvinfo;
  struct ieee80211_hdr *hdr;
  u32 phystatus = GET_RX_DESC_PHYST(pdesc);

  ....

  status->macid = GET_RX_DESC_MACID(pdesc);
  if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))
    status->wake_match = BIT(2);
  else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc))
    status->wake_match = BIT(1);
  else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc))
    status->wake_match = BIT(0);
  else
    status->wake_match = 0;

  ....
}

Linux Kernel

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1277, 1282. ks_wlan_net.c 1277


static int ks_wlan_set_power(struct net_device *dev,
           struct iw_request_info *info,
           struct iw_param *vwrq, char *extra)
{
  struct ks_wlan_private *priv =
      (struct ks_wlan_private *)netdev_priv(dev);
  short enabled;

  if (priv->sleep_mode == SLP_SLEEP) {
    return -EPERM;
  }
  /* for SLEEP MODE */
  enabled = vwrq->disabled ? 0 : 1;
  if (enabled == 0) {  /* 0 */
    priv->reg.powermgt = POWMGT_ACTIVE_MODE;
  } else if (enabled) {  /* 1 */
    if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
      priv->reg.powermgt = POWMGT_SAVE1_MODE;
    else
      return -EINVAL;
  } else if (enabled) {  /* 2 */
    if (priv->reg.operation_mode == MODE_INFRASTRUCTURE)
      priv->reg.powermgt = POWMGT_SAVE2_MODE;
    else
      return -EINVAL;
  } else
    return -EINVAL;

  hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);

  return 0;
}

Linux Kernel

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 422, 424. Hal8188ERateAdaptive.c 422


static int odm_ARFBRefresh_8188E(
        struct odm_dm_struct *dm_odm,
        struct odm_ra_info *pRaInfo)
{  /*  Wilson 2011/10/26 */
  ....
  if (pRaInfo->HighestRate > 0x13)
    pRaInfo->PTModeSS = 3;
  else if (pRaInfo->HighestRate > 0x0b)
    pRaInfo->PTModeSS = 2;
  else if (pRaInfo->HighestRate > 0x0b)
    pRaInfo->PTModeSS = 1;
  else
    pRaInfo->PTModeSS = 0;
  ....
  return 0;
}

Clang

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 416, 418. iteratorpastendchecker.cpp 416


bool IteratorPastEndChecker::evalCall(const CallExpr *CE,
                                      CheckerContext &C) const {
  ....
  if (FD->getIdentifier() == II_find) {
    return evalFind(C, CE);
  } else if (FD->getIdentifier() == II_find_end) {
    return evalFindEnd(C, CE);
  } else if (FD->getIdentifier() == II_find_first_of) {
    return evalFindFirstOf(C, CE);
  } else if (FD->getIdentifier() == II_find_if) {         // <=
    return evalFindIf(C, CE);
  } else if (FD->getIdentifier() == II_find_if) {         // <=
    return evalFindIf(C, CE);
  } else if (FD->getIdentifier() == II_find_if_not) {
    return evalFindIfNot(C, CE);
  } else if (FD->getIdentifier() == II_upper_bound) {
    return evalUpperBound(C, CE);
  } else if (FD->getIdentifier() == II_lower_bound) {
    return evalLowerBound(C, CE);
  } else if (FD->getIdentifier() == II_search) {
    return evalSearch(C, CE);
  } else if (FD->getIdentifier() == II_search_n) {
    return evalSearchN(C, CE);
  }
  ....
}

FreeBSD Kernel

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 102, 109. dtrace_debug.c 102


static void
dtrace_debug_output(void)
{
  ....
  if (d->first < d->next) {                                // <=
    char *p1 = dtrace_debug_bufr;
    count = (uintptr_t) d->next - (uintptr_t) d->first;
    for (p = d->first; p < d->next; p++)
      *p1++ = *p;
  } else if (d->next > d->first) {                         // <=
    char *p1 = dtrace_debug_bufr;
    count = (uintptr_t) d->last - (uintptr_t) d->first;
    for (p = d->first; p < d->last; p++)
      *p1++ = *p;
    count += (uintptr_t) d->next - (uintptr_t) d->bufr;
    for (p = d->bufr; p < d->next; p++)
      *p1++ = *p;
  }
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

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

goto PVS-Studio;