Re: [Linuxwacom-devel] [PATCH v2 2/5] Detect boolean conversion failure in convert_value_from_user

2011-03-14 Thread Peter Hutterer
On Fri, Mar 11, 2011 at 03:13:52PM -0800, Jason Gerecke wrote:
 Properties with PROP_FLAG_BOOLEAN set can only take on a restricted
 set of values. We detect if the string matches any of the allowed
 values and convert if possible. If not possible, the caller is notified.
 
 Signed-off-by: Jason Gerecke killert...@gmail.com
 ---
  tools/xsetwacom.c |9 +++--
  1 files changed, 7 insertions(+), 2 deletions(-)
 
 diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
 index 4497e72..2a819c7 100644
 --- a/tools/xsetwacom.c
 +++ b/tools/xsetwacom.c
 @@ -1440,10 +1440,15 @@ error:
   */
  static Bool convert_value_from_user(param_t *param, char *value, int 
 *return_value)
  {
 - if ((param-prop_flags  PROP_FLAG_BOOLEAN)  strcmp(value, off) == 
 0)
 + if (param-prop_flags  PROP_FLAG_BOOLEAN)
 + {
 + if (strcmp(value, off) == 0)
   *return_value = 0;
 - else if ((param-prop_flags  PROP_FLAG_BOOLEAN)  strcmp(value, on) 
 == 0)
 + else if (strcmp(value, on) == 0)
   *return_value = 1;
 + else
 + return False;
 + }
   else
   *return_value = atoi(value);
  
 -- 
 1.7.1

Reviewed-by: Peter Hutterer peter.hutte...@who-t.net

Cheers,
  Peter

--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH v2 2/5] Detect boolean conversion failure in convert_value_from_user

2011-03-11 Thread Jason Gerecke
Properties with PROP_FLAG_BOOLEAN set can only take on a restricted
set of values. We detect if the string matches any of the allowed
values and convert if possible. If not possible, the caller is notified.

Signed-off-by: Jason Gerecke killert...@gmail.com
---
 tools/xsetwacom.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 4497e72..2a819c7 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -1440,10 +1440,15 @@ error:
  */
 static Bool convert_value_from_user(param_t *param, char *value, int 
*return_value)
 {
-   if ((param-prop_flags  PROP_FLAG_BOOLEAN)  strcmp(value, off) == 
0)
+   if (param-prop_flags  PROP_FLAG_BOOLEAN)
+   {
+   if (strcmp(value, off) == 0)
*return_value = 0;
-   else if ((param-prop_flags  PROP_FLAG_BOOLEAN)  strcmp(value, on) 
== 0)
+   else if (strcmp(value, on) == 0)
*return_value = 1;
+   else
+   return False;
+   }
else
*return_value = atoi(value);
 
-- 
1.7.1


--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel