KContacts - fix compile warnings
ClosedPublic

Authored by winterz on May 1 2019, 8:59 PM.

Details

Summary

doing something with return values of methods marked with REQUIRED_RESULT

Test Plan

compile and run make test
no compile warnings for me now

Diff Detail

Repository
R174 KContacts
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
winterz created this revision.May 1 2019, 8:59 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMay 1 2019, 8:59 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
winterz requested review of this revision.May 1 2019, 8:59 PM
pino added a subscriber: pino.May 1 2019, 9:29 PM
pino added inline comments.
src/converter/ldifconverter.cpp
114–121

this will now return the result of the last contactGroupToLDIF call -- so, if contactGroupToLDIF returns false for any element but last of the list, the result is still true (like the current code, though)

IMHO there are two options:
a) if the results of the various contactGroupToLDIF is not wanted/needed, cast them to (void)
b) if the results matter, either make sure that at least one failure generates a failure result of the whole function, or stop and fail at the first contactGroupToLDIF call that returns false

126–133

ditto

winterz added inline comments.May 2 2019, 11:57 AM
src/converter/ldifconverter.cpp
114–121

right. my reason for this bad code was that I was following other patterns in the file.
for example, see LDIFConverter::addresseeAndContactGroupToLDIF()

I think the return value should matter and we should do:
result ||= contactGroupToLDIF(*it, str);

except I don't know what that will break.
I will try that and see if at least the unit tests still pass

winterz updated this revision to Diff 57379.May 2 2019, 2:02 PM

Pino's suggestion
added tests

dvratil added a subscriber: dvratil.May 2 2019, 3:17 PM
dvratil added inline comments.
src/converter/ldifconverter.cpp
122 ↗(On Diff #57379)

You could simplify by using result |= contactGroupToLDIF(*it, str)

winterz added inline comments.May 2 2019, 3:30 PM
src/converter/ldifconverter.cpp
122 ↗(On Diff #57379)

I could. but I don't want to :)
if you insist.

dvratil accepted this revision.May 2 2019, 4:11 PM

I don't insist :-)

This revision is now accepted and ready to land.May 2 2019, 4:11 PM
This revision was automatically updated to reflect the committed changes.