From patchwork Tue Oct 5 13:28:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 66827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 08A28B70AF for ; Wed, 6 Oct 2010 00:31:54 +1100 (EST) Received: from localhost ([127.0.0.1]:47676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P37cU-0000aA-Mn for incoming@patchwork.ozlabs.org; Tue, 05 Oct 2010 09:31:50 -0400 Received: from [140.186.70.92] (port=53876 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P37Zu-0008GP-Qr for qemu-devel@nongnu.org; Tue, 05 Oct 2010 09:29:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P37Zq-0003hH-8b for qemu-devel@nongnu.org; Tue, 05 Oct 2010 09:29:09 -0400 Received: from mtagate4.de.ibm.com ([195.212.17.164]:46643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P37Zp-0003gp-Ul for qemu-devel@nongnu.org; Tue, 05 Oct 2010 09:29:06 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate4.de.ibm.com (8.13.1/8.13.1) with ESMTP id o95DT2pA016455 for ; Tue, 5 Oct 2010 13:29:02 GMT Received: from d12av04.megacenter.de.ibm.com (d12av04.megacenter.de.ibm.com [9.149.165.229]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o95DT0QM3891268 for ; Tue, 5 Oct 2010 15:29:02 +0200 Received: from d12av04.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o95DSxSD019894 for ; Tue, 5 Oct 2010 15:29:00 +0200 Received: from stefan-thinkpad.ibm.com (sig-9-145-201-78.de.ibm.com [9.145.201.78]) by d12av04.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o95DSxxU019881; Tue, 5 Oct 2010 15:28:59 +0200 From: Stefan Hajnoczi To: Date: Tue, 5 Oct 2010 14:28:50 +0100 Message-Id: <1286285333-21003-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Blue Swirl , Stefan Hajnoczi , Prerna Saxena Subject: [Qemu-devel] [PATCH 1/4] trace: Use portable format strings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It is not portable to use "%ld" for int64_t because int64_t may have type long on 64-bit platforms and long long on 32-bit platforms. Use the standard library PRId64 macros to keep format strings portable. Signed-off-by: Stefan Hajnoczi --- docs/tracing.txt | 4 ++++ trace-events | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index ae01ff1..5504850 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -72,6 +72,10 @@ Trace events should use types as follows: * For everything else, use primitive scalar types (char, int, long) with the appropriate signedness. +Format strings should reflect the types defined in the trace event. Take +special care to use PRId64 and PRIu64 for int64_t and uint64_t types, +respectively. This ensures portability between 32- and 64-bit platforms. + === Hints for adding new trace events === 1. Trace state changes in the code. Interesting points in the code usually diff --git a/trace-events b/trace-events index f32c83f..b43317e 100644 --- a/trace-events +++ b/trace-events @@ -55,10 +55,10 @@ disable bdrv_aio_multiwrite_latefail(void *mcb, int i) "mcb %p i %d" # hw/virtio-blk.c disable virtio_blk_req_complete(void *req, int status) "req %p status %d" disable virtio_blk_rw_complete(void *req, int ret) "req %p ret %d" -disable virtio_blk_handle_write(void *req, unsigned long sector, unsigned long nsectors) "req %p sector %lu nsectors %lu" +disable virtio_blk_handle_write(void *req, uint64_t sector, size_t nsectors) "req %p sector %"PRIu64" nsectors %zu" # posix-aio-compat.c -disable paio_submit(void *acb, void *opaque, unsigned long sector_num, unsigned long nb_sectors, unsigned long type) "acb %p opaque %p sector_num %lu nb_sectors %lu type %lu" +disable paio_submit(void *acb, void *opaque, int64_t sector_num, int nb_sectors, int type) "acb %p opaque %p sector_num %"PRId64" nb_sectors %d type %d" # ioport.c disable cpu_in(unsigned int addr, unsigned int val) "addr %#x value %u"