aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt2013-12-29 00:06:51 -0600
committerKenneth Graunke2014-01-20 12:58:06 -0600
commit734de7093db296912da0027e4fa1094f60787c11 (patch)
tree81548f2353d24b0a90cd5da7f4dedcfbc7d2be08 /xf86drmMode.c
parentcb4bc8ead63cb213a26bcc8d14b2b44d9fb967da (diff)
downloadexternal-libgbm-734de7093db296912da0027e4fa1094f60787c11.tar.gz
external-libgbm-734de7093db296912da0027e4fa1094f60787c11.tar.xz
external-libgbm-734de7093db296912da0027e4fa1094f60787c11.zip
drm: Initialize or valgrind-clear modesetting ioctl arguments.
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. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 6b60c35e..dd7966ef 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -41,6 +41,10 @@
41#include <sys/ioctl.h> 41#include <sys/ioctl.h>
42#include <stdio.h> 42#include <stdio.h>
43 43
44#ifdef HAVE_CONFIG_H
45#include "config.h"
46#endif
47
44#include "xf86drmMode.h" 48#include "xf86drmMode.h"
45#include "xf86drm.h" 49#include "xf86drm.h"
46#include <drm.h> 50#include <drm.h>
@@ -49,6 +53,16 @@
49#include <unistd.h> 53#include <unistd.h>
50#include <errno.h> 54#include <errno.h>
51 55
56#ifdef HAVE_VALGRIND
57#include <valgrind.h>
58#include <memcheck.h>
59#define VG(x) x
60#else
61#define VG(x)
62#endif
63
64#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
65
52#define U642VOID(x) ((void *)(unsigned long)(x)) 66#define U642VOID(x) ((void *)(unsigned long)(x))
53#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) 67#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
54 68
@@ -245,6 +259,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
245 struct drm_mode_fb_cmd f; 259 struct drm_mode_fb_cmd f;
246 int ret; 260 int ret;
247 261
262 VG_CLEAR(f);
248 f.width = width; 263 f.width = width;
249 f.height = height; 264 f.height = height;
250 f.pitch = pitch; 265 f.pitch = pitch;
@@ -335,6 +350,7 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
335 struct drm_mode_crtc crtc; 350 struct drm_mode_crtc crtc;
336 drmModeCrtcPtr r; 351 drmModeCrtcPtr r;
337 352
353 VG_CLEAR(crtc);
338 crtc.crtc_id = crtcId; 354 crtc.crtc_id = crtcId;
339 355
340 if (drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc)) 356 if (drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc))
@@ -368,6 +384,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
368{ 384{
369 struct drm_mode_crtc crtc; 385 struct drm_mode_crtc crtc;
370 386
387 VG_CLEAR(crtc);
371 crtc.x = x; 388 crtc.x = x;
372 crtc.y = y; 389 crtc.y = y;
373 crtc.crtc_id = crtcId; 390 crtc.crtc_id = crtcId;
@@ -436,6 +453,7 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
436 drmModeEncoderPtr r = NULL; 453 drmModeEncoderPtr r = NULL;
437 454
438 enc.encoder_id = encoder_id; 455 enc.encoder_id = encoder_id;
456 enc.crtc_id = 0;
439 enc.encoder_type = 0; 457 enc.encoder_type = 0;
440 enc.possible_crtcs = 0; 458 enc.possible_crtcs = 0;
441 enc.possible_clones = 0; 459 enc.possible_clones = 0;
@@ -580,6 +598,7 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
580 struct drm_mode_get_property prop; 598 struct drm_mode_get_property prop;
581 drmModePropertyPtr r; 599 drmModePropertyPtr r;
582 600
601 VG_CLEAR(prop);
583 prop.prop_id = property_id; 602 prop.prop_id = property_id;
584 prop.count_enum_blobs = 0; 603 prop.count_enum_blobs = 0;
585 prop.count_values = 0; 604 prop.count_values = 0;