Fix printf warnings

- Use length specifier "z" for size_t type and "t" for ptrdiff_t.
Fix signed/unsigned comparisons

- Comparisons between size_t/ptrdiff_t require special handling.  The
size_t is strictly larger than ptrdiff_t, so if ptrdiff_t > 0, then we
can safely convert it to size_t.