[pacman-dev] use consistent time notation for the log

Message ID 20190608195045.1390-1-andrew.gregory.8@gmail.com
State Accepted, archived
Headers show
Series [pacman-dev] use consistent time notation for the log | expand

Commit Message

Andrew Gregory June 8, 2019, 7:50 p.m. UTC
%X is locale-dependent, making it impossible to reliably parse and
potentially overflowing the buffer.  %T is consistent across locales.

Also fixes some adjacent whitespace.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
 lib/libalpm/log.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Allan McRae June 20, 2019, 7:01 a.m. UTC | #1
On 9/6/19 5:50 am, Andrew Gregory wrote:
> %X is locale-dependent, making it impossible to reliably parse and
> potentially overflowing the buffer.  %T is consistent across locales.
> 
> Also fixes some adjacent whitespace.
> 
> Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
> ---

OK.

Thanks,
A

Patch

diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c
index d8842a55..2ff5544b 100644
--- a/lib/libalpm/log.c
+++ b/lib/libalpm/log.c
@@ -39,11 +39,11 @@  static int _alpm_log_leader(FILE *f, const char *prefix)
 {
 	time_t t = time(NULL);
 	struct tm *tm = localtime(&t);
-    int length = 32;
-    char timestamp[length];
+	int length = 32;
+	char timestamp[length];
 
 	/* Use ISO-8601 date format */
-    strftime(timestamp,length,"%FT%X%z", tm);
+	strftime(timestamp,length,"%FT%T%z", tm);
 	return fprintf(f, "[%s] [%s] ", timestamp, prefix);
 }