[libbacktrace] Fix non-portable printf format in allocfail.c

Message ID alpine.LSU.2.21.1901192332380.5414@anthias.pfeifer.com
State New
Headers show
Series
  • [libbacktrace] Fix non-portable printf format in allocfail.c
Related show

Commit Message

Gerald Pfeifer Jan. 20, 2019, 11:48 a.m.
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.

Comments

Ian Lance Taylor Jan. 20, 2019, 3:04 p.m. | #1
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

Patch

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);
 }