All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Initialize or valgrind-clear modesetting ioctl arguments.
@ 2013-12-29  6:06 Eric Anholt
  2014-01-20 18:55 ` Kenneth Graunke
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Anholt @ 2013-12-29  6:06 UTC (permalink / raw)
  To: dri-devel

Fixes valgrind complaints in the modesetting driver.  I tried to
follow each ioctl's pattern for whether it was initializing just the
in values, or both in and out values.
---
 Makefile.am   |  2 ++
 xf86drmMode.c | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index f726036..826c30d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,6 +59,8 @@ libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
 libdrm_la_LIBADD = @CLOCK_LIB@
 
 libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
+AM_CFLAGS = \
+	$(VALGRIND_CFLAGS)
 
 libdrm_la_SOURCES =				\
 	xf86drm.c				\
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 6b60c35..dd7966e 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -41,6 +41,10 @@
 #include <sys/ioctl.h>
 #include <stdio.h>
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "xf86drmMode.h"
 #include "xf86drm.h"
 #include <drm.h>
@@ -49,6 +53,16 @@
 #include <unistd.h>
 #include <errno.h>
 
+#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)))
+
 #define U642VOID(x) ((void *)(unsigned long)(x))
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
@@ -245,6 +259,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
 	struct drm_mode_fb_cmd f;
 	int ret;
 
+	VG_CLEAR(f);
 	f.width  = width;
 	f.height = height;
 	f.pitch  = pitch;
@@ -335,6 +350,7 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
 	struct drm_mode_crtc crtc;
 	drmModeCrtcPtr r;
 
+	VG_CLEAR(crtc);
 	crtc.crtc_id = crtcId;
 
 	if (drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc))
@@ -368,6 +384,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
 {
 	struct drm_mode_crtc crtc;
 
+	VG_CLEAR(crtc);
 	crtc.x             = x;
 	crtc.y             = y;
 	crtc.crtc_id       = crtcId;
@@ -436,6 +453,7 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
 	drmModeEncoderPtr r = NULL;
 
 	enc.encoder_id = encoder_id;
+	enc.crtc_id = 0;
 	enc.encoder_type = 0;
 	enc.possible_crtcs = 0;
 	enc.possible_clones = 0;
@@ -580,6 +598,7 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
 	struct drm_mode_get_property prop;
 	drmModePropertyPtr r;
 
+	VG_CLEAR(prop);
 	prop.prop_id = property_id;
 	prop.count_enum_blobs = 0;
 	prop.count_values = 0;
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm: Initialize or valgrind-clear modesetting ioctl arguments.
  2013-12-29  6:06 [PATCH] drm: Initialize or valgrind-clear modesetting ioctl arguments Eric Anholt
@ 2014-01-20 18:55 ` Kenneth Graunke
  0 siblings, 0 replies; 2+ messages in thread
From: Kenneth Graunke @ 2014-01-20 18:55 UTC (permalink / raw)
  To: Eric Anholt, dri-devel

On 12/28/2013 10:06 PM, Eric Anholt wrote:
> Fixes valgrind complaints in the modesetting driver.  I tried to
> follow each ioctl's pattern for whether it was initializing just the
> in values, or both in and out values.
> ---
>  Makefile.am   |  2 ++
>  xf86drmMode.c | 19 +++++++++++++++++++
>  2 files changed, 21 insertions(+)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-20 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-29  6:06 [PATCH] drm: Initialize or valgrind-clear modesetting ioctl arguments Eric Anholt
2014-01-20 18:55 ` Kenneth Graunke

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.