From patchwork Thu Feb 9 16:35:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9565081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 180CD6020C for ; Thu, 9 Feb 2017 16:38:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0596428576 for ; Thu, 9 Feb 2017 16:38:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED3CE2857B; Thu, 9 Feb 2017 16:38:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7586728576 for ; Thu, 9 Feb 2017 16:38:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbrhn-0005sE-VY; Thu, 09 Feb 2017 16:36:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbrhn-0005s8-3K for xen-devel@lists.xenproject.org; Thu, 09 Feb 2017 16:36:23 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 89/A4-15112-68A9C985; Thu, 09 Feb 2017 16:36:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeJIrShJLcpLzFFi42JxWrrBXrdl1pw Ig89PTC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozFB+6xFVzVreh8+p2lgXG2UhcjJ4eEgL/E 9Y5DjCA2m4COxMW5O9m6GDk4RARUJG7vNehi5OJgFpjIJDGv+xcrSFxYwE5i79ZykHIWoJK+R 1PZQGxeAUuJj0eXM0KM1JPYdeQ3K0RcUOLkzCcsIDazgKZE6/bf7BC2vETz1tnMILaQgKJE/7 wHbBMYeWYhaZmFpGUWkpYFjMyrGNWLU4vKUot0LfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxK TivWS83M3MQIDhwEIdjDe3RRwiFGSg0lJlFe2YE6EEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQne xplAOcGi1PTUirTMHGAIw6QlOHiURHjXgKR5iwsSc4sz0yFSpxgVpcR5q0ASAiCJjNI8uDZY3 FxilJUS5mUEOkSIpyC1KDezBFX+FaM4B6OSMG8oyBSezLwSuOmvgBYzAS2+fnoWyOKSRISUVA Mj4znLHXnzgtg2WrgkFTF9sBKXPK6lWb7ghkNX2lsHd7MJt7lklveuFd4ofO8C+8RG76J30bc n7f1v8qAn7Twz55cfhrJmwjfnfpt4LX/vZcXX3uELGT+bS/Cai6S8bH284H/9Yrfa2LVbU0x5 Xubs6XvdZBxwwiziaNXTCMfWLykfL/4+dj5MiaU4I9FQi7moOBEANLF0GJYCAAA= X-Env-Sender: prvs=206367711=roger.pau@citrix.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1486658179!43054600!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23139 invoked from network); 9 Feb 2017 16:36:20 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-2.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 9 Feb 2017 16:36:20 -0000 X-IronPort-AV: E=Sophos;i="5.35,137,1484006400"; d="scan'208";a="414689756" From: Roger Pau Monne To: Date: Thu, 9 Feb 2017 16:35:30 +0000 Message-ID: <20170209163530.66926-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) MIME-Version: 1.0 Cc: Wei Liu , Liu Jinsong , Christoph Egger , Ian Jackson , Jan Beulich , Andrew Cooper , Roger Pau Monne Subject: [Xen-devel] [PATCH] build/printf: fix incorrect format specifiers X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The following incorrect format specifiers and incorrect number of parameters passed to printf like functions are reported by clang: grant_table.c:3289:17: error: format specifies type 'unsigned short' but the argument has type 'grant_handle_t' (aka 'unsigned int') [-Werror,-Wformat] handle, ref, map->flags, map->domid); ^~~~~~ grant_table.c:3289:25: error: format specifies type 'unsigned short' but the argument has type 'grant_ref_t' (aka 'unsigned int') [-Werror,-Wformat] handle, ref, map->flags, map->domid); ^~~ mce.c:601:18: error: data argument not used by format string [-Werror,-Wformat-extra-args] smp_processor_id()); ^ xenpm.c:102:23: error: data argument not used by format string [-Werror,-Wformat-extra-args] what, argv[argc > 1]); ^ libxl_internal.c:25:69: error: data argument not used by format string [-Werror,-Wformat-extra-args] libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L); ^ libxl_internal.c:24:17: note: expanded from macro 'L' func, (unsigned long)nmemb, (unsigned long)size ^ libxl_internal.c:26:21: error: data argument not used by format string [-Werror,-Wformat-extra-args] fprintf(stderr, L); ^ libxl_internal.c:24:17: note: expanded from macro 'L' func, (unsigned long)nmemb, (unsigned long)size ^ This patch contains the fixes for them. Signed-off-by: Roger Pau Monné --- NB: FWIW, there's a way to disable extra arguments checks (-Wno-format-extra-args), that would prevent us from having to apply some of the changes here. However, given that there are not that many occurrences, I would rather leave the full checks of Wformat enabled. NB2: this has only been tested with a FreeBSD clang build (3.8.0), and only against the components that build on FreeBSD (ie: no qemu-trad, and certainly no blktap). --- Cc: Ian Jackson Cc: Wei Liu Cc: Christoph Egger Cc: Liu Jinsong Cc: Jan Beulich Cc: Andrew Cooper --- tools/libxl/libxl_internal.c | 21 ++++++++++++++++----- tools/misc/xenpm.c | 13 ++++++++----- xen/arch/x86/cpu/mcheck/mce.c | 4 ++-- xen/common/grant_table.c | 2 +- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index d288215..f492dae 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -20,14 +20,25 @@ void libxl__alloc_failed(libxl_ctx *ctx, const char *func, size_t nmemb, size_t size) { #define M "libxl: FATAL ERROR: memory allocation failure" -#define L (size ? M " (%s, %lu x %lu)\n" : M " (%s)\n"), \ - func, (unsigned long)nmemb, (unsigned long)size - libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L); - fprintf(stderr, L); +#define M_SIZE M " (%s, %lu x %lu)\n" +#define M_NSIZE M " (%s)\n" + if (size) { + libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0, 0, func, INVALID_DOMID, + M_SIZE, func, (unsigned long)nmemb, (unsigned long)size); + fprintf(stderr, M_SIZE, func, (unsigned long)nmemb, + (unsigned long)size); + } else { + libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0, 0, func, INVALID_DOMID, + M_NSIZE, func); + fprintf(stderr, M_NSIZE, func); + + } + fflush(stderr); _exit(-1); +#undef M_NSIZE +#undef M_SIZE #undef M -#undef L } void libxl__ptr_add(libxl__gc *gc, void *ptr) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index a2edee5..ded40b9 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -93,13 +93,16 @@ static void parse_cpuid(const char *arg, int *cpuid) static void parse_cpuid_and_int(int argc, char *argv[], int *cpuid, int *val, const char *what) { - if ( argc > 1 ) - parse_cpuid(argv[0], cpuid); + if ( argc == 0 ) + { + fprintf(stderr, "Missing %s\n", what); + exit(EINVAL); + } - if ( argc == 0 || sscanf(argv[argc > 1], "%d", val) != 1 ) + parse_cpuid(argv[0], cpuid); + if ( sscanf(argv[1], "%d", val) != 1 ) { - fprintf(stderr, argc ? "Invalid %s '%s'\n" : "Missing %s\n", - what, argv[argc > 1]); + fprintf(stderr, "Invalid %s '%s'\n", what, argv[1]); exit(EINVAL); } } diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index 2695b0c..5f40e71 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -596,8 +596,8 @@ int show_mca_info(int inited, struct cpuinfo_x86 *c) }; snprintf(prefix, ARRAY_SIZE(prefix), - g_type != mcheck_unset ? XENLOG_WARNING "CPU%i: " - : XENLOG_INFO, + g_type != mcheck_unset ? XENLOG_WARNING "CPU%i: ": + XENLOG_INFO "CPU%i: ", smp_processor_id()); BUG_ON(inited >= ARRAY_SIZE(type_str)); switch (inited) { diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index d3ea805..50b003e 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -3284,7 +3284,7 @@ gnttab_release_mappings( ref = map->ref; - gdprintk(XENLOG_INFO, "Grant release (%hu) ref:(%hu) " + gdprintk(XENLOG_INFO, "Grant release (%u) ref:(%u) " "flags:(%x) dom:(%hu)\n", handle, ref, map->flags, map->domid);