Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jun 2015 18:49:21 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Marcelo Araujo <araujo@freebsd.org>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r283869 - head/contrib/diff/src
Message-ID:  <20150601183442.O1517@besplex.bde.org>
In-Reply-To: <201506010614.t516EHBC062793@svn.freebsd.org>
References:  <201506010614.t516EHBC062793@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150601183442.O1517>