Cppcheck: 'bMark' is assigned a value never used (sc module)

2013-02-13 Thread julien2412
Hello,

Cppcheck reported this:
sc/source/ui/view/tabview2.cxx
970 unreadVariable  style   Variable 'bMark' is assigned a value that is 
never
used.951 void ScTabView::PaintBlock( bool bReset )
952 {
953 ScMarkData rMark = aViewData.GetMarkData();
954 SCTAB nTab = aViewData.GetTabNo();
955 bool bMark = rMark.IsMarked();
956 bool bMulti = rMark.IsMultiMarked();
957 if (bMark || bMulti)
958 {
959 ScRange aMarkRange;
960 HideAllCursors();
961 if (bMulti)
962 {
963 bool bFlag = rMark.GetMarkingFlag();
964 rMark.SetMarking(false);
965 rMark.MarkToMulti();
966 rMark.GetMultiMarkArea(aMarkRange);
967 rMark.MarkToSimple();
968 rMark.SetMarking(bFlag);
969 
970 bMark = rMark.IsMarked();

See
http://opengrok.libreoffice.org/xref/core/sc/source/ui/view/tabview2.cxx#950

Is line 970 can be removed or is something lacking?

Julien




--
View this message in context: 
http://nabble.documentfoundation.org/Cppcheck-bMark-is-assigned-a-value-never-used-sc-module-tp4037118.html
Sent from the Dev mailing list archive at Nabble.com.
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Cppcheck: 'bMark' is assigned a value never used (sc module)

2013-02-13 Thread Riccardo Magliocchetti

Hello,

Il 13/02/2013 15:24, julien2412 ha scritto:

Hello,

Cppcheck reported this:
sc/source/ui/view/tabview2.cxx
970 unreadVariable  style   Variable 'bMark' is assigned a value that is 
never
used.951 void ScTabView::PaintBlock( bool bReset )

[snip]


See
http://opengrok.libreoffice.org/xref/core/sc/source/ui/view/tabview2.cxx#950

Is line 970 can be removed or is something lacking?


It looks to me like this and other cppcheck errors you have reported on 
list follow the pattern let's update the variable because in theory if 
i ever need to use it again the old value would be wrong. But practice 
is a different matter :)


Also while we are speaking about code checkers is anyone looking at 
coverity scan? On a couple of projects I've found it reporting ten time 
the errors reported by cppcheck.


thanks,
riccardo
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


Re: Cppcheck: 'bMark' is assigned a value never used (sc module)

2013-02-13 Thread Eike Rathke
Hi julien2412,

On Wednesday, 2013-02-13 06:24:20 -0800, julien2412 wrote:

 Cppcheck reported this:
 sc/source/ui/view/tabview2.cxx
 970   unreadVariable  style   Variable 'bMark' is assigned a value that is 
 never
 used.951 void ScTabView::PaintBlock( bool bReset )
 952 {
 953 ScMarkData rMark = aViewData.GetMarkData();
 954 SCTAB nTab = aViewData.GetTabNo();
 955 bool bMark = rMark.IsMarked();
 956 bool bMulti = rMark.IsMultiMarked();
 957 if (bMark || bMulti)
 958 {
 959 ScRange aMarkRange;
 960 HideAllCursors();
 961 if (bMulti)
 962 {
 963 bool bFlag = rMark.GetMarkingFlag();
 964 rMark.SetMarking(false);
 965 rMark.MarkToMulti();
 966 rMark.GetMultiMarkArea(aMarkRange);
 967 rMark.MarkToSimple();
 968 rMark.SetMarking(bFlag);
 969 
 970 bMark = rMark.IsMarked();
 
 See
 http://opengrok.libreoffice.org/xref/core/sc/source/ui/view/tabview2.cxx#950
 
 Is line 970 can be removed or is something lacking?

It can be removed. However, I suggest to also remove line 955 and change
line 957

-if (bMark || bMulti)
+if (rMark.IsMarked() || bMulti)

So no one accidentally assumes bMark would be valid after that scope.

  Eike

-- 
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
New GnuPG key 0x65632D3A : 2265 D7F3 A7B0 95CC 3918  630B 6A6C D5B7 6563 2D3A
Old GnuPG key 0x293C05FD : 997A 4C60 CE41 0149 0DB3  9E96 2F1A D073 293C 05FD
Support the FSFE, care about Free Software! https://fsfe.org/support/?erack


pgpCoodKYs97e.pgp
Description: PGP signature
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[SOLVED] Re: Cppcheck: 'bMark' is assigned a value never used (sc module)

2013-02-13 Thread Julien Nabet

On 13/02/2013 17:52, Eike Rathke wrote:

Hi julien2412,

On Wednesday, 2013-02-13 06:24:20 -0800, julien2412 wrote:


Cppcheck reported this:
sc/source/ui/view/tabview2.cxx
970 unreadVariable  style   Variable 'bMark' is assigned a value that is 
never
...
See
http://opengrok.libreoffice.org/xref/core/sc/source/ui/view/tabview2.cxx#950

Is line 970 can be removed or is something lacking?

It can be removed. However, I suggest to also remove line 955 and change
line 957

-if (bMark || bMulti)
+if (rMark.IsMarked() || bMulti)

So no one accidentally assumes bMark would be valid after that scope.

Thank you for your feedback Eike!
I pushed the patch on master, see 
http://cgit.freedesktop.org/libreoffice/core/commit/?id=c3aad7456adb8a24e2350c9b50778adefb2d1444


Julien
___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice