public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [libbacktrace,PATCH] Fix non-portable printf format in allocfail.c
@ 2019-01-20 11:48 Gerald Pfeifer
  2019-01-20 15:04 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: Gerald Pfeifer @ 2019-01-20 11:48 UTC (permalink / raw)
  To: gcc-patches, Ian Lance Taylor, Tom de Vries

This addresses another fallout from the libbacktrace changes applied
in November.


libbacktrace/allocfail.c has the following declaration:

  extern uint64_t get_nr_allocs (void);

And in line 133 then the following:

  fprintf (stderr, "%lu\n", get_nr_allocs ());

On a 32-bit system such as x86 this creates a mismatch between %lu 
(32-bit) and the third parameter (64-bit).


The patch below addresses it; tested on i586-unknown-freebsd11.3.

Okay?

Gerald

2019-01-20  Gerald Pfeifer  <gerald@pfeifer.com>

	* allocfail.c (main): Increase portability of printf statement.

Index: libbacktrace/allocfail.c
===================================================================
--- libbacktrace/allocfail.c	(revision 268102)
+++ libbacktrace/allocfail.c	(working copy)
@@ -130,7 +130,7 @@ main (int argc, char **argv)
 #endif
 
   if (argc == 1)
-    fprintf (stderr, "%lu\n", get_nr_allocs ());
+    fprintf (stderr, "%llu\n", (long long unsigned) get_nr_allocs ());
 
   exit (failures ? EXIT_FAILURE : EXIT_SUCCESS);
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [libbacktrace,PATCH] Fix non-portable printf format in allocfail.c
  2019-01-20 11:48 [libbacktrace,PATCH] Fix non-portable printf format in allocfail.c Gerald Pfeifer
@ 2019-01-20 15:04 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 2019-01-20 15:04 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: gcc-patches, Tom de Vries

Gerald Pfeifer <gerald@pfeifer.com> writes:

> 2019-01-20  Gerald Pfeifer  <gerald@pfeifer.com>
>
> 	* allocfail.c (main): Increase portability of printf statement.

This is OK.

Thanks.

Ian

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-20 15:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-20 11:48 [libbacktrace,PATCH] Fix non-portable printf format in allocfail.c Gerald Pfeifer
2019-01-20 15:04 ` Ian Lance Taylor

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).