Examples of errors detected by the V728 diagnostic
V728. Excessive check can be simplified. The '||' operator is surrounded by opposite expressions 'x' and '!x'.
86Box
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!transc' and 'transc'. vid_mga.c 4395
static void blit_line(mystique_t *mystique, int closed, int autoline) { .... bool transc = !!(mystique->dwgreg.dwgctrl_running & DWGCTRL_TRANSC); switch (mystique->dwgreg.dwgctrl_running & DWGCTRL_ATYPE_MASK) { case DWGCTRL_ATYPE_RSTR: case DWGCTRL_ATYPE_RPL: while (mystique->dwgreg.length >= 0) { if (....) { .... if ( !transc // <= || (transc && (mystique->dwgreg .pattern[pattern_y][pattern_x]))) .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!transc' and 'transc'. vid_mga.c 4716
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!transc' and 'transc'. vid_mga.c 4788
CMake
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions 'arguments.ErrorVariable.empty()' and '!arguments.ErrorVariable.empty()'. cmExecuteProcessCommand.cxx 257
bool cmExecuteProcessCommand(std::vector<std::string> const& args, cmExecutionStatus& status) { .... else if ( arguments.ErrorVariable.empty() || (!arguments.ErrorVariable.empty() && arguments.OutputVariable != arguments.ErrorVariable)) { .... } .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. cmGlobalGhsMultiGenerator.cxx 341
- V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. testDynamicLoader.cxx 81
- V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. testDynamicLoader.cxx 88
- And 1 additional diagnostic messages.
Battle for Wesnoth
V728 [CWE-571] An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!action_result' and 'action_result'. recruitment.cpp 439
void recruitment::execute() { .... do{ .... action_result_ptr action_result; .... } while((action_result && action_result->is_ok()) || !action_result); .... } Nau Engine
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!optional' and 'optional'. dataComponent.cpp 283
void DataComponents::initialize(const ComponentTypes &types) { .... if (!this->hasComponent(depConstString.hash) && (!optional || (optional && !can_skip_optional))) { .... } .... } PPSSPP
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!dummyThreadHackAddr' and 'dummyThreadHackAddr'. sceNetAdhoc.cpp 1121
void netAdhocValidateLoopMemory() { // Allocate Memory if it wasn't valid/allocated // after loaded from old SaveState if ( !dummyThreadHackAddr || ( dummyThreadHackAddr && strcmp("dummythreadhack", kernelMemory.GetBlockTag(dummyThreadHackAddr)) != 0)) { .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!matchingThreadHackAddr' and 'matchingThreadHackAddr'. sceNetAdhoc.cpp 1126
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!regs[i].away' and 'regs[i].away'. RegCache.cpp 352
Telegram
V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. passport_form_controller.h 318
bool operator==(const PasswordSettings &other) const { return (request == other.request) .... && ((v::is_null(newAlgo) && v::is_null(other.newAlgo)) || (!v::is_null(newAlgo) && !v::is_null(other.newAlgo))) && .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. passport_form_controller.h 320
- V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. media_view_overlay_widget.cpp 1210
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!_searchFull' and '_searchFull'. dialogs_widget.cpp 582
- And 1 additional diagnostic messages.
PPSSPP
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!apctlThreadHackAddr' and 'apctlThreadHackAddr'. sceNet.cpp 257
void netValidateLoopMemory() { // Allocate Memory if it wasn't valid/allocated // after loaded from old SaveState if ( !apctlThreadHackAddr || ( apctlThreadHackAddr && strcmp("apctlThreadHack", kernelMemory.GetBlockTag(apctlThreadHackAddr)) != 0)) { .... } } YTsaurus
V728 – Message: An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. comparator.cpp:194:1
int TComparator::CompareKeyBounds(const TKeyBound& lhs, const TKeyBound& rhs, int lowerVsUpper) const { .... // Prefixes coincide. Check if key bounds are indeed at the same point. { auto lhsInclusivenessAsUpper = (lhs.IsUpper && lhs.IsInclusive) || (!lhs.IsUpper && !lhs.IsInclusive); auto rhsInclusivenessAsUpper = (rhs.IsUpper && rhs.IsInclusive) || (!rhs.IsUpper && !rhs.IsInclusive); if (lhsInclusivenessAsUpper != rhsInclusivenessAsUpper) { return lhsInclusivenessAsUpper - rhsInclusivenessAsUpper; } } .... } YTsaurus
V728 – Message: An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. scheduler_commands.h:36:1
template <class TOptions> class TSimpleOperationCommandBase : public virtual TTypedCommandBase<TOptions> { .... public: TSimpleOperationCommandBase() { .... if (!OperationId.IsEmpty() && OperationAlias.operator bool() || OperationId.IsEmpty() && !OperationAlias.operator bool() ) { .... } .... } }; CodeLite
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!false' and 'false'. clDebuggerBreakpoint.cpp:26
clDebuggerBreakpoint::clDebuggerBreakpoint(const clDebuggerBreakpoint& BI) { .... if (!is_windows || (is_windows && !file.Contains("/"))) { .... } .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!matcher' and 'matcher'. ssh_account_info.cpp:108
- V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. assignedfilesmodel.cpp:310
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions 'data->m_wxcWidget->IsSizer()' and '!data->m_wxcWidget->IsSizer()'. wxguicraft_main_view.cpp:530
VCMI
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!isCurrentMapConquerable' and 'isCurrentMapConquerable'. NetPacksLobbyServer.cpp 225
void ApplyOnServerNetPackVisitor::visitLobbySetCampaign(LobbySetCampaign & pack) { .... if ( !isCurrentMapConquerable || (isCurrentMapConquerable && i == *pack.ourCampaign->currentMap)) { srv.setCampaignMap(i); } .... } Overgrowth
V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. as_compiler.cpp 4317
void asCCompiler::CompileIfStatement(....) { bool constructorCall1 = ....; bool constructorCall2 = ....; .... if ( (constructorCall1 && !constructorCall2) ||(constructorCall2 && !constructorCall1) ) { .... } } Heawei Ark Compiler
V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. mir_nodes.cpp 1552
bool BinaryNode::Verify() const { .... if ((IsAddress(GetBOpnd(0)->GetPrimType()) && !IsAddress(GetBOpnd(1)->GetPrimType())) || (!IsAddress(GetBOpnd(0)->GetPrimType()) && IsAddress(GetBOpnd(1)->GetPrimType()))) { .... } .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. bin_mpl_import.cpp 702
Heawei Ark Compiler
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions 'c != '\"'' and 'c == '\"''. lexer.cpp 400
TokenKind MIRLexer::GetTokenWithPrefixDoubleQuotation() { .... char c = GetCurrentCharWithUpperCheck(); while ((c != 0) && (c != '\"' || (c == '\"' && GetCharAtWithLowerCheck(....) == '\\'))) { .... } .... } CMake
V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. cmCTestRunTest.cxx 151
bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { .... } else if ((success && !this->TestProperties->WillFail) || (!success && this->TestProperties->WillFail)) { this->TestResult.Status = cmCTestTestHandler::COMPLETED; outputStream << " Passed "; } .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. cmCTestTestHandler.cxx 702
- V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. digest_sspi.c 443
- V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. tcp.c 1295
- And 3 additional diagnostic messages.
EAStdC
V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. int128.h 1242
inline void int128_t::Modulus(....) const { .... bool bDividendNegative = false; bool bDivisorNegative = false; .... if( (bDividendNegative && !bDivisorNegative) || (!bDividendNegative && bDivisorNegative)) { quotient.Negate(); } .... } Windows Calculator
V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. Calculator Calculator.xaml.cpp 239
void Calculator::AnimateCalculator(bool resultAnimate) { if (App::IsAnimationEnabled()) { m_doAnimate = true; m_resultAnimate = resultAnimate; if (((m_isLastAnimatedInScientific && IsScientific) || (!m_isLastAnimatedInScientific && !IsScientific)) && ((m_isLastAnimatedInProgrammer && IsProgrammer) || (!m_isLastAnimatedInProgrammer && !IsProgrammer))) { this->OnStoryboardCompleted(nullptr, nullptr); } } } LibreOffice
V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. toolbox2.cxx 1042
void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror ) { ImplToolItems::size_type nPos = GetItemPos( nItemId ); if ( nPos != ITEM_NOTFOUND ) { ImplToolItem* pItem = &mpData->m_aItems[nPos]; if ((pItem->mbMirrorMode && !bMirror) || // <= (!pItem->mbMirrorMode && bMirror)) // <= { .... } } } Vangers: One For The Road
V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. iscreen.cpp 2221
void iScreen::CheckScanCode(int sc) { .... iScreenObject *obj; iScreenEvent *p; .... obj = (iScreenObject*) objList->last; while (obj) { .... while (p) { if ( (!(obj->flags & OBJ_LOCKED) && !(p->flags & EV_IF_LOCKED)) || ((obj->flags & OBJ_LOCKED) && (p->flags & EV_IF_LOCKED))) { .... } } .... } } Krita
V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. kis_filter_weights_buffer.h 216
#define SANITY_ZEROS() .... \ if ((m_filterWeights[i].weight[j] && \ !m_filterWeights[i].weight[idx2]) || \ (!m_filterWeights[i].weight[j] && \ m_filterWeights[i].weight[idx2])) { \ .... \ } \ .... \ Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!nodeJuggler' and 'nodeJuggler'. kis_node_manager.cpp 809
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!m_currentFilterConfigWidget' and 'm_currentFilterConfigWidget'. kis_filter_option.cpp 111
Audacity
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!j->hasFixedBinCount' and 'j->hasFixedBinCount'. LoadVamp.cpp 169
wxArrayString VampEffectsModule::FindPlugins(....) { .... if (.... || !j->hasFixedBinCount || (j->hasFixedBinCount && j->binCount > 1)) { ++output; continue; } .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!j->hasFixedBinCount' and 'j->hasFixedBinCount'. LoadVamp.cpp 297
EFL Core Libraries
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!itr' and 'itr'. evas_object_textblock.c 9505
static Eina_Bool _evas_textblock_node_text_adjust_offsets_to_start(....) { Evas_Object_Textblock_Node_Format *last_node, *itr; .... if (!itr || (itr && (itr->text_node != n))) .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!p' and 'p'. elm_theme.c 447
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!ss' and 'ss'. config.c 3932
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!icon_version' and 'icon_version'. efreet_icon_cache_create.c 917
CMaNGOS
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!realtimeonly' and 'realtimeonly'. Player.cpp 10536
void Player::UpdateItemDuration(uint32 time, bool realtimeonly) { .... if ((realtimeonly && (....)) || !realtimeonly) item->UpdateDuration(this, time); .... } CodeLite
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!found' and 'found'. editor_config.cpp 120
bool EditorConfig::Load() { .... if(userSettingsLoaded) { if(!found || (found && version != this->m_version)){ // <= if(DoLoadDefaultSettings() == false) { return false; } } } .... } Blender
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!fluidmd' and 'fluidmd'. mod_fluidsim_util.c 528
DerivedMesh *fluidsimModifier_do(....) { .... if (!fluidmd || (fluidmd && !fluidmd->fss)) return dm; .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!render_only' and 'render_only'. drawobject.c 4663
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!parent' and 'parent'. kx_scene.cpp 1667
CPython
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions 'quotetabs' and '!quotetabs'. binascii.c 1453
static PyObject * binascii_b2a_qp_impl(PyModuleDef *module, Py_buffer *data, int quotetabs, int istext, int header) { Py_ssize_t in, out; const unsigned char *databuf; .... if ((databuf[in] > 126) || (databuf[in] == '=') || (header && databuf[in] == '_') || ((databuf[in] == '.') && (linelen == 0) && (databuf[in+1] == '\n' || databuf[in+1] == '\r' || databuf[in+1] == 0)) || (!istext && ((databuf[in] == '\r') || (databuf[in] == '\n'))) || ((databuf[in] == '\t' || databuf[in] == ' ') && (in + 1 == datalen)) || ((databuf[in] < 33) && (databuf[in] != '\r') && (databuf[in] != '\n') && (quotetabs || (!quotetabs && ((databuf[in] != '\t') && // <= (databuf[in] != ' ')))))) { .... } .... } Firebird
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!xnet_connect_mutex' and 'xnet_connect_mutex'. xnet.cpp 2231
bool XnetServerEndPoint::server_init(USHORT flag) { .... xnet_connect_mutex = CreateMutex(ISC_get_security_desc(), FALSE, name_buffer); if (!xnet_connect_mutex || (xnet_connect_mutex && ERRNO == ERROR_ALREADY_EXISTS)) { system_error::raise(ERR_STR("CreateMutex")); } .... } PHP:Hypertext Preprocessor
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!path' and 'path'. plain_wrapper.c 1487
PHPAPI php_stream *_php_stream_fopen_with_path( .... const char *path, ....) { .... if (!path || (path && !*path)) { .... } Similar errors can be found in some other places:
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!path' and 'path'. fopen_wrappers.c 643
- V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!headers_lc' and 'headers_lc'. sendmail.c 728
The GTK+ Project
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions 'ret' and '!ret'. gtktreeview.c 13682
void gtk_tree_view_get_cell_area (....) { .... gboolean ret = ...; .... /* Get vertical coords */ if ((!ret && tree == NULL) || ret) .... } The GTK+ Project
V728 An excessive check can be simplified. The '||' operator is surrounded by opposite expressions '!mount' and 'mount'. gtkplacesview.c 708
static void add_volume (....) { .... GMount *mount; .... if (!mount || (mount && !g_mount_is_shadowed (mount))) .... }