From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18079 invoked by alias); 30 May 2014 02:15:20 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 18055 invoked by uid 89); 30 May 2014 02:15:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-pb0-f52.google.com Received: from mail-pb0-f52.google.com (HELO mail-pb0-f52.google.com) (209.85.160.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 30 May 2014 02:15:16 +0000 Received: by mail-pb0-f52.google.com with SMTP id rr13so1165353pbb.39 for ; Thu, 29 May 2014 19:15:14 -0700 (PDT) X-Received: by 10.66.189.226 with SMTP id gl2mr14045017pac.65.1401416114349; Thu, 29 May 2014 19:15:14 -0700 (PDT) Received: from bubble.grove.modra.org ([101.166.26.37]) by mx.google.com with ESMTPSA id ky8sm3458166pbc.64.2014.05.29.19.15.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 19:15:13 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id CC147EA3742; Fri, 30 May 2014 11:45:07 +0930 (CST) Date: Fri, 30 May 2014 02:15:00 -0000 From: Alan Modra To: Chen Gang Cc: jan.kratochvil@redhat.com, drow@false.org, ezannoni@kwikemart.cygnus.com, brobecker@gnat.com, muller@sourceware.org, palves@redhat.com, nickc@redhat.com, macro@linux-mips.org, binutils@sourceware.org Subject: Re: [PATCH] readline/util.c: use '%d' instead of 'ld' to avoid compiling warning Message-ID: <20140530021507.GT6679@bubble.grove.modra.org> Mail-Followup-To: Chen Gang , jan.kratochvil@redhat.com, drow@false.org, ezannoni@kwikemart.cygnus.com, brobecker@gnat.com, muller@sourceware.org, palves@redhat.com, nickc@redhat.com, macro@linux-mips.org, binutils@sourceware.org References: <5387CCBD.7070203@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5387CCBD.7070203@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-05/txt/msg00283.txt.bz2 On Fri, May 30, 2014 at 08:11:41AM +0800, Chen Gang wrote: > getpid() will return 'pid_t' which is always 'int', so need use '%d' > instead of '%ld' in sprintf(). Please do not copy many lists and/or maintainers. This patch should have gone just to gdb-patches@sourceware.org, since readline belongs to the gdb project. Also, gdb and binutils generally require patches to be supplied with a ChangeLog entry. See other posts on the mailing list. Now, on to the substance of your patch. It's wrong to claim that "pid_t" is always "int". I know of systems that use or used to use "short". In fact http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html says "The implementation shall support one or more programming environments in which the widths of blksize_t, pid_t, size_t, ssize_t, and suseconds_t are no greater than the width of type long." So the correct patch would be to cast the return of getpid() to long, continuing to use '%ld' in the format string. > The related warning (cross-compile aarch64): > > ../../binutils-gdb/readline/util.c: In function ‘_rl_tropen’: > ../../binutils-gdb/readline/util.c:510:3: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘__pid_t’ [-Wformat] -- Alan Modra Australia Development Lab, IBM