svn commit: r283869 - head/contrib/diff/src

Bruce Evans brde at optusnet.com.au
Mon Jun 1 08:49:25 UTC 2015


On Mon, 1 Jun 2015, Marcelo Araujo wrote:

> Log:
>  Fix the wrong format, format specifies type 'int' but the argument has type
>  'long', it was spotted by clang.
> ...
> Modified: head/contrib/diff/src/context.c
> ==============================================================================
> --- head/contrib/diff/src/context.c	Mon Jun  1 06:05:53 2015	(r283868)
> +++ head/contrib/diff/src/context.c	Mon Jun  1 06:14:17 2015	(r283869)
> @@ -62,7 +62,7 @@ print_context_label (char const *mark,
> 	{
> 	  time_t sec = inf->stat.st_mtime;
> 	  verify (info_preserved, sizeof inf->stat.st_mtime <= sizeof sec);
> -	  sprintf (buf, "%jd.%.9d", (intmax_t)sec, nsec);
> +	  sprintf (buf, "%jd.%.9ld", (intmax_t)sec, nsec);

It is still a garbage format.  It doesn't even misprint 1 second + 3
nanoseconds as 1.3, which looks like 1 second + 300 million nanoseconds.
It pads the nanoseconds field with leading spaces, so it misprints 1
second + 3 nanoseconds as "1.        3", which is unparsable.

Nanoseconds resolution is too precise for human-readable times, but the
times here are unsuitable for human readingfor other reasons.  They
are apparently for machine reading, but never read.

Bruce


More information about the svn-src-head mailing list