From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Murray Date: Thu, 1 Sep 2011 00:30:36 +0100 Subject: [U-Boot] [PATCH 3/7] Add timing information to printf's for use with bootgraph.pl In-Reply-To: <201108311847.16042.vapier@gentoo.org> References: <1314829261-13996-1-git-send-email-amurray@theiet.org> <1314829261-13996-4-git-send-email-amurray@theiet.org> <201108311847.16042.vapier@gentoo.org> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 31 August 2011 23:47, Mike Frysinger wrote: > On Wednesday, August 31, 2011 18:20:57 Andrew Murray wrote: >> ? ? ? va_list args; >> ? ? ? uint i; >> ? ? ? char printbuffer[CONFIG_SYS_PBSIZE]; >> + ? ? char *buf = printbuffer; >> >> ? ? ? va_start(args, fmt); >> >> +#if defined(CONFIG_BOOT_TRACE) >> + ? ? unsigned long long ticks = get_ticks(); >> + ? ? int secs = ticks / get_tbclk(); >> + ? ? int msec = ((ticks * 1000000) / get_tbclk()) - (secs * 1000000); >> + >> + ? ? i += sprintf(buf, "[%5lu.%06lu] ", secs, msec); >> + ? ? buf += i; >> +#endif >> + >> ? ? ? /* For this to work, printbuffer must be larger than >> ? ? ? ?* anything we ever want to print. >> ? ? ? ?*/ >> - ? ? i = vsprintf(printbuffer, fmt, args); >> + ? ? i += vsprintf(buf, fmt, args); >> ? ? ? va_end(args); > > NAK for a few reasons: > ?- i dont see how this could possibly compile warning free > ?- you never initialize "i", only added to it > ?- you call va_start() inbetween variable decls > -mike > Yes this does look dreadful - I'll update the patch pending outcome of thread with Simon Glass and existing work in this area. Andrew Murray