Cleanup #9756
Issues found by Clang
0%
Description
I again [1] used Clang with -Weverything [2] to compile the Ceph repository [3].
There is still a huge amount of serious issues reported by Clang.
Even new ones that were only found by the nightly Clang version I used.
-Wtautological-constant-out-of-range-compare:
- "comparison of constant 0 with expression of type 'bool' is always false"
- https://github.com/ceph/ceph/blob/158381e95d14e05e187b025c73522cbec42e88b4/src/auth/cephx/CephxServiceHandler.cc#L100
- a bool is never < 0, this is dead code!
-Wembedded-directive:
- "embedding a directive within macro arguments has undefined behavior"
- https://github.com/ceph/ceph/blob/158381e95d14e05e187b025c73522cbec42e88b4/src/common/config_opts.h#L464-466
-Wvarargs:
- "'va_start' has undefined behavior with reference types"
- https://github.com/ceph/ceph/blob/158381e95d14e05e187b025c73522cbec42e88b4/src/common/ceph_argparse.cc#L206
- I thought this was changed to boost's program_option. At least it was discussed.
-Wuninitialized:
- "field 'mdlog' is uninitialized when used here"
- https://github.com/ceph/ceph/blob/158381e95d14e05e187b025c73522cbec42e88b4/src/mds/MDLog.cc#L186
- see how mdlog is first dereferenced and then initialized in the initializer list.
There is even more, such as Wshift-sign-overflow, Wsign-compare, etc. that are just too many to list here. And I discovered those just with Clang's warnings -- this is not even using the Static Analyzer, which warns about various other issues I do not have the time to go through.
Could you please not only fix those issues but also incorporate Clang / Static Analyzer into your toolchain? I'm not heavily involved in Ceph's codebase as I'm mostly a user that compiles the repo every other month mostly for the fun of it.
Thanks,
Daniel
[1] http://thread.gmane.org/gmane.comp.file-systems.ceph.devel/19507
[2] clang version 3.6.0-svn219050-1~exp1 (trunk) (based on LLVM 3.6.0)
[3] https://github.com/ceph/ceph/tree/158381e95d14e05e187b025c73522cbec42e88b4
Associated revisions
CephxServiceHandler.cc: fix get_auth conditional
The KeyServer class has a public method get_auth() that returns a boolean
value. This value is being checked here - fix the conditional so it triggers
when get_auth() returns false.
http://tracker.ceph.com/issues/9756 References: #9756
Signed-off-by: Nathan Cutler <ncutler@suse.com>
CephxServiceHandler.cc: fix get_auth conditional
The KeyServer class has a public method get_auth() that returns a boolean
value. This value is being checked here - fix the conditional so it triggers
when get_auth() returns false.
http://tracker.ceph.com/issues/9756 References: #9756
Signed-off-by: Nathan Cutler <ncutler@suse.com>
(cherry picked from commit 7250db62cb7ac1e9c0b1f5956d60b9d874496702)
History
#1 Updated by Sage Weil over 9 years ago
start with
https://github.com/ceph/autobuild-ceph/blob/master/build-ceph.sh
and make a build-ceph-clang.sh. then update build-auto.sh to have a clang case (in the hostname) and then it will be pretty trivial to add this to the gitbuilder list at
http://ceph.com/gitbuilders.cgi
of course, the real work is in cleaning up all the existing issues!
#2 Updated by Nathan Cutler over 8 years ago
- Status changed from New to In Progress
https://github.com/ceph/ceph/pull/6090 attempts to fix the -Wtautological-constant-out-of-range-compare
#3 Updated by Kefu Chai over 8 years ago
https://github.com/ceph/ceph/pull/6090 also applies to hammer