From: Alan Modra <amodra@gmail.com>
To: Chen Gang <gang.chen.5i5j@gmail.com>
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
Date: Fri, 30 May 2014 02:15:00 -0000 [thread overview]
Message-ID: <20140530021507.GT6679@bubble.grove.modra.org> (raw)
In-Reply-To: <5387CCBD.7070203@gmail.com>
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
next prev parent reply other threads:[~2014-05-30 2:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 0:11 Chen Gang
2014-05-30 2:15 ` Alan Modra [this message]
2014-05-30 2:22 ` Alan Modra
2014-05-30 2:28 ` Chen Gang
2014-05-30 2:50 ` Chen Gang
2014-05-30 8:27 ` Pedro Alves
[not found] ` <87lhtj7han.fsf@igel.home>
2014-05-30 16:43 ` Chen Gang
2014-09-15 11:14 ` Chen Gang
2014-05-30 17:02 Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140530021507.GT6679@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=brobecker@gnat.com \
--cc=drow@false.org \
--cc=ezannoni@kwikemart.cygnus.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=jan.kratochvil@redhat.com \
--cc=macro@linux-mips.org \
--cc=muller@sourceware.org \
--cc=nickc@redhat.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).