<< Return to list of all diagnostics
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);
}
....
}