Merge lp://qastaging/~alan-griffiths/miral/fix-1717061 into lp://qastaging/miral

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: 580
Merged at revision: 580
Proposed branch: lp://qastaging/~alan-griffiths/miral/fix-1717061
Merge into: lp://qastaging/miral
Diff against target: 350 lines (+174/-39)
7 files modified
miral/CMakeLists.txt (+1/-0)
miral/set_window_management_policy.cpp (+16/-16)
miral/window_info.cpp (+49/-15)
miral/window_info_defaults.h (+36/-0)
miral/window_management_trace.cpp (+10/-8)
test/CMakeLists.txt (+1/-0)
test/window_info.cpp (+61/-0)
To merge this branch: bzr merge lp://qastaging/~alan-griffiths/miral/fix-1717061
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Gerry Boland (community) Approve
Brandon Schaefer (community) Approve
Review via email: mp+330832@code.qastaging.launchpad.net

Commit message

Define default window settings in one place and clamp the actual values to avoid ldiv0. (LP: #1717061)

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+unsigned clamp_dim(unsigned dim)
+{
+ return std::min<unsigned long>(std::numeric_limits<long>::max(), dim);
+}

There's a mix of types here: unsigned int, unsigned long and signed long, which is causing me problems understanding. I know sizeof(unsigned int) <= sizeof(long), which implies to me that

dim <= std::numeric_limits<unsigned>::max()
    <= std::numeric_limits<long>::max()

so the min() will always choose "dim". So I don't understand what it is clamping to.

+// For our convenience when doing calculations we clamp the dimensions of the aspect ratio
+// so they will fit into a long without overflow.
What "long"? AspectRatio is a pair of unsigned ints.

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> +unsigned clamp_dim(unsigned dim)
> +{
> + return std::min<unsigned long>(std::numeric_limits<long>::max(), dim);
> +}
>
> There's a mix of types here: unsigned int, unsigned long and signed long,
> which is causing me problems understanding. I know sizeof(unsigned int) <=
> sizeof(long), which implies to me that
>
> dim <= std::numeric_limits<unsigned>::max()
> <= std::numeric_limits<long>::max()

when, as Brandon encountered on armhf, long and int are the same size.

     std::numeric_limits<long>::max() <= std::numeric_limits<unsigned>::max()

> so the min() will always choose "dim". So I don't understand what it is
> clamping to.

In the above case it is clamping to std::numeric_limits<long>::max()

> +// For our convenience when doing calculations we clamp the dimensions of the
> aspect ratio
> +// so they will fit into a long without overflow.
> What "long"? AspectRatio is a pair of unsigned ints.

If std::numeric_limits<long>::max() <= dim <= std::numeric_limits<unsigned>::max() then dim doesn't fit in a long.

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Yeah this seems a bit more robust then what I was doing in my branch.

I was just figuring since sizeof(long) >= sizeof(int) we could just cheat and assign the aspect to int::max() vs unsigned::max() but you do end up losing a byte there if really wanted on amd64 machines.

Though wont it all be going through the values that are depended in the RPC? Should we at some point look at moving to proper int sizes (u)int8/16/32/64 to know we wont have changing int values depending on the architecture.

Also that test is sort of ... different then this overflow issue but still nice to test. Wasnt sure if we actually had more checking higher up the stack when we come from the RPC.

LGTM

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

lgtm

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/miral-autolanding/44/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-miral/125/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/1554/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5252
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5240
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5240
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5240
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=artful/129
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=artful/129/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=xenial/129
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=xenial/129/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=zesty/129
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=zesty/129/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=artful/129
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=artful/129/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=xenial/129
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=xenial/129/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=zesty/129/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://mir-jenkins.ubuntu.com/job/miral-autolanding/45/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-miral/126/console
    None: https://mir-jenkins.ubuntu.com/job/generic-land-mp/1558/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/5260
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=artful/5248
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/5248
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/5248
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=artful/130
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=artful/130/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=xenial/130
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=xenial/130/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=zesty/130
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=amd64,release=zesty/130/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=artful/130
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=artful/130/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=xenial/130
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=xenial/130/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-miral/arch=i386,release=zesty/130/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches