summaryrefslogtreecommitdiff
path: root/tools/libinput-list-devices.c
diff options
context:
space:
mode:
authorJon A. Cruz <jonc@osg.samsung.com>2015-05-28 19:01:01 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2015-06-01 08:47:14 +1000
commit96d4fa03640559e18484e5c1a2ca4b19049bbe1f (patch)
treec6e51001240e0712ff421b816c6b3597c3304af5 /tools/libinput-list-devices.c
parent35269404363d069bb9f8c3b67eb950bc1e145f17 (diff)
downloadlibinput-96d4fa03640559e18484e5c1a2ca4b19049bbe1f.tar.gz
Add xasprintf to avoid use of undefined pointer values
If asprintf fails for any reason, the contents of the pointer are undefined. While some platforms set it to NULL, there is no guarantee that all will. This change adds a simple wrapper to ensure proper NULL results on failure. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Added LIBINPUT_PRINTF attribute and the required declaration for it. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-list-devices.c')
-rw-r--r--tools/libinput-list-devices.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c
index 66251731..68ddb612 100644
--- a/tools/libinput-list-devices.c
+++ b/tools/libinput-list-devices.c
@@ -120,17 +120,17 @@ calibration_default(struct libinput_device *device)
float calibration[6];
if (!libinput_device_config_calibration_has_matrix(device)) {
- asprintf(&str, "n/a");
+ xasprintf(&str, "n/a");
return str;
}
if (libinput_device_config_calibration_get_default_matrix(device,
calibration) == 0) {
- asprintf(&str, "identity matrix");
+ xasprintf(&str, "identity matrix");
return str;
}
- asprintf(&str,
+ xasprintf(&str,
"%.2f %.2f %.2f %.2f %.2f %.2f",
calibration[0],
calibration[1],
@@ -150,13 +150,13 @@ scroll_defaults(struct libinput_device *device)
scroll_methods = libinput_device_config_scroll_get_methods(device);
if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
- asprintf(&str, "none");
+ xasprintf(&str, "none");
return str;
}
method = libinput_device_config_scroll_get_default_method(device);
- asprintf(&str,
+ xasprintf(&str,
"%s%s%s%s%s%s",
(method == LIBINPUT_CONFIG_SCROLL_2FG) ? "*" : "",
(scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) ? "two-finger " : "",
@@ -176,12 +176,12 @@ click_defaults(struct libinput_device *device)
click_methods = libinput_device_config_click_get_methods(device);
if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE) {
- asprintf(&str, "none");
+ xasprintf(&str, "none");
return str;
}
method = libinput_device_config_click_get_default_method(device);
- asprintf(&str,
+ xasprintf(&str,
"%s%s%s%s",
(method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) ? "*" : "",
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) ? "button-areas " : "",