Hi,

On Sun, Jan 12, 2014 at 12:44:35PM +0100, David Tardon wrote:
> Hi,
> 
> On Sun, Jan 12, 2014 at 10:33:09AM +0000, Rob Kendrick wrote:
> > On Sun, Jan 12, 2014 at 09:42:41AM +0100, David Tardon wrote:
> > >  #include <ctype.h>
> > >  #include <inttypes.h>
> > >  #include <stdbool.h>
> > > +#include <stdint.h>
> > 
> > ...
> > 
> > > - printf("        bytecode len:%ld used:%ld\n", e->bclen, e->bcused);
> > > + printf("        bytecode len:%" PRIuMAX " used:%" PRIuMAX "\n",
> > > +         (uintmax_t) e->bclen, (uintmax_t) e->bcused);
> > 
> > The header for these defines is inttypes.h, I thought?
> 
> stdint.h is for uintmax_t. This is already included through inttypes.h
> on my system, but I am not sure if that is required. Drop the extra
> include if you think it is not needed.

I checked and it is indeed specified htat inttypes.h always includes
stdint.h. So there is the patch again with the extra include removed.

D.
>From a3f019aa770145f65cb6f75e400a9ab2449cd514 Mon Sep 17 00:00:00 2001
From: David Tardon <[email protected]>
Date: Mon, 6 Jan 2014 21:44:34 +0100
Subject: [PATCH] print size_t values in a portable way

---
 test/parse-auto.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/parse-auto.c b/test/parse-auto.c
index 2bbe61e..93ab536 100644
--- a/test/parse-auto.c
+++ b/test/parse-auto.c
@@ -340,12 +341,14 @@ static void report_fail(const uint8_t *data, size_t 
datalen, exp_entry *e)
 
        printf("    Expected entry:\n");
        printf("        entry type:%d name:%s\n", e->type, e->name);
-       printf("        bytecode len:%ld used:%ld\n", e->bclen, e->bcused);
+       printf("        bytecode len:%" PRIuMAX " used:%" PRIuMAX "\n",
+               (uintmax_t) e->bclen, (uintmax_t) e->bcused);
        printf("        bytecode ");
        for (bcoff = 0; bcoff < e->bcused; bcoff++) {
                printf("%.2x ", ((uint8_t *) e->bytecode)[bcoff]);
        }
-       printf("\n        string table len:%ld used %ld\n", e->stlen, 
e->stused);
+       printf("\n        string table len:%" PRIuMAX " used %" PRIuMAX "\n",
+               (uintmax_t) e->stlen, (uintmax_t) e->stused);
 /*
        struct stentry {
                size_t off;
@@ -513,9 +516,9 @@ bool validate_rule_selector(css_rule_selector *s, exp_entry 
*e)
 
                if ((s->style->used * sizeof(css_code_t)) != e->bcused) {
                        printf("FAIL Bytecode lengths differ\n"
-                              "    Got length %ld, Expected %u\n",
-                               (s->style->used * sizeof(css_code_t)), 
-                               (int) e->bcused);
+                              "    Got length %" PRIuMAX ", Expected %" 
PRIuMAX "\n",
+                               (uintmax_t) (s->style->used * 
sizeof(css_code_t)),
+                               (uintmax_t) e->bcused);
                        return true;
                }
 
-- 
1.8.4.2

Reply via email to