From patchwork Sun Dec 29 06:06:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Anholt X-Patchwork-Id: 3416601 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5FBDC9F37A for ; Sun, 29 Dec 2013 06:07:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95D2720108 for ; Sun, 29 Dec 2013 06:07:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ED07A200F2 for ; Sun, 29 Dec 2013 06:06:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A9336FACB8; Sat, 28 Dec 2013 22:06:54 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from annarchy.freedesktop.org (annarchy.freedesktop.org [131.252.210.176]) by gabe.freedesktop.org (Postfix) with ESMTP id CF78CFACB8; Sat, 28 Dec 2013 22:06:53 -0800 (PST) Received: from eliezer.anholt.net (annarchy.freedesktop.org [127.0.0.1]) by annarchy.freedesktop.org (Postfix) with ESMTP id 84736181BC; Sat, 28 Dec 2013 22:06:53 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id B3F00F02ED2; Sat, 28 Dec 2013 22:06:51 -0800 (PST) From: Eric Anholt To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Initialize or valgrind-clear modesetting ioctl arguments. Date: Sat, 28 Dec 2013 22:06:51 -0800 Message-Id: <1388297211-8460-1-git-send-email-eric@anholt.net> X-Mailer: git-send-email 1.8.5.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "xf86drmMode.h" #include "xf86drm.h" #include @@ -49,6 +53,16 @@ #include #include +#ifdef HAVE_VALGRIND +#include +#include +#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;