Mir

Merge lp:~vorlon/mir/explicit-gcc-version-and-g++4.9-compatibility into lp:mir

Proposed by Steve Langasek
Status: Superseded
Proposed branch: lp:~vorlon/mir/explicit-gcc-version-and-g++4.9-compatibility
Merge into: lp:mir
Diff against target: 0 lines
To merge this branch: bzr merge lp:~vorlon/mir/explicit-gcc-version-and-g++4.9-compatibility
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+226562@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

1730. By Alexandros Frantzis

android,tests: Fix g++ 4.9 build

It seems that g++ 4.9 has become more aggressive about constant folding of
expressions that use sizeof(), thus triggering warnings/errors related to
constant overflows that didn't occur with g++ 4.8.

For example, g++-4.8 warns about overflowing i3, but not i4, whereas g++-4.9
warns about both i3 and i4:

#define VALUE1 0x70000000UL
#define VALUE2 (VALUE1 >> sizeof(unsigned char))
#define VALUE3 0x80000000UL
#define VALUE4 (VALUE1 << sizeof(unsigned char))

int main()
{
    int i1 = VALUE1;
    int i2 = VALUE2;
    int i3 = VALUE3;
    int i4 = VALUE4;
}

This affects our ioctl() wrapper calls because we use 'int' for the request
parameter, whereas the request numbers produced by the kernel macros (using
sizeof() in the calculation) are 'unsigned long'. This MP fixes the problem by
casting the request numbers to 'int', which is a safe conversion since the
request numbers are constrained to 32 bits by design.

Note that we don't have a problem with all ioctl request numbers, although they
are produced by the same set of macros, because almost all of them don't have
the high bit set (like VALUE2 above) and don't trigger the overflow error. The
one we have a problem with, SYNC_IOC_MERGE, has the high bit set (like VALUE4
above).

Also note that the glibc ioctl() function signature uses 'unsigned long'
instead of 'int' for the request number. So, alternatively, we could fix the
problem by changing our wrappers to use 'unsigned long', too. However, the
glibc signature goes against POSIX and there have been discussions about
switching it back. See https://sourceware.org/bugzilla/show_bug.cgi?id=14362 .

Preview Diff

Empty

Subscribers

People subscribed via source and target branches