akonadi: fix some clazy warnings
ClosedPublic

Authored by dfaure on Apr 21 2019, 4:20 PM.

Details

Summary

relation.h:30:1: warning: Move qHash(Akonadi::Relation) into Akonadi namespace for ADL lookup [-Wclazy-qhash-namespace]
itemcreatehandlertest.cpp:874:30: warning: Don't call QVector::operator[]() on temporary [-Wclazy-detaching-temporary]
tagmodeltest.cpp:266:5: warning: unused QList<QVariant> (removedTagList)

Test Plan

builds, ctest passes

Diff Detail

Repository
R165 Akonadi
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dfaure created this revision.Apr 21 2019, 4:20 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptApr 21 2019, 4:20 PM
dfaure requested review of this revision.Apr 21 2019, 4:20 PM
vkrause accepted this revision.Apr 21 2019, 7:23 PM
This revision is now accepted and ready to land.Apr 21 2019, 7:23 PM
This revision was automatically updated to reflect the committed changes.
dvratil added inline comments.Apr 23 2019, 9:33 AM
src/server/handler/itemcreatehandler.cpp
402

@dfaure This looks suspicious. There's a difference in how this is translated in the SQL query: the original version gets translated into ... WHERE gid = "", while the new version gets translated into ... WHERE gid = NULL, which is always false (a null never compares to another null). Even if you would change it to IS NULL this would still yield different results, since an empty value is not the same as a null value in SQL.

@

src/server/handler/itemcreatehandler.cpp
402

@smartins Interesting. This means this is a clazy false positive. Did I miss a caveat somewhere explaining that the change should only be made if empty vs null makes no difference, unlike here?

I'll revert and add a silence-clazy comment.

smartins added inline comments.Apr 27 2019, 4:07 PM
src/server/handler/itemcreatehandler.cpp
402

README-empty-qstringliteral.md says:

"Note: Beware that QString().isNull() is true while both QStringLiteral().isEmpty() and QStringLiteral("").isNull() are false.
So be sure not to introduce subtle bugs when doing such replacements."

smartins added inline comments.Apr 27 2019, 4:52 PM
src/server/handler/itemcreatehandler.cpp
402

Just QLatin1String("") even, I've checked with heaptrack and it doesn't allocate memory (unlike QString(""))