X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fdropin.c;h=3c950ada0fb8acf8a869661084088074424d7864;hb=2c6b2d70e6640f39563ad7bb0aa0ba87f883848c;hp=c7b558a4288bad7a06041ab575ad47b3a86b8300;hpb=e16ab7b89948c24a2c47652e8eb1a817a4b1424c;p=tinc diff --git a/src/dropin.c b/src/dropin.c index c7b558a4..3c950ada 100644 --- a/src/dropin.c +++ b/src/dropin.c @@ -1,7 +1,7 @@ /* dropin.c -- a set of drop-in replacements for libc functions Copyright (C) 2000-2005 Ivo Timmermans, - 2000-2016 Guus Sliepen + 2000-2018 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,9 @@ #include "system.h" +#ifndef HAVE_ASPRINTF #include "xalloc.h" +#endif #ifndef HAVE_DAEMON /* @@ -50,8 +52,9 @@ int daemon(int nochdir, int noclose) { } /* If we are the parent, terminate */ - if(pid) + if(pid) { exit(0); + } /* Detach by becoming the new process group leader */ if(setsid() < 0) { @@ -81,6 +84,8 @@ int daemon(int nochdir, int noclose) { return 0; #else + (void)nochdir; + (void)noclose; return -1; #endif } @@ -106,14 +111,14 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); - buf[len - 1] = 0; va_end(aq); - if(status >= 0) + if(status >= 0) { *buf = xrealloc(*buf, status + 1); + } if(status > len - 1) { - len = status; + len = status + 1; va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); va_end(aq); @@ -143,6 +148,7 @@ int gettimeofday(struct timeval *tv, void *tz) { #ifndef HAVE_NANOSLEEP int nanosleep(const struct timespec *req, struct timespec *rem) { + (void)rem; struct timeval tv = {req->tv_sec, req->tv_nsec / 1000}; return select(0, NULL, NULL, NULL, &tv); }