summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-05-14 07:55:03 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-06-02 08:32:11 +0100
commitd6240d197be1e752c0de26fbf84fc8fa8d55383c (patch)
tree4ae5b58f550245d6625b13b164605780fe28fbc8
parentd27c948a4382c4024ce5e76f1ea82103fc8e9d66 (diff)
intel: Clear structs for valgrind
When probing the module, clear structs passed into unknown ioctls to keep valgrind quiet. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/Makefile.am4
-rw-r--r--src/intel_device.c17
2 files changed, 17 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index da751258..aa8b47e2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,10 @@ AM_CFLAGS = \
@NOWARNFLAGS@ \
$(NULL)
+if VALGRIND
+AM_CFLAGS += $(VALGRIND_CFLAGS)
+endif
+
intel_drv_la_LTLIBRARIES = intel_drv.la
intel_drv_la_LDFLAGS = -module -avoid-version
intel_drv_ladir = $(moduledir)/drivers
diff --git a/src/intel_device.c b/src/intel_device.c
index 7140bebd..c1c6d846 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -37,8 +37,6 @@
#include <stdlib.h>
#include <errno.h>
-#include <sys/ioctl.h>
-
#include <pciaccess.h>
#include <xorg-server.h>
@@ -52,6 +50,16 @@
#include <xf86platformBus.h>
#endif
+#ifdef HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#define VG(x) x
+#else
+#define VG(x)
+#endif
+
+#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
+
#include "intel_driver.h"
#include "fd.h"
@@ -70,11 +78,11 @@ static int __intel_get_device_id(int fd)
struct drm_i915_getparam gp;
int devid = 0;
- memset(&gp, 0, sizeof(gp));
+ VG_CLEAR(gp);
gp.param = I915_PARAM_CHIPSET_ID;
gp.value = &devid;
- if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)))
+ if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp))
return 0;
return devid;
@@ -126,6 +134,7 @@ static int is_i915_gem(int fd)
if (ret) {
struct drm_i915_getparam gp;
+ VG_CLEAR(gp);
gp.param = I915_PARAM_HAS_GEM;
gp.value = &ret;