Bug 66493 - dbus headers not tolerant to namespace pollution
Summary: dbus headers not tolerant to namespace pollution
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Havoc Pennington
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-02 09:33 UTC by Ivan Romanov
Modified: 2013-08-29 10:33 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Use iface instead of interface (11.65 KB, patch)
2013-07-02 11:44 UTC, Ivan Romanov
Details | Splinter Review

Description Ivan Romanov 2013-07-02 09:33:28 UTC
Original bugreport on RedHat Bugzilla.
https://bugzilla.redhat.com/show_bug.cgi?id=980278

OS: Fedora 18.

Description of problem:
The current mingw header <rpc.h> pollutes the namespace with a '#define interface ...'.  While this is bad practice, the dbus package should avoid the problems it causes by picking names that are less likely to collide in its function declarations, or even omitting parameter names altogether (and just declaring parameter types without names).  I ran into this while trying to cross-compile libvirt for mingw.

Version-Release number of selected component (if applicable):
mingw32-dbus-1.6.8-1.fc18.noarch
mingw32-headers-2.0.999-0.15.trunk.20121110.fc18.noarch

How reproducible:
100%

Steps to Reproduce:
1. cat foo.c
2. i686-w64-mingw32-gcc -c \
   -I /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0 \
   -I /usr/i686-w64-mingw32/sys-root/mingw/lib/dbus-1.0/include \
   foo.c

Actual results:

1. #include <rpc.h>
#include <dbus/dbus.h>
int dummy;

2. In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-connection.h:32:0,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-bus.h:30,
                 from /usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus.h:31,
                 from foo.c:2:
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:74:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:80:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:111:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:116:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:149:58: error: expected ';', ',' or ')' before 'struct'
/usr/i686-w64-mingw32/sys-root/mingw/include/dbus-1.0/dbus/dbus-message.h:153:58: error: expected ';', ',' or ')' before 'struct'


Expected results:
no compilation error
Comment 1 Simon McVittie 2013-07-02 10:03:01 UTC
A patch that does s/interface/iface/ in function parameter names would be welcome.

If 'interface' appears in contexts where it's part of the API (e.g. struct members) then, sorry, we can't fix this.
Comment 2 Ivan Romanov 2013-07-02 10:42:03 UTC
it is only in function parameters.
Comment 3 Ivan Romanov 2013-07-02 11:44:47 UTC
Created attachment 81872 [details] [review]
Use iface instead of interface
Comment 4 Simon McVittie 2013-07-02 16:01:24 UTC
Comment on attachment 81872 [details] [review]
Use iface instead of interface

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

Sure, I'll apply this soon.
Comment 5 Simon McVittie 2013-07-02 16:05:18 UTC
(In reply to comment #0)
> The current mingw header <rpc.h> pollutes the namespace with a '#define
> interface ...'.  While this is bad practice, the dbus package should avoid
> the problems it causes by picking names that are less likely to collide in
> its function declarations, or even omitting parameter names altogether (and
> just declaring parameter types without names).

General policy statement on this:

Unless the other maintainers all overrule me, I am not willing to drop parameter names in general: named parameters have significant documentation value (and I suspect Doxygen uses them as input).

However, 'interface' is a sufficiently widely-namespace-polluted token that I think it's worth avoiding; your patch is ideal for that (assuming it works, I haven't tried it yet :-)
Comment 6 Ivan Romanov 2013-07-11 20:45:23 UTC
So. Is the patch approved? I need to know this before rebuild Fedora package.
Comment 7 Simon McVittie 2013-08-29 10:33:49 UTC
Yes, fixed in git for 1.7.6. Thanks!


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.