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>main
parent
cb4bc8ead6
commit
734de7093d
|
@ -59,6 +59,8 @@ libdrm_la_LDFLAGS = -version-number 2:4:0 -no-undefined
|
||||||
libdrm_la_LIBADD = @CLOCK_LIB@
|
libdrm_la_LIBADD = @CLOCK_LIB@
|
||||||
|
|
||||||
libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
|
libdrm_la_CPPFLAGS = -I$(top_srcdir)/include/drm
|
||||||
|
AM_CFLAGS = \
|
||||||
|
$(VALGRIND_CFLAGS)
|
||||||
|
|
||||||
libdrm_la_SOURCES = \
|
libdrm_la_SOURCES = \
|
||||||
xf86drm.c \
|
xf86drm.c \
|
||||||
|
|
|
@ -41,6 +41,10 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "xf86drmMode.h"
|
#include "xf86drmMode.h"
|
||||||
#include "xf86drm.h"
|
#include "xf86drm.h"
|
||||||
#include <drm.h>
|
#include <drm.h>
|
||||||
|
@ -49,6 +53,16 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.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 U642VOID(x) ((void *)(unsigned long)(x))
|
||||||
#define VOID2U64(x) ((uint64_t)(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;
|
struct drm_mode_fb_cmd f;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
VG_CLEAR(f);
|
||||||
f.width = width;
|
f.width = width;
|
||||||
f.height = height;
|
f.height = height;
|
||||||
f.pitch = pitch;
|
f.pitch = pitch;
|
||||||
|
@ -335,6 +350,7 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
|
||||||
struct drm_mode_crtc crtc;
|
struct drm_mode_crtc crtc;
|
||||||
drmModeCrtcPtr r;
|
drmModeCrtcPtr r;
|
||||||
|
|
||||||
|
VG_CLEAR(crtc);
|
||||||
crtc.crtc_id = crtcId;
|
crtc.crtc_id = crtcId;
|
||||||
|
|
||||||
if (drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc))
|
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;
|
struct drm_mode_crtc crtc;
|
||||||
|
|
||||||
|
VG_CLEAR(crtc);
|
||||||
crtc.x = x;
|
crtc.x = x;
|
||||||
crtc.y = y;
|
crtc.y = y;
|
||||||
crtc.crtc_id = crtcId;
|
crtc.crtc_id = crtcId;
|
||||||
|
@ -436,6 +453,7 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
|
||||||
drmModeEncoderPtr r = NULL;
|
drmModeEncoderPtr r = NULL;
|
||||||
|
|
||||||
enc.encoder_id = encoder_id;
|
enc.encoder_id = encoder_id;
|
||||||
|
enc.crtc_id = 0;
|
||||||
enc.encoder_type = 0;
|
enc.encoder_type = 0;
|
||||||
enc.possible_crtcs = 0;
|
enc.possible_crtcs = 0;
|
||||||
enc.possible_clones = 0;
|
enc.possible_clones = 0;
|
||||||
|
@ -580,6 +598,7 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
|
||||||
struct drm_mode_get_property prop;
|
struct drm_mode_get_property prop;
|
||||||
drmModePropertyPtr r;
|
drmModePropertyPtr r;
|
||||||
|
|
||||||
|
VG_CLEAR(prop);
|
||||||
prop.prop_id = property_id;
|
prop.prop_id = property_id;
|
||||||
prop.count_enum_blobs = 0;
|
prop.count_enum_blobs = 0;
|
||||||
prop.count_values = 0;
|
prop.count_values = 0;
|
||||||
|
|
Loading…
Reference in New Issue