Bug 337796

Summary: kmymoney-4.6.6/kmymoney/widgets/register.cpp:1768: bad if test ?
Product: [Applications] kmymoney Reporter: dcb314
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal CC: onet.cristian
Priority: NOR    
Version: git (master)   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

Description dcb314 2014-07-25 11:10:50 UTC
kmymoney-4.6.6/kmymoney/widgets/register.cpp:1768:49: warning: logical 'or' of collectively exhaustive tests is always true [-Wlogical-op]

        if ((item->isSelected() != sel) && (sel || !sel)) {

Suggest code rework.
Comment 1 Cristian Oneț 2014-07-25 11:22:30 UTC
This seems to be in there from a while back :)

Initially like this:
http://kmymoney2.cvs.sourceforge.net/viewvc/kmymoney2/kmymoney2/kmymoney2/widgets/register.cpp?r1=1.72&r2=1.73&

The change to this:
http://kmymoney2.cvs.sourceforge.net/viewvc/kmymoney2/kmymoney2/kmymoney2/widgets/register.cpp?r1=1.83&r2=1.84&

But it's a valid warning which will be fixed in master.
Comment 2 Thomas Baumgart 2014-07-25 12:14:52 UTC
Wow, please don't ask what I smoked back in 2008. It must have been some heavy stuff ;)  This whole logic seems a bit strange if I look at it now.
Comment 3 dcb314 2014-07-25 12:18:08 UTC
It might be worthwhile to add gcc compiler flag -Wlogical-op
to your gcc builds.
Comment 4 Cristian Oneț 2014-07-28 06:20:07 UTC
Git commit 0d8b593ab4cdcf0a989ca3196619d5d70022052d by Cristian Oneț.
Committed on 28/07/2014 at 06:15.
Pushed by conet into branch 'master'.

Enable the 'logical-op' gcc warning and fix it's occurrences.

The code was broken in both places where the warning was signalled. We
should let KDAB know about the KDChart issue.

M  +1    -1    CMakeLists.txt
M  +2    -4    kmymoney/widgets/register.cpp
M  +1    -1    libkdchart/src/KDChartStockDiagram_p.cpp

http://commits.kde.org/kmymoney/0d8b593ab4cdcf0a989ca3196619d5d70022052d
Comment 5 Cristian Oneț 2014-07-28 06:21:02 UTC
Git commit 2a66f14472af17235ee21bf9da3f78ea61ce8355 by Cristian Oneț.
Committed on 28/07/2014 at 06:15.
Pushed by conet into branch 'frameworks'.

Enable the 'logical-op' gcc warning and fix it's occurrences.

The code was broken in both places where the warning was signalled. We
should let KDAB know about the KDChart issue.
(cherry picked from commit 0d8b593ab4cdcf0a989ca3196619d5d70022052d)

M  +1    -1    CMakeLists.txt
M  +2    -4    kmymoney/widgets/register.cpp
M  +1    -1    libkdchart/src/KDChartStockDiagram_p.cpp

http://commits.kde.org/kmymoney/2a66f14472af17235ee21bf9da3f78ea61ce8355