Coverity fixes
AbandonedPublic

Authored by wojnilowicz on Mar 30 2018, 1:55 PM.

Details

Reviewers
tbaumgart
Group Reviewers
KMyMoney
Commits
R261:ad83acb7c9a9: Coverity fixes
Summary

Second batch of coverity fixes.

Diff Detail

Repository
R261 KMyMoney
Lint
Lint Skipped
Unit
Unit Tests Skipped
wojnilowicz requested review of this revision.Mar 30 2018, 1:55 PM
wojnilowicz created this revision.

Compiling this patch, I get the following warnings (I think I mentioned the result one already):

/home/thb/devel/kmymoney/kmymoney/dialogs/kequitypriceupdatedlg.cpp:525:9: warning: 
      variable 'result' is used uninitialized whenever 'if' condition is false
      [-Wsometimes-uninitialized]
    if (item)
        ^~~~
/home/thb/devel/kmymoney/kmymoney/dialogs/kequitypriceupdatedlg.cpp:534:7: note: 
      uninitialized use occurs here
  if (result == KMessageBox::No) {
      ^~~~~~
/home/thb/devel/kmymoney/kmymoney/dialogs/kequitypriceupdatedlg.cpp:525:5: note: 
      remove the 'if' if its condition is always true
    if (item)
    ^~~~~~~~~
/home/thb/devel/kmymoney/kmymoney/dialogs/kequitypriceupdatedlg.cpp:523:13: note: 
      initialize the variable 'result' to silence this warning
  int result;
            ^
             = 0

But it compiles otherwise. I have not run it.

kmymoney/dialogs/kequitypriceupdatedlg.cpp
523–524

result should be initialized here to a default in case item is zero

kmymoney/dialogs/stdtransactioneditor.cpp
532–533

Shouldn't that be

if (category && category->completion())
kmymoney/plugins/csv/import/core/csvimportercore.h
196

Better format it as follows (this applies to other spots as well)

explicit PricesProfile()
  : CSVProfile()
  , m_donAks(0)
  , m_priceFraction(2)
:
:
kmymoney/reports/tests/reportstestcommon.cpp
138–139

Is this indented correctly? It does not show here, hence I am asking.

tbaumgart requested changes to this revision.Mar 31 2018, 8:04 AM
This revision now requires changes to proceed.Mar 31 2018, 8:04 AM
wojnilowicz marked 2 inline comments as done.Mar 31 2018, 9:49 AM
wojnilowicz added inline comments.
kmymoney/dialogs/kequitypriceupdatedlg.cpp
523–524

Simple return should do it.

kmymoney/dialogs/stdtransactioneditor.cpp
532–533

It should be, but Coverity doesn't report that and that's my only goal.
I think it's a little bit messy and someone should invest a lot of time to get it 100 % right.

kmymoney/plugins/csv/import/core/csvimportercore.h
196

I didn't know it. It looks like it's against the rules to start new line with punctuation mark. What's the advantage of formatting it your way?

If it has any advantage then I would suggest to do it from no on forward.

kmymoney/reports/tests/reportstestcommon.cpp
138–139

It wasn't.

wojnilowicz marked 2 inline comments as done.

Some fixes according to comments.

tbaumgart accepted this revision as: tbaumgart.Mar 31 2018, 10:19 AM

Otherwise, it works for me.

kmymoney/plugins/csv/import/core/csvimportercore.h
196

It easier to move stuff around and add to the end. You don't need to change any existing code.

wojnilowicz added inline comments.Mar 31 2018, 12:53 PM
kmymoney/plugins/csv/import/core/csvimportercore.h
196

In my opinion the effort is equal and you have lot less whitespaces. I like my way better, as it resembles common writing rules and ":" looks like written in Python.
However, if you have a paper that governs good writing rules, I would be grateful :)

wojnilowicz abandoned this revision.Mar 31 2018, 12:54 PM

According to kdelibs style (https://community.kde.org/Policies/Kdelibs_Coding_Style), which is derived from Qt style, constructor initializers are formatted with ',' as suffix, not as prefix. You may run the astyle command at the mentioned page to see this.

According to kdelibs style (https://community.kde.org/Policies/Kdelibs_Coding_Style), which is derived from Qt style, constructor initializers are formatted with ',' as suffix, not as prefix. You may run the astyle command at the mentioned page to see this.

Thank you Ralf for the reference.