diff options
author | Eric Anholt | 2014-11-15 00:12:47 -0600 |
---|---|---|
committer | srinivas pulukuru | 2015-01-30 16:04:01 -0600 |
commit | e4013228673a26ff7043972f6c5a053c02663b71 (patch) | |
tree | c1b1b0e8b918f0c4e9a5cb39f3a4a06f5f0cee9a | |
parent | c9ca82b80acfa19ad63580ec6a153be4ffeec67b (diff) | |
download | libdrm-e4013228673a26ff7043972f6c5a053c02663b71.tar.gz libdrm-e4013228673a26ff7043972f6c5a053c02663b71.tar.xz libdrm-e4013228673a26ff7043972f6c5a053c02663b71.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>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: srinivas pulukuru <srinivas.pulukuru@ti.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | xf86drmMode.c | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 320e5640..afef0bb2 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -57,6 +57,8 @@ libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined | |||
57 | libdrm_la_LIBADD = @CLOCK_LIB@ | 57 | libdrm_la_LIBADD = @CLOCK_LIB@ |
58 | 58 | ||
59 | libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm | 59 | libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm |
60 | AM_CFLAGS = \ | ||
61 | $(VALGRIND_CFLAGS) | ||
60 | 62 | ||
61 | libdrm_la_SOURCES = \ | 63 | libdrm_la_SOURCES = \ |
62 | xf86drm.c \ | 64 | xf86drm.c \ |
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; |