Bug 89243

Summary: clean up compiler warnings from clang
Product: dbus Reporter: Simon McVittie <smcv>
Component: coreAssignee: D-Bus Maintainers <dbus>
Status: RESOLVED MOVED QA Contact: D-Bus Maintainers <dbus>
Severity: enhancement    
Priority: medium    
Version: git master   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: tests: reassure clang that oom() does in fact not return
marshalling tests: fix an incorrect use of memcmp

Description Simon McVittie 2015-02-20 18:10:55 UTC
For better code quality, we should be able to build dbus with clang so that its better (or just different) compiler warnings can point out bad code.

As a first step towards that, I've been building it with:

-Wno-error=cast-align
-Wno-error=pointer-sign
-Wno-error=unused-const-variable
-Wno-error=tautological-compare

of which pointer-sign is Bug #15522 (and I'm not quite sure why configure isn't detecting that suppression as supported already).
Comment 1 Simon McVittie 2015-02-20 18:11:47 UTC
Created attachment 113693 [details] [review]
tests: reassure clang that oom() does in fact not return

---

gcc can tell that g_error is already noreturn, but clang can't.
Comment 2 Simon McVittie 2015-02-20 18:12:47 UTC
Created attachment 113694 [details] [review]
marshalling tests: fix an incorrect use of memcmp

---

We intended to memcmp sizeof(literal) bytes but were actually comparing 1 byte. Oops. (The tests still pass with this fixed, though.)
Comment 3 Ralf Habacker 2015-02-23 18:33:36 UTC
Comment on attachment 113694 [details] [review]
marshalling tests: fix an incorrect use of memcmp

looks good
Comment 4 Ralf Habacker 2015-02-23 18:35:10 UTC
Comment on attachment 113693 [details] [review]
tests: reassure clang that oom() does in fact not return

Review of attachment 113693 [details] [review]:
-----------------------------------------------------------------

looks good
Comment 5 Simon McVittie 2015-02-24 11:28:06 UTC
Patches applied, thanks. I'll leave this open, because there are still obvious clang warnings.
Comment 6 Simon McVittie 2015-02-24 11:40:37 UTC
(In reply to Simon McVittie from comment #0)
> -Wno-error=cast-align

That's essentially Bug #10599 so I'm treating it as somewhat out-of-scope for this bug (although it would be good to suppress the warning until then).

> -Wno-error=pointer-sign

This is Bug #15522; similar.

> -Wno-error=unused-const-variable

This is a new insight from clang; gcc doesn't notice. We probably just need more #ifndef TESTS or whatever.

> -Wno-error=tautological-compare

clang is making one of our enums unsigned, where gcc makes it signed. I think we might also be abusing the relevant enum to take an out-of-range value (not allowed in Standard C) which ought to be fixed one day anyway.
Comment 7 GitLab Migration User 2018-10-12 21:22:18 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/122.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.