This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] readline/util.c: use '%d' instead of 'ld' to avoid compiling warning


getpid() will return 'pid_t' which is always 'int', so need use '%d'
instead of '%ld' in sprintf().

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]


Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
 readline/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/readline/util.c b/readline/util.c
index 321dee2..05c8abc 100644
--- a/readline/util.c
+++ b/readline/util.c
@@ -507,7 +507,7 @@ _rl_tropen ()
 
   if (_rl_tracefp)
     fclose (_rl_tracefp);
-  sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
+  sprintf (fnbuf, "/var/tmp/rltrace.%d", getpid());
   unlink(fnbuf);
   _rl_tracefp = fopen (fnbuf, "w+");
   return _rl_tracefp != 0;
-- 
1.9.2.459.g68773ac


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]