Bug 97282 - Fix gcc 6.1 warnings
Summary: Fix gcc 6.1 warnings
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: git master
Hardware: All All
: medium normal
Assignee: Thomas Zimmermann
QA Contact: D-Bus Maintainers
URL: https://lists.freedesktop.org/archive...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-10 17:07 UTC by Thomas Zimmermann
Modified: 2016-08-12 07:20 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
[01] Remove trailing whitespaces (71.91 KB, patch)
2016-08-10 17:11 UTC, Thomas Zimmermann
Details | Splinter Review
[02] Initialize 'klass' in |_dbus_type_reader_recurse| to NULL (989 bytes, patch)
2016-08-10 17:12 UTC, Thomas Zimmermann
Details | Splinter Review
[03] dbus-launch: Protect |concat2| by DBUS_ENABLE_EMBEDDED_TESTS (823 bytes, patch)
2016-08-10 17:12 UTC, Thomas Zimmermann
Details | Splinter Review
[04] Protect 'i' in |_handle_inotify_watch| by DBUS_ENABLE_VERBOSE_MODE (1.68 KB, patch)
2016-08-10 17:13 UTC, Thomas Zimmermann
Details | Splinter Review
[05] Fix misleading indention to avoid respective compiler warning (1.14 KB, patch)
2016-08-10 17:14 UTC, Thomas Zimmermann
Details | Splinter Review
[06] Protect 'orig_len' in |recover_unused_bytes| by DBUS_ENABLE_VERBOSE_MODE (1.04 KB, patch)
2016-08-10 17:14 UTC, Thomas Zimmermann
Details | Splinter Review
[07] auth: Remove 'WaitingForOK' from client (3.06 KB, patch)
2016-08-10 17:15 UTC, Thomas Zimmermann
Details | Splinter Review
[02] Initialize 'klass' in |_dbus_type_reader_recurse| to NULL (v2) (1.25 KB, patch)
2016-08-10 17:38 UTC, Thomas Zimmermann
Details | Splinter Review
[04] Protect 'i' in |_handle_inotify_watch| by DBUS_ENABLE_VERBOSE_MODE (v2) (812 bytes, patch)
2016-08-10 17:40 UTC, Thomas Zimmermann
Details | Splinter Review
[05] Fix misleading indentation to avoid respective compiler warning (v2) (1.14 KB, patch)
2016-08-10 17:42 UTC, Thomas Zimmermann
Details | Splinter Review

Description Thomas Zimmermann 2016-08-10 17:07:59 UTC
Gcc 6.1 creates a number of warnings for the dbus source code. For a related discussion on the DBus ML, see [1].

[1] https://lists.freedesktop.org/archives/dbus/2016-August/016982.html
Comment 1 Thomas Zimmermann 2016-08-10 17:11:51 UTC
Created attachment 125675 [details] [review]
[01] Remove trailing whitespaces
Comment 2 Thomas Zimmermann 2016-08-10 17:12:26 UTC
Created attachment 125676 [details] [review]
[02] Initialize 'klass' in |_dbus_type_reader_recurse| to NULL
Comment 3 Thomas Zimmermann 2016-08-10 17:12:58 UTC
Created attachment 125677 [details] [review]
[03] dbus-launch: Protect |concat2| by DBUS_ENABLE_EMBEDDED_TESTS
Comment 4 Thomas Zimmermann 2016-08-10 17:13:37 UTC
Created attachment 125678 [details] [review]
[04] Protect 'i' in |_handle_inotify_watch| by DBUS_ENABLE_VERBOSE_MODE
Comment 5 Thomas Zimmermann 2016-08-10 17:14:16 UTC
Created attachment 125679 [details] [review]
[05] Fix misleading indention to avoid respective compiler warning
Comment 6 Thomas Zimmermann 2016-08-10 17:14:50 UTC
Created attachment 125680 [details] [review]
[06] Protect 'orig_len' in |recover_unused_bytes| by DBUS_ENABLE_VERBOSE_MODE
Comment 7 Thomas Zimmermann 2016-08-10 17:15:22 UTC
Created attachment 125681 [details] [review]
[07] auth: Remove 'WaitingForOK' from client
Comment 8 Thomas Zimmermann 2016-08-10 17:36:34 UTC
Comment on attachment 125675 [details] [review]
[01] Remove trailing whitespaces

This patch fixes only the tailing white spaces for the files in this patch set. My editor is configured to remove them automatically. Since I had the patch file anyway, I thought I could also submit it.
Comment 9 Thomas Zimmermann 2016-08-10 17:38:44 UTC
Created attachment 125682 [details] [review]
[02] Initialize 'klass' in |_dbus_type_reader_recurse| to NULL (v2)

Changes since v1:

  - added |_dbus_assert| to test that klass != NULL

|_dbus_assert| is also empty in release mode, so the warning persists.
Comment 10 Thomas Zimmermann 2016-08-10 17:40:47 UTC
Created attachment 125683 [details] [review]
[04] Protect 'i' in |_handle_inotify_watch| by DBUS_ENABLE_VERBOSE_MODE (v2)

Changes since v1:

  - don't move 'i' next to while loop
  - protect 'i' by DBUS_ENABLE_VERBOSE_MODE
Comment 11 Thomas Zimmermann 2016-08-10 17:42:31 UTC
Created attachment 125684 [details] [review]
[05] Fix misleading indentation to avoid respective compiler warning (v2)

Changes since v1:

  - 'indention' -> 'indentation'
Comment 12 Thomas Zimmermann 2016-08-10 17:55:33 UTC
Comment on attachment 125681 [details] [review]
[07] auth: Remove 'WaitingForOK' from client

The code for 'WaitingForOK' is unused. According to the protocol spec on the DBus website, the client should enter this state when the authentication mechanism says so. (Right?)

The authentication code doesn't actually offer this functionality. When it's in 'WaitingForData' and sees an OK, it handles the OK as if it was in 'WaitingForOK'. [1] The code apparently works, but it's not strictly following the specification.

I had (incomplete) patches for fixing this, but I'm new to the code base and didn't want to start with the 'interesting' stuff right away. :)

[1] https://cgit.freedesktop.org/dbus/dbus/tree/dbus/dbus-auth.c?id=4e06dcf35bc8f2e3d89bbcd40ac87f4fae0085ae#n2022
Comment 13 Simon McVittie 2016-08-10 19:31:53 UTC
(In reply to Thomas Zimmermann from comment #8)
> This patch fixes only the tailing white spaces for the files in this patch
> set. My editor is configured to remove them automatically.

Thanks, but I would prefer not to apply this. Doing whitespace correctly (consistent use of spaces vs. tabs, no trailing whitespace) is a good thing in general, but dbus has too much historical whitespace damage for fixing it to be a small change.


We've fixed several security vulnerabilities in the past, which means there are probably more, so I'm reluctant to make it harder to cherry-pick fixes from master to older branches.
Comment 14 Simon McVittie 2016-08-10 19:32:51 UTC
(In reply to Thomas Zimmermann from comment #9)
> |_dbus_assert| is also empty in release mode, so the warning persists.

To be clear, do you mean the warning persists unless you also initialize klass, which is why you have also done that?
Comment 15 Simon McVittie 2016-08-10 19:39:13 UTC
(In reply to Thomas Zimmermann from comment #12)
> The code for 'WaitingForOK' is unused. According to the protocol spec on the
> DBus website, the client should enter this state when the authentication
> mechanism says so. (Right?)

The protocol specification is an abstract description of how a D-Bus client should behave, and a correct D-Bus client doesn't necessarily need to have precisely the same state machine, as long as it has compatible behaviour. I'm not particularly surprised that the two are not the same; this is not a frequently modified part of the code, or a particularly well-understood part of the specification.

If the result of switching to the specification's behaviour would not interoperate with deployed dbus-daemon implementations, then it's about 10 years too late to fix it, and we should consider fixing the specification to match the reference implementation instead.

> I had (incomplete) patches for fixing this, but I'm new to the code base and
> didn't want to start with the 'interesting' stuff right away. :)

We should fix it properly or not at all. If the warning is preventing you from compiling dbus, I think the right thing to do is to open a separate bug for investigating what is going on here, and silence the warning with _DBUS_UNUSED (or whatever we called our __attribute__((__unused__)) macro), with a comment pointing to the bug.
Comment 16 Thomas Zimmermann 2016-08-11 06:42:33 UTC
(In reply to Simon McVittie from comment #13)
> (In reply to Thomas Zimmermann from comment #8)
> > This patch fixes only the tailing white spaces for the files in this patch
> > set. My editor is configured to remove them automatically.
> 
> Thanks, but I would prefer not to apply this.

No problem. I'll check if the patch set needs a rebase to apply without the white-space fixes.
Comment 17 Thomas Zimmermann 2016-08-11 06:42:57 UTC
(In reply to Simon McVittie from comment #14)
> (In reply to Thomas Zimmermann from comment #9)
> > |_dbus_assert| is also empty in release mode, so the warning persists.
> 
> To be clear, do you mean the warning persists unless you also initialize
> klass, which is why you have also done that?

Yes, the warning persists.
Comment 18 Thomas Zimmermann 2016-08-11 06:54:43 UTC
(In reply to Simon McVittie from comment #15)

> If the result of switching to the specification's behaviour would not
> interoperate with deployed dbus-daemon implementations, then it's about 10
> years too late to fix it, and we should consider fixing the specification to
> match the reference implementation instead.

I agree. Just out of interest: how could one test this? You probably don't run a historical DBus releases for testing?

OTOH 'git blame' says that most of the code was written in the early 2000s, so most of the releases since then should ship the same code as the one in 'master'.

> > I had (incomplete) patches for fixing this, but I'm new to the code base and
> > didn't want to start with the 'interesting' stuff right away. :)
> 
> We should fix it properly or not at all.

Yes. I had that incomplete patch, but realized that it would be too invasive for a simple clean up. Maybe let's open a follow-up bug; in case someone wants to investigate.
Comment 19 Simon McVittie 2016-08-11 14:54:36 UTC
(In reply to Thomas Zimmermann from comment #18)
> I agree. Just out of interest: how could one test this? You probably don't
> run a historical DBus releases for testing?

In practice no, although it would be possible to compile a new dbus on an old-ish Linux distribution (Debian oldstable or something) and connect to the system's dbus-daemon.

> OTOH 'git blame' says that most of the code was written in the early 2000s,
> so most of the releases since then should ship the same code as the one in
> 'master'.

Yes. Your change doesn't actually affect the server-side, and presumably your incomplete patches for fixing this properly won't either; so the existing test coverage is likely good enough.

> Maybe let's open a follow-up bug; in case someone
> wants to investigate.

https://bugs.freedesktop.org/show_bug.cgi?id=97298
Comment 20 Simon McVittie 2016-08-11 15:15:55 UTC
(In reply to Thomas Zimmermann from comment #16)
> No problem. I'll check if the patch set needs a rebase to apply without the
> white-space fixes.

One patch does, but I've done that now. Testing in progress.
Comment 21 Simon McVittie 2016-08-11 15:48:29 UTC
I've applied all these, except Attachment #125675 [details] (whitespace) and Attachment #125681 [details] (WaitingForOK) which I'm not going to apply. Fixed in git for 1.11.4, thanks.

Attachment #125680 [details] needed a small amount of adjustment to apply when whitespace damage hadn't been fixed. I included whitespace fixes for the lines adjacent to those affected by this patch, because that isn't going to make cherry-picking noticeably more difficult.

(We usually fix trailing whitespace and hard tabs opportunistically, if they're in a line we are modifying anyway or an adjacent blank line, with the same justification.)

I removed the |vertical bars| around function names in the commit messages; I'm not sure where that convention comes from, but it isn't one that we use in this project. The closest we get to a special convention for function names is that we sometimes add () (e.g. "_dbus_setenv()") if we want to be unambiguous: that's the syntax used to link to a function in Doxygen.
Comment 22 Thomas Zimmermann 2016-08-12 07:20:46 UTC
Thank you!


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.