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

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

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

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

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

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

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

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

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

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

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


Если вы так и не получили ответ, пожалуйста, проверьте, отфильтровано ли письмо в одну из следующих стандартных папок:

  • Промоакции
  • Оповещения
  • Спам

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

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

V517. Potential logical error. The 'if (A) {...} else if (A) {...}' pattern was detected.


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.

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

Similar 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

WebP codec

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

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

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

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

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

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

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

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

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

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

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

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

Scilab

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


void cdf_error(char const* const fname, int status, double bound)
{
  switch (status)
  {
    ....
    case 10:
    if (strcmp(fname, "cdfchi") == 0)      // <=
    {
      Scierror(999
               _("%s: cumgam returned an error\n"), fname);
    }
    else if (strcmp(fname, "cdfchi") == 0) // <=
    {
      Scierror(999,
        _("%s: gamma or inverse gamma routine failed\n"), fname);
    }
    break;
  ....
}

Tizen

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


#define LANG_ES_MX "\x45\x73\x70\x61\xC3\xB1\x6f\x6c\x20\x28\" \
 "x45\x73\x74\x61\x64\x6f\x73\x20\x55\x6e\x69\x64\x6f\x73\x29"

#define LANG_ES_US "\x45\x73\x70\x61\xC3\xB1\x6f\x6c\x20\x28\" \
 "x45\x73\x74\x61\x64\x6f\x73\x20\x55\x6e\x69\x64\x6f\x73\x29"

char *voice_setting_language_conv_lang_to_id(const char* lang)
{
  ....
  } else if (!strcmp(LANG_PT_PT, lang)) {
    return "pt_PT";
  } else if (!strcmp(LANG_ES_MX, lang)) {     // <=
    return "es_MX";
  } else if (!strcmp(LANG_ES_US, lang)) {     // <=
    return "es_US";
  } else if (!strcmp(LANG_EL_GR, lang)) {
    return "el_GR";
  ....
}

Bind

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


static lwres_result_t
lwres_conf_parseoption(lwres_context_t *ctx,  FILE *fp) {
  ....
  while (strlen(word) > 0U) {
    if (strcmp("debug", word) == 0) {                      // <=
      confdata->resdebug = 1;
    } else if (strcmp("no_tld_query", word) == 0) {
      confdata->no_tld_query = 1;
    } else if (strcmp("debug", word) == 0) {               // <=
      confdata->resdebug = 1;
  ....
}

Tizen

V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 792, 800. setting-common-general-func.c 792


EXPORT_PUBLIC bool get_substring_int(....)
{
  const char *str = *ipStr;
  ....
  if (str[1] == '\0') {          // <= 1
    str++;
    *ipStr = str;
    return TRUE;
  } else if (str[1] == delim) {
    str += 2;
    *ipStr = str;
    return TRUE;
  } else if (str[1] == 0) {      // <= 1
    if (str[2] == 0) {           // <= 2
      str += 3;
      *ipStr = str;
      return TRUE;
    } else if (str[2] == '\0') { // <= 2
      str += 2;
      *ipStr = str;
      return TRUE;
    } else {
      str += 2;
    }
  ....
}

Similar 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: 801, 805. setting-common-general-func.c 801

EFL Core Libraries

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


static Eina_Bool
evas_image_load_file_head_bmp(void *loader_data,
                              Evas_Image_Property *prop,
                              int *error)
{
  ....
  if (header.comp == 0) // no compression
  {
    // handled
  }
  else if (header.comp == 3) // bit field
  {
    // handled
  }
  else if (header.comp == 4) // jpeg - only printer drivers
    goto close_file;
  else if (header.comp == 3) // png - only printer drivers
    goto close_file;
  else
    goto close_file;
  ....
}

Similar 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: 1248, 1408. evas_image_load_bmp.c 1248
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 426, 432. parser.c 426

MuseScore

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


static void readNote(Note* note, XmlReader& e)
{
  ....
  while (e.readNextStartElement()) {
    const QStringRef& tag(e.name());
    if (tag == "Accidental") {
      ....
    }
    ....
    else if (tag == "offTimeType") {        // <= line 651
      if (e.readElementText() == "offset")
        note->setOffTimeType(2);
      else
        note->setOffTimeType(1);
    }
    ....
    else if (tag == "offTimeType")          // <= line 728
      e.skipCurrentElement();               // <= Dead code
    ....
  }
  ....
}

Similar 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: 645, 726. read114.cpp 645

Rosegarden

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


QString IntervalDialog::getIntervalName(....)
{
  ....
  if (deviation == -1)
    textIntervalDeviated += tr("a minor");
  else if (deviation == 0)                               // <=
    textIntervalDeviated += tr("a major");
  else if (deviation == -2)
    textIntervalDeviated += tr("a diminished");
  else if (deviation == 1)
    textIntervalDeviated += tr("an augmented");
  else if (deviation == -3)
    textIntervalDeviated += tr("a doubly diminished");
  else if (deviation == 2)
    textIntervalDeviated += tr("a doubly augmented");
  else if (deviation == -4)
    textIntervalDeviated += tr("a triply diminished");
  else if (deviation == 3)
    textIntervalDeviated += tr("a triply augmented");
  else if (deviation == 4)
    textIntervalDeviated += tr("a quadruply augmented");
  else if (deviation == 0)                               // <=
    textIntervalDeviated += tr("a perfect");
  ....
}

Ardour

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


void
MixerStrip::parameter_changed (string p)
{
  if (p == _visibility.get_state_name()) {
    ....
  } else if (p == "track-name-number") { // <=
    name_changed ();
  } else if (p == "use-monitor-bus") {
    ....
  } else if (p == "track-name-number") { // <=
    update_track_number_visibility();
  }
}

Similar 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: 160, 170. event_type_map.cc 160
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 4065, 4151. session_state.cc 4065
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 4063, 4144. session_state.cc 4063
  • And 2 additional diagnostic messages.

XNU kernel

V517 CWE-570 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 340, 343. pf_pbuf.c 340


void
pbuf_copy_back(pbuf_t *pbuf, int off, int len, void *src)
{
  VERIFY(off >= 0);
  VERIFY(len >= 0);
  VERIFY((u_int)(off + len) <= pbuf->pb_packet_len);

  if (pbuf->pb_type == PBUF_TYPE_MBUF)
    m_copyback(pbuf->pb_mbuf, off, len, src);
  else
  if (pbuf->pb_type == PBUF_TYPE_MBUF) {
    if (len)
      memcpy(&((uint8_t *)pbuf->pb_data)[off], src, len);
  } else
    panic("%s: bad pb_type: %d", __func__, pbuf->pb_type);
}

The code contains a logical error. It seems to me that the first key word 'else' is superfluous.


XNU kernel

V517 CWE-570 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 358, 361. pf_pbuf.c 358


void
pbuf_copy_data(pbuf_t *pbuf, int off, int len, void *dst)
{

  VERIFY(off >= 0);
  VERIFY(len >= 0);
  VERIFY((u_int)(off + len) <= pbuf->pb_packet_len);

  if (pbuf->pb_type == PBUF_TYPE_MBUF)
    m_copydata(pbuf->pb_mbuf, off, len, dst);
  else
  if (pbuf->pb_type == PBUF_TYPE_MBUF) {
    if (len)
      memcpy(dst, &((uint8_t *)pbuf->pb_data)[off], len);
  } else
    panic("%s: bad pb_type: %d", __func__, pbuf->pb_type);
}

The code is very similar to the previous one. Most likely, this function is written using a Copy-Paste method. The code contains a logical error. It seems to me that the first key word 'else' is superfluous.


RT-Thread

V517 CWE-570 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 525, 527. gd32f4xx_can.c 525


#define CAN_FIFO0   ((uint8_t)0x00U)   /*!< receive FIFO0 */
#define CAN_FIFO1   ((uint8_t)0x01U)   /*!< receive FIFO1 */

uint8_t can_receive_message_length(uint32_t can_periph,
                                   uint8_t fifo_number)
{
 uint8_t val = 0U;

 if(CAN_FIFO0 == fifo_number){
   val = (uint8_t)(CAN_RFIFO0(can_periph) & CAN_RFIFO_RFL0_MASK);
 }else if(CAN_FIFO0 == fifo_number){
   val = (uint8_t)(CAN_RFIFO1(can_periph) & CAN_RFIFO_RFL0_MASK);
 }else{
   /* illegal parameter */
 }
 return val;
}

TDLib

V517 CWE-570 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 2536, 2549. cli.cpp 2536


void on_cmd(string cmd)
{
  ....
  string status_str;
  ....
  std::tie(user_id, status_str) = split(args);
  if (status_str == "admin") {            // <=
    status = ....
  } else if (status_str == "member") {
    status = ....
  } else if (status_str == "left") {
    status = ....
  } else if (status_str == "banned") {
    status = ....
  } else if (status_str == "creator") {
    status = ....
  } else if (status_str == "uncreator") {
    status = ....
  } else if (status_str == "admin") {     // <=
    status = ....
  } else if (status_str == "unadmin") {
    status = ....
  } else if (status_str == "rest") {
    status = ....
  } else if (status_str == "restkick") {
    status = ....
  } else if (status_str == "unrest") {
    status = ....
  }
  ....
}

Krita

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


void
KoInlineTextObjectManager::documentInformationUpdated(
const QString &info, const QString &data)
{
    if (info == "title") // <=
        setProperty(KoInlineObject::Title, data);
    else if (info == "description")
        setProperty(KoInlineObject::Description, data);
    else if (info == "abstract")
        setProperty(KoInlineObject::Comments, data);
    else if (info == "subject")
        setProperty(KoInlineObject::Subject, data);
    else if (info == "keyword")
        setProperty(KoInlineObject::Keywords, data);
    else if (info == "creator")
        setProperty(KoInlineObject::AuthorName, data);
    else if (info == "initial")
        setProperty(KoInlineObject::AuthorInitials, data);
    else if (info == "title") // <=
        setProperty(KoInlineObject::SenderTitle, data);
    else if (info == "email")
        setProperty(KoInlineObject::SenderEmail, data);
    ....
}

LibreOffice

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


Reference<XResultSet> SAL_CALL ODatabaseMetaData::getColumns(....)
{
  ....
  bool bIsCharMax = !xRow->wasNull();
  if (sDataType.equalsIgnoreAsciiCase("year"))
      nColumnSize = sColumnType.copy(6, 1).toInt32();
  else if (sDataType.equalsIgnoreAsciiCase("date"))       // <=
      nColumnSize = 10;
  else if (sDataType.equalsIgnoreAsciiCase("date"))       // <=
      nColumnSize = 8;
  else if (sDataType.equalsIgnoreAsciiCase("datetime")
           || sDataType.equalsIgnoreAsciiCase("timestamp"))
      nColumnSize = 19;
  else if (!bIsCharMax)
      nColumnSize = xRow->getShort(7);
  else
      nColumnSize = nCharMaxLen;
  ....
}

FreeRDP

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


BOOL rdpei_write_4byte_unsigned(wStream* s, UINT32 value)
{
  BYTE byte;

  if (value <= 0x3F)
  {
    ....
  }
  else if (value <= 0x3FFF)
  {
    ....
  }
  else if (value <= 0x3FFFFF)
  {
    byte = (value >> 16) & 0x3F;
    Stream_Write_UINT8(s, byte | 0x80);
    byte = (value >> 8) & 0xFF;
    Stream_Write_UINT8(s, byte);
    byte = (value & 0xFF);
    Stream_Write_UINT8(s, byte);
  }
  else if (value <= 0x3FFFFF)
  {
    byte = (value >> 24) & 0x3F;
    Stream_Write_UINT8(s, byte | 0xC0);
    byte = (value >> 16) & 0xFF;
    Stream_Write_UINT8(s, byte);
    byte = (value >> 8) & 0xFF;
    Stream_Write_UINT8(s, byte);
    byte = (value & 0xFF);
    Stream_Write_UINT8(s, byte);
  }
  ....
}

Similar 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: 169, 173. file.c 169

Haiku Operation System

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


void
FindPanel::BuildAttrQuery(BQuery* query, bool &dynamicDate) const
{
  ....
  case B_BOOL_TYPE:
  {
    uint32 value;
    if (strcasecmp(textControl->Text(),
        "true") == 0) {
      value = 1;
    } else if (strcasecmp(textControl->Text(),
        "true") == 0) {
      value = 1;
    } else
      value = (uint32)atoi(textControl->Text());

    value %= 2;
    query->PushUInt32(value);
    break;
  }
  ....
}

Bullet Physics SDK

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


int main(int argc, char* argv[])
{
  ....
  while (serviceResult > 0)
  {
    serviceResult = enet_host_service(client, &event, 0);
    if (serviceResult > 0)
    {
      ....
    }
    else if (serviceResult > 0)
    {
      puts("Error with servicing the client");
      exit(EXIT_FAILURE);
    }
    ....
  }
  ....
}

Similar 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: 151, 190. PhysicsClientUDP.cpp 151

Mozilla Thunderbird

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


void CMapiApi::ReportLongProp(const char *pTag, LPSPropValue pVal) {
  if (pVal && (PROP_TYPE(pVal->ulPropTag) == PT_LONG)) {
    nsCString num;
    nsCString num2;

    num.AppendInt((int32_t)pVal->Value.l);
    num2.AppendInt((int32_t)pVal->Value.l, 16);
    MAPI_TRACE3("%s %s, 0x%s\n", pTag, num, num2);
  } else if (pVal && (PROP_TYPE(pVal->ulPropTag) == PT_NULL)) {
    MAPI_TRACE1("%s {NULL}\n", pTag);
  } else if (pVal && (PROP_TYPE(pVal->ulPropTag) == PT_ERROR)) {  // <=
    MAPI_TRACE1("%s {Error retrieving property}\n", pTag);
  } else if (pVal && (PROP_TYPE(pVal->ulPropTag) == PT_ERROR)) {  // <=
    MAPI_TRACE1("%s {Error retrieving property}\n", pTag);
  } else {
    MAPI_TRACE1("%s invalid value, expecting long\n", pTag);
  }
  if (pVal) MAPIFreeBuffer(pVal);
}

ROOT

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


Int_t TProofMonSenderML::SendSummary(TList *recs, const char *id)
{
  ....
  if (fSummaryVrs == 0) {
    if ((dsn = recs->FindObject("dataset"))) recs->Remove(dsn);
  } else if (fSummaryVrs == 0) {
    // Only the first records
    xrecs = new TList;
    xrecs->SetOwner(kFALSE);
    TIter nxr(recs);
    TObject *o = 0;
    while ((o = nxr())) {
       if (!strcmp(o->GetName(), "vmemmxw")) break;
       xrecs->Add(o);
    }
  }
  ....
}

Qemu

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


#define MEGASAS_MAX_SGE 128             /* Firmware limit */
....
static void megasas_scsi_realize(PCIDevice *dev, Error **errp)
{
  ....
  if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) {
    ....
  } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) {
    ....
  }
  ....
}

TheXTech

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


if(Player[A].Character == 2) // luigi doesn't fly as long as mario
  Player[A].FlyCount = 300; // Length of flight time
else if(Player[A].Character == 3) // special handling for peach
{
  Player[A].FlyCount = 0;
  Player[A].RunCount = 80;
  Player[A].CanFly2 = false;
  Player[A].Jump = 70;
  Player[A].CanFloat = true;
  Player[A].FlySparks = true;
}
else if(Player[A].Character == 3) // special handling for peach
  Player[A].FlyCount = 280; // Length of flight time
else
  Player[A].FlyCount = 320; // Length of flight time

Chromium

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


void HeapObject::HeapObjectShortPrint(std::ostream& os)
{
  ....
  switch (map().instance_type()) {
    ....
    case FEEDBACK_CELL_TYPE: {
      {
        ReadOnlyRoots roots = GetReadOnlyRoots();
        os << "<FeedbackCell[";
        if (map() == roots.no_closures_cell_map()) {           // <=
          os << "no feedback";
        } else if (map() == roots.no_closures_cell_map()) {    // <=
          os << "no closures";
        } else if (map() == roots.one_closure_cell_map()) {
          os << "one closure";
        } else if (map() == roots.many_closures_cell_map()) {
          os << "many closures";
        } else {
          os << "!!!INVALID MAP!!!";
        }
        os << "]>";
      }
      break;
    }
    ....
  }
}

MuditaOS

V517 [CERT-MSC01-C] The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 1053, 1056. avdtp_util.c 1053


static uint16_t avdtp_signaling_setup_media_codec_mpeg_audio_config_event(....)
{
  uint8_t channel_mode_bitmap = ....;
  ....
  if (....)
  {
    ....
  }
  else if (channel_mode_bitmap & 0x02)
  {
    num_channels = 2;
    channel_mode = AVDTP_CHANNEL_MODE_STEREO;
  }
  else if (channel_mode_bitmap & 0x02)
  {
    num_channels = 2;
    channel_mode = AVDTP_CHANNEL_MODE_JOINT_STEREO;
  }
  ....
}

GPCS4

V517 [CWE-570] The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 469, 475. GnmGpuAddress.cpp 469


int32_t sce::GpuAddress::adjustTileMode(/* .... */)
{
switch(microTileMode)
{
  case Gnm::kMicroTileModeThin:
    if (....)
    ....
    else if (newArrayMode == Gnm::kArrayMode2dTiledThin)
      *outTileMode = Gnm::kTileModeThin_2dThin;
    ....
    else if (newArrayMode == Gnm::kArrayModeTiledThinPrt)
      *outTileMode = Gnm::kTileModeThin_ThinPrt;
    else if (newArrayMode == Gnm::kArrayMode2dTiledThin)
      *outTileMode = Gnm::kTileModeThin_2dThin;
    ....
}
}

CodeLite

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


void DisplayVariableDlg::UpdateValue(....)
{
  ....
  wxTreeItemId item = iter->second;

  if (item.IsOk())
  {
    ....
  }
  else if (item.IsOk())
  {
    ....
  }
  ....
}

Similar 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: 53, 55. symbol_tree.cpp:53, symbol_tree.cpp:55
  • V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 82, 84. symbol_tree.cpp:82, symbol_tree.cpp:84

Microsoft PowerToys

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


std::string toMediaTypeString(GUID subtype)
{
  if (subtype == MFVideoFormat_YUY2)      // <=
    return "MFVideoFormat_YUY2";
  else if (subtype == MFVideoFormat_RGB32)
    return "MFVideoFormat_RGB32";
  else ....
  else if (subtype == MFVideoFormat_AYUV)
    return "MFVideoFormat_AYUV";
  else if (subtype == MFVideoFormat_YUY2) // <=
    return "MFVideoFormat_YUY2";
  else ....
}

LLVM/Clang

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


FormatToken *verilogGroupDecl(FormatToken *FirstOfType,
                              FormatToken *PreviousComma)
{
  ....
  if (Tok->is(tok::hash))
  {
    // Start of a macro expansion.
    First = Tok;
    Tok = Next;
    if (Tok)
      Tok = Tok->getNextNonComment();
  }
  else
  ....
  if (Tok->is(tok::hash))
  {
    if (Next->is(tok::l_paren))
      Next = Next->MatchingParen;
    if (Next)
      Tok = Next->getNextNonComment();
  }
  ....
}

OpenVINO

V517 [CERT-MSC01-C] The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 22, 26. pad3d.cpp 22


NamedOutputs pad3d(const NodeContext& node)
{
  ....
  // padding of type int feature only supported by paddle 'develop'
  // version(>=2.1.0)
  if (node.has_attribute("paddings"))
  {
    auto paddings_vector = node.get_attribute<
                             std::vector<int32_t>>("paddings");
    PADDLE_OP_CHECK(node, paddings_vector.size() == 6,
                 "paddings Params size should be 6 in pad3d!");
    paddings = paddings_vector;
  }
  else if (node.has_attribute("paddings"))
  {
    auto padding_int = node.get_attribute<int32_t>("paddings");
    for (int i = 0; i < 6; i++)
      paddings[i] = padding_int;
  }
  else
  {
    PADDLE_OP_CHECK(node, false, "Unsupported paddings attribute!");
  }
  ....
}

DPDK

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


static inline int
i40e_flow_fdir_fill_eth_ip_head(....)
{
  ....
    } else if (cus_pctype->index == I40E_CUSTOMIZED_IPV4_L2TPV3) {
      len = fill_ip4_head(fdir_input, raw_pkt, IPPROTO_L2TP,
          len, ether_type);
    } else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV4) {
      len = fill_ip4_head(fdir_input, raw_pkt, IPPROTO_ESP,
          len, ether_type);
    } else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV4_UDP) {  // <=
      len = fill_ip4_head(fdir_input, raw_pkt, IPPROTO_UDP,
          len, ether_type);
    } else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV4_UDP) {  // <=
      len = fill_ip4_head(fdir_input, raw_pkt, IPPROTO_UDP,
          len, ether_type);
    } else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV6)
      len = fill_ip6_head(fdir_input, raw_pkt, IPPROTO_ESP,
          len, ether_type);
    else if (cus_pctype->index == I40E_CUSTOMIZED_ESP_IPV6_UDP)
      len = fill_ip6_head(fdir_input, raw_pkt, IPPROTO_UDP,
          len, ether_type);
  ....
}