Merge lp:~3v1n0/frame/remove-asserts-on-device-get into lp:frame/xenial

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 123
Merged at revision: 123
Proposed branch: lp:~3v1n0/frame/remove-asserts-on-device-get
Merge into: lp:frame/xenial
Diff against target: 54 lines (+15/-8)
1 file modified
src/device.cpp (+15/-8)
To merge this branch: bzr merge lp:~3v1n0/frame/remove-asserts-on-device-get
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Abstain
Review via email: mp+302442@code.launchpad.net

Commit message

device: don't use asserts to get properties on failures, to avoid crashes

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Self-approving as the same has been approved for upstream.

review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/device.cpp'
2--- src/device.cpp 2012-12-04 18:46:01 +0000
3+++ src/device.cpp 2016-08-09 15:58:19 +0000
4@@ -20,8 +20,6 @@
5
6 #include "device.h"
7
8-#include <assert.h>
9-
10 #include "axis.h"
11
12 #include <oif/frame_backend.h>
13@@ -135,8 +133,11 @@
14 unsigned int num_axes;
15 UFStatus status = frame_device_get_property(device, UFDevicePropertyNumAxes,
16 &num_axes);
17- assert(status == UFStatusSuccess);
18- return num_axes;
19+ if (status == UFStatusSuccess)
20+ return num_axes;
21+
22+ fprintf(stderr, "Error: failed to get device number of axes\n");
23+ return 0;
24 }
25
26 float frame_device_get_window_resolution_x(UFDevice device) {
27@@ -144,8 +145,11 @@
28 UFStatus status = frame_device_get_property(device,
29 UFDevicePropertyWindowResolutionX,
30 &resolution);
31- assert(status == UFStatusSuccess);
32- return resolution;
33+ if (status == UFStatusSuccess)
34+ return resolution;
35+
36+ fprintf(stderr, "Error: failed to get device X resolution\n");
37+ return 0;
38 }
39
40 float frame_device_get_window_resolution_y(UFDevice device) {
41@@ -153,8 +157,11 @@
42 UFStatus status = frame_device_get_property(device,
43 UFDevicePropertyWindowResolutionY,
44 &resolution);
45- assert(status == UFStatusSuccess);
46- return resolution;
47+ if (status == UFStatusSuccess)
48+ return resolution;
49+
50+ fprintf(stderr, "Error: failed to get device Y resolution\n");
51+ return 0;
52 }
53
54 UFStatus frame_accept_touch(UFDevice device, UFWindowId window_id,

Subscribers

People subscribed via source and target branches