fix format-of-pointer warnings on 32bits architectures

(report by Kakadu)

The format `"%ld"` cannot be portably used for values of type
`code_t`; one can use `"%" ARCH_INTNAT_PRINTF_FORMAT "d"` instead, as
intnat is configured to be the integer type of pointer size.
master
Gabriel Scherer 2015-12-31 19:45:37 +01:00
parent 43e8cc9ae1
commit a80d536bdb
1 changed files with 7 additions and 4 deletions

View File

@ -183,19 +183,21 @@ caml_trace_value_file (value v, code_t prog, int proglen, FILE * f)
if (prog && v % sizeof (int) == 0
&& (code_t) v >= prog
&& (code_t) v < (code_t) ((char *) prog + proglen))
fprintf (f, "=code@%ld", (code_t) v - prog);
fprintf (f, "=code@%" ARCH_INTNAT_PRINTF_FORMAT "d", (code_t) v - prog);
else if (Is_long (v))
fprintf (f, "=long%" ARCH_INTNAT_PRINTF_FORMAT "d", Long_val (v));
else if ((void*)v >= (void*)caml_stack_low
&& (void*)v < (void*)caml_stack_high)
fprintf (f, "=stack_%ld", (intnat*)caml_stack_high - (intnat*)v);
fprintf (f, "=stack_%" ARCH_INTNAT_PRINTF_FORMAT "d",
(intnat*)caml_stack_high - (intnat*)v);
else if (Is_block (v)) {
int s = Wosize_val (v);
int tg = Tag_val (v);
int l = 0;
switch (tg) {
case Closure_tag:
fprintf (f, "=closure[s%d,cod%ld]", s, (code_t) (Code_val (v)) - prog);
fprintf (f, "=closure[s%d,cod%" ARCH_INTNAT_PRINTF_FORMAT "d]",
s, (code_t) (Code_val (v)) - prog);
goto displayfields;
case String_tag:
l = caml_string_length (v);
@ -250,7 +252,8 @@ caml_trace_accu_sp_file (value accu, value * sp, code_t prog, int proglen,
value *p;
fprintf (f, "accu=");
caml_trace_value_file (accu, prog, proglen, f);
fprintf (f, "\n sp=%#" ARCH_INTNAT_PRINTF_FORMAT "x @%ld:",
fprintf (f, "\n sp=%#" ARCH_INTNAT_PRINTF_FORMAT "x "
"@%" ARCH_INTNAT_PRINTF_FORMAT "d:",
(intnat) sp, caml_stack_high - sp);
for (p = sp, i = 0; i < 12 + (1 << caml_trace_level) && p < caml_stack_high;
p++, i++) {