From patchwork Tue Apr 8 20:49:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 3950971 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1F92BFF02 for ; Tue, 8 Apr 2014 20:50:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 27385204AF for ; Tue, 8 Apr 2014 20:50:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 264C820483 for ; Tue, 8 Apr 2014 20:50:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 185616E86C; Tue, 8 Apr 2014 13:50:36 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f41.google.com (mail-bk0-f41.google.com [209.85.214.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 721EA6E866 for ; Tue, 8 Apr 2014 13:50:33 -0700 (PDT) Received: by mail-bk0-f41.google.com with SMTP id d7so1293074bkh.14 for ; Tue, 08 Apr 2014 13:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=yZrVZTTw2vEpDBlZB1X0YnW5yrWGtewimQwFfCoVRgw=; b=Lpbfp6v0eDlmJTabL2AuKMez1Tk4zHdFszAA5GKONpe8QaBBnCACScyYR2ZHkhZM0F m0DDH+q6q0dLaa6EufvYKrOvqLbHkdz2rEPFT7PYqb+Fj3g8qcVzT3SarEUa2gau/obl eXMjOjsdeM7a8eDuTMasFUAxAeb5mXj+SzicfaLbrs8srizJkKzO+NdXC15dHGerSiEo tsMjkJ6kbbvoLBdF/DBd/Xqwg9XvIPayA0mvwnio/S+oy8fWIOaFtSb1GGLW3SFZ44Kz T3WfWE8eT0ARMmgD52ftYHY4s34J3/6IHLVUMFBDMGc5AGYv59RqJbFHIbLanlhPb/nj itKQ== X-Received: by 10.204.103.199 with SMTP id l7mr222696bko.70.1396990232617; Tue, 08 Apr 2014 13:50:32 -0700 (PDT) Received: from localhost (port-92459.pppoe.wtnet.de. [84.46.73.165]) by mx.google.com with ESMTPSA id ez1sm3743401bkb.2.2014.04.08.13.50.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Apr 2014 13:50:31 -0700 (PDT) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/4] Mark functions printf-like where possible Date: Tue, 8 Apr 2014 22:49:35 +0200 Message-Id: <1396990178-32470-2-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1396990178-32470-1-git-send-email-thierry.reding@gmail.com> References: <1396990178-32470-1-git-send-email-thierry.reding@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 From: Thierry Reding These functions all take a format string and either a list of variable arguments or a va_list. Use the new DRM_PRINTFLIKE macro to tell the compiler about it so that the arguments can be checked against the format string. Signed-off-by: Thierry Reding --- intel/intel_decode.c | 7 ++----- tests/drmstat.c | 2 +- xf86drm.c | 10 +++++++--- xf86drm.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/intel/intel_decode.c b/intel/intel_decode.c index c0a0cafc904e..61239dd96d27 100644 --- a/intel/intel_decode.c +++ b/intel/intel_decode.c @@ -29,6 +29,7 @@ #include #include +#include "xf86drm.h" #include "intel_chipset.h" #include "intel_bufmgr.h" @@ -104,11 +105,7 @@ static float int_as_float(uint32_t intval) return uval.f; } -static void -instr_out(struct drm_intel_decode *ctx, unsigned int index, - const char *fmt, ...) __attribute__((format(__printf__, 3, 4))); - -static void +static void DRM_PRINTFLIKE(3, 4) instr_out(struct drm_intel_decode *ctx, unsigned int index, const char *fmt, ...) { diff --git a/tests/drmstat.c b/tests/drmstat.c index 345b8d2cda31..c51cbc6c9f61 100644 --- a/tests/drmstat.c +++ b/tests/drmstat.c @@ -425,7 +425,7 @@ int main(int argc, char **argv) return r; } -void +void DRM_PRINTFLIKE(4, 0) xf86VDrvMsgVerb(int scrnIndex, int type, int verb, const char *format, va_list args) { diff --git a/xf86drm.c b/xf86drm.c index 720952ff2cbd..fa5701abae51 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -104,12 +104,16 @@ void drmSetServerInfo(drmServerInfoPtr info) * This function is a wrapper around vfprintf(). */ -static int drmDebugPrint(const char *format, va_list ap) +static int DRM_PRINTFLIKE(1, 0) +drmDebugPrint(const char *format, va_list ap) { return vfprintf(stderr, format, ap); } -static int (*drm_debug_print)(const char *format, va_list ap) = drmDebugPrint; +typedef int DRM_PRINTFLIKE(1, 0) (*debug_msg_func_t)(const char *format, + va_list ap); + +static debug_msg_func_t drm_debug_print = drmDebugPrint; void drmMsg(const char *format, ...) @@ -129,7 +133,7 @@ drmMsg(const char *format, ...) } void -drmSetDebugMsgFunction(int (*debug_msg_ptr)(const char *format, va_list ap)) +drmSetDebugMsgFunction(debug_msg_func_t debug_msg_ptr) { drm_debug_print = debug_msg_ptr; } diff --git a/xf86drm.h b/xf86drm.h index 5e170f86fe5e..c024cc446354 100644 --- a/xf86drm.h +++ b/xf86drm.h @@ -704,7 +704,7 @@ extern int drmSLLookupNeighbors(void *l, unsigned long key, extern int drmOpenOnce(void *unused, const char *BusID, int *newlyopened); extern void drmCloseOnce(int fd); -extern void drmMsg(const char *format, ...); +extern void drmMsg(const char *format, ...) DRM_PRINTFLIKE(1, 2); extern int drmSetMaster(int fd); extern int drmDropMaster(int fd);