Do some additional checking to ensure the user provides valid values for boolean parameters. Also, provide a helpful error if the user goes astray.
Signed-off-by: Jason Gerecke <killert...@gmail.com> --- tools/xsetwacom.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c index fa98e3e..7544872 100644 --- a/tools/xsetwacom.c +++ b/tools/xsetwacom.c @@ -1424,10 +1424,14 @@ static int convert_value_from_user(param_t *param, char *value) { int val; - if ((param->prop_flags & PROP_FLAG_BOOLEAN) && strcmp(value, "off") == 0) + if (param->prop_flags & PROP_FLAG_BOOLEAN) { + if (strcmp(value, "off") == 0) val = 0; - else if ((param->prop_flags & PROP_FLAG_BOOLEAN) && strcmp(value, "on") == 0) + else if (strcmp(value, "on") == 0) val = 1; + else + val = -1; + } else val = atoi(value); @@ -1508,6 +1512,11 @@ static void set(Display *dpy, int argc, char **argv) for (i = 0; i < nvals; i++) { val = convert_value_from_user(param, values[i]); + if (param->prop_flags & PROP_FLAG_BOOLEAN && (val != 0 && val != 1)) { + fprintf(stderr, "Property '%s' is a boolean. Set it with 'on' or 'off'.\n", + param->name); + goto out; + } switch(param->prop_format) { -- 1.7.1 ------------------------------------------------------------------------------ What You Don't Know About Data Connectivity CAN Hurt You This paper provides an overview of data connectivity, details its effect on application quality, and explores various alternative solutions. http://p.sf.net/sfu/progress-d2d _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel