Bug 102979 - dbus-send fails to build with -Werror=maybe-uninitialized on Debian gcc 7.2.0-7
Summary: dbus-send fails to build with -Werror=maybe-uninitialized on Debian gcc 7.2.0-7
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: 1.10
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact: D-Bus Maintainers
URL:
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-09-25 15:24 UTC by Simon McVittie
Modified: 2017-09-25 16:03 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
dbus-send: Reassure the compiler that secondary_type is initialized (1.22 KB, patch)
2017-09-25 15:25 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2017-09-25 15:24:59 UTC
/home/smcv/src/dbus-1.10/tools/dbus-send.c: In function ‘main’:
/home/smcv/src/dbus-1.10/tools/dbus-send.c:185:7: error: ‘secondary_type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       append_arg (&subiter, valtype, val);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/smcv/src/dbus-1.10/tools/dbus-send.c:461:11: note: ‘secondary_type’ was declared here
       int secondary_type;
           ^~~~~~~~~~~~~~

Oddly, the same version of gcc seems to be happy with dbus-send from git master, which has equivalent behaviour.

The code is essentially this:

if (container_type == DICT_ENTRY)
  secondary_type = ...;
...
if (container_type == DICT_ENTRY)
  call_a_function (secondary_type);
Comment 1 Simon McVittie 2017-09-25 15:25:34 UTC
Created attachment 134464 [details] [review]
dbus-send: Reassure the compiler that secondary_type is  initialized

It's initialized to a non-trivial value whenever container_type
is DBUS_TYPE_DICT_ENTRY, and subsequently only used if
container_type is DBUS_TYPE_DICT_ENTRY, but Debian's gcc 7.2.0-7
doesn't seem to be able to infer that any more, causing build failure
under -Werror=maybe-uninitialized.
Comment 2 Philip Withnall 2017-09-25 15:42:55 UTC
Comment on attachment 134464 [details] [review]
dbus-send: Reassure the compiler that secondary_type is  initialized

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

++
Comment 3 Simon McVittie 2017-09-25 16:03:53 UTC
Thanks, fixed in git for 1.11.18 and 1.10.24.


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.