Bug 377897 - Findings from code review
Summary: Findings from code review
Status: RESOLVED FIXED
Alias: None
Product: Akonadi
Classification: Frameworks and Libraries
Component: server (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-21 19:33 UTC by Steve
Modified: 2017-03-24 13:45 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 17.04


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve 2017-03-21 19:33:51 UTC
Leaked FD:
akonadi-16.12.2/src/rds/bridgeconnection.cpp:96: open_fn: Returning handle opened by "socket".
akonadi-16.12.2/src/rds/bridgeconnection.cpp:96: var_assign: Assigning: "fd" = handle returned from "socket(1, SOCK_STREAM, 0)".
akonadi-16.12.2/src/rds/bridgeconnection.cpp:103: noescape: Resource "fd" is not freed or pointed-to in "connect".
akonadi-16.12.2/src/rds/bridgeconnection.cpp:107: leaked_handle: Handle variable "fd" going out of scope leaks the handle.

Missing return statements:
akonadi-16.12.2/src/server/handler.cpp:216: unterminated_case: The case for value "Akonadi::Protocol::Command::SubscriptionChangeNotification" is not terminated by a 'break' statement.
akonadi-16.12.2/src/server/handler.cpp:219: fallthrough: The above case falls through to this one.
akonadi-16.12.2/src/server/handler.cpp:222: fallthrough: The above case falls through to this one.

Identical branches:
akonadi-16.12.2/x86_64-redhat-linux-gnu/src/agentbase/moc_preprocessorbase.cpp:87: implicit_else: The code from the above if-then branch is identical to the code after the if statement.
akonadi-16.12.2/x86_64-redhat-linux-gnu/src/agentbase/moc_preprocessorbase.cpp:85: identical_branches: The same code is executed when the condition "_id < 0" is true or false, because the code in the if-then branch and after the if statement is identical.

The identical branches is in other files, too. You can probably grep on it.

Missing Break:
akonadi-16.12.2/src/core/changerecorder_p.cpp:95: unterminated_case: The case for value "Akonadi::ChangeRecorderPrivate::Collection" is not terminated by a 'break' statement.
akonadi-16.12.2/src/core/changerecorder_p.cpp:97: fallthrough: The above case falls through to this one.

Double return statements, is the first one supposed to be there?:
akonadi-16.12.2/src/private/protocol.cpp:8019: unreachable: This code cannot be reached: "return stream;".

Another double return:
akonadi-16.12.2/src/private/protocol.cpp:8025: unreachable: This code cannot be reached: "return stream;".
Comment 1 Daniel Vrátil 2017-03-22 00:28:38 UTC
Git commit 92c529c2cae9f9661b938fbbbe84a1fa180c832f by Daniel Vrátil.
Committed on 22/03/2017 at 00:27.
Pushed by dvratil into branch 'Applications/17.04'.

Fix missing break/return statements

Thanks to Steve Grubb for pointing those out.
FIXED-IN: 17.04

M  +1    -0    src/core/changerecorder_p.cpp
M  +0    -2    src/private/protocol.cpp
M  +2    -0    src/server/handler.cpp

https://commits.kde.org/akonadi/92c529c2cae9f9661b938fbbbe84a1fa180c832f
Comment 2 Daniel Vrátil 2017-03-22 00:29:05 UTC
Thanks for the review! 

The leaked FDs are false positives, as the FD is passed into QLocalSocket which then takes ownership and ensures they are freed when the QLocalSocket is destroyed.

The "identical branches" warnings are from a generated code (code generated by Qt during compilation), so nothing I can fix easily.

I fixed the missing return, missing break, and double return issues. Thanks again!