From d9c2a6cf943ca08f31f61a3fada940f77e3a03d3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 11 Jan 2016 12:09:23 +0100 Subject: [SERVER] Fix a lot of (mostly harmless) data races --- src/shared/log.c | 6 +++--- src/shared/sockhelper.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/shared') diff --git a/src/shared/log.c b/src/shared/log.c index 6d77dc5..da27392 100644 --- a/src/shared/log.c +++ b/src/shared/log.c @@ -82,12 +82,12 @@ void logadd(const logmask_t mask, const char *fmt, ...) va_list ap; int ret; time_t rawtime; - struct tm *timeinfo; + struct tm timeinfo; char buffer[LINE_LEN]; time( &rawtime ); - timeinfo = localtime( &rawtime ); - size_t offset = strftime( buffer, LINE_LEN, "[%d.%m. %H:%M:%S] ", timeinfo ); + localtime_r( &rawtime, &timeinfo ); + size_t offset = strftime( buffer, LINE_LEN, "[%d.%m. %H:%M:%S] ", &timeinfo ); offset += writeLevel( buffer + offset, mask ); va_start( ap, fmt ); ret = vsnprintf( buffer + offset, LINE_LEN - offset, fmt, ap ); diff --git a/src/shared/sockhelper.c b/src/shared/sockhelper.c index e93d45c..d1dbd8c 100644 --- a/src/shared/sockhelper.c +++ b/src/shared/sockhelper.c @@ -207,7 +207,7 @@ int sock_printable(struct sockaddr *addr, socklen_t addrLen, char *output, int l bool sock_listen(poll_list_t* list, char* bind_addr, uint16_t port) { if ( list->count >= MAXLISTEN ) return false; - struct addrinfo hints, *res, *ptr; + struct addrinfo hints, *res = NULL, *ptr; char portStr[6]; const int on = 1; int openCount = 0; -- cgit v1.2.3-55-g7522