From patchwork Thu Jun 11 12:42:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Benson X-Patchwork-Id: 7114 Received: (qmail 17022 invoked by alias); 11 Jun 2015 12:42:26 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17012 invoked by uid 89); 11 Jun 2015 12:42:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 11 Jun 2015 12:42:24 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 9D6AD373BC4; Thu, 11 Jun 2015 12:42:23 +0000 (UTC) Received: from blade.nx (ovpn-116-112.ams2.redhat.com [10.36.116.112]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5BCgMTx011913; Thu, 11 Jun 2015 08:42:23 -0400 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 35AB9262FE8; Thu, 11 Jun 2015 13:42:22 +0100 (BST) From: Gary Benson To: gdb-patches@sourceware.org Cc: James Greenhalgh , Pedro Alves , Eli Zaretskii , Doug Evans , =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Subject: [OB PATCH] Use pulongest for printing ssize_t Date: Thu, 11 Jun 2015 13:42:22 +0100 Message-Id: <1434026542-29902-1-git-send-email-gbenson@redhat.com> In-Reply-To: <55796B44.9090904@redhat.com> References: <55796B44.9090904@redhat.com> X-IsSubscribed: yes Pedro Alves wrote: > On 06/11/2015 09:40 AM, James Greenhalgh wrote: > > I would expect that to mean this is broken for any "long int != > > ssize_t" target. I'm not sure which C standards GDB requires > > compatability with, but I believe the portable C99 way of printing > > a ssize_t would be "%zd". > > GDB is written in C90 currently. > > The usual way to handle this is to use plongest (with %s). As this > is native GNU/Linux code, casting to long (thus keep %ld) would be > fine too. This commit changes the debug printing code in linux-namespaces.c to use pulongest instead of "%ld". Pushed as obvious. Thanks, Gary --- gdb/ChangeLog: * nat/linux-namespaces.c (mnsh_send_message): Use pulongest. (mnsh_recv_message): Likewise. --- gdb/ChangeLog | 5 +++++ gdb/nat/linux-namespaces.c | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c index 98ae104..f18e40d 100644 --- a/gdb/nat/linux-namespaces.c +++ b/gdb/nat/linux-namespaces.c @@ -374,7 +374,7 @@ mnsh_send_message (int sock, enum mnsh_msg_type type, { debug_printf ("mnsh: send: "); mnsh_debug_print_message (type, fd, int1, int2, buf, bufsiz); - debug_printf (" -> %ld\n", size); + debug_printf (" -> %s\n", pulongest (size)); } return size; @@ -426,7 +426,8 @@ mnsh_recv_message (int sock, enum mnsh_msg_type *type, if (size < 0) { if (debug_linux_namespaces) - debug_printf ("namespace-helper: recv failed (%ld)\n", size); + debug_printf ("namespace-helper: recv failed (%s)\n", + pulongest (size)); mnsh_maybe_mourn_peer (); @@ -437,8 +438,8 @@ mnsh_recv_message (int sock, enum mnsh_msg_type *type, if (size < fixed_size || (msg.msg_flags & (MSG_TRUNC | MSG_CTRUNC))) { if (debug_linux_namespaces) - debug_printf ("namespace-helper: recv truncated (%ld 0x%x)\n", - size, msg.msg_flags); + debug_printf ("namespace-helper: recv truncated (%s 0x%x)\n", + pulongest (size), msg.msg_flags); mnsh_maybe_mourn_peer ();