Re: [PATCH libinput] evdev-mt-touchpad: check calloc result

2014-04-22 Thread Peter Hutterer
On Tue, Apr 15, 2014 at 11:15:35PM +0200, Carlos Olmedo Escobar wrote:
 Check the value returned by calloc.
 ---
  src/evdev-mt-touchpad.c | 5 +
  1 file changed, 5 insertions(+)
 
 diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
 index bbbd8f3..9ec1682 100644
 --- a/src/evdev-mt-touchpad.c
 +++ b/src/evdev-mt-touchpad.c
 @@ -25,6 +25,7 @@
  #include assert.h
  #include math.h
  #include stdbool.h
 +#include stdio.h
  
  #include evdev-mt-touchpad.h
  
 @@ -721,6 +722,10 @@ tp_init_slots(struct tp_dispatch *tp,
   }
   tp-touches = calloc(tp-ntouches,
sizeof(struct tp_touch));
 + if (!tp-touches) {
 + fprintf(stderr, Failed to initialize slots.);
 + return -1;
 + }

Please use log_error() or the associated macros for this, though in this
case a simple return -1 is sufficient (we don't have a lot of logging yet
anyway)

Cheers,
   Peter

  
   return 0;
  }
 -- 
 1.9.2
 
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


[PATCH libinput] evdev-mt-touchpad: check calloc result

2014-04-15 Thread Carlos Olmedo Escobar
Check the value returned by calloc.
---
 src/evdev-mt-touchpad.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index bbbd8f3..9ec1682 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -25,6 +25,7 @@
 #include assert.h
 #include math.h
 #include stdbool.h
+#include stdio.h
 
 #include evdev-mt-touchpad.h
 
@@ -721,6 +722,10 @@ tp_init_slots(struct tp_dispatch *tp,
}
tp-touches = calloc(tp-ntouches,
 sizeof(struct tp_touch));
+   if (!tp-touches) {
+   fprintf(stderr, Failed to initialize slots.);
+   return -1;
+   }
 
return 0;
 }
-- 
1.9.2

___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel