X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fdebug.h;h=911a440fb0f83feb30c039351cd2216a81958c28;hb=2c55827f6f2c231a8f166e015df4c5c3818c8ba4;hp=4a7c00bc107949f2a9ab5b7aaea3c3c1452a429e;hpb=357a499884543ec285238c9ec6c53565fa4d5b48;p=coloredstderr%2Fcoloredstderr.git diff --git a/src/debug.h b/src/debug.h index 4a7c00b..911a440 100644 --- a/src/debug.h +++ b/src/debug.h @@ -24,8 +24,10 @@ static void debug_write(int fd, int first_call, char const *format, va_list ap) char buffer[1024]; int written = vsnprintf(buffer, sizeof(buffer), format, ap); + if (written < 0) { + return; /* shouldn't happen */ /* Overflow. */ - if ((size_t)written >= sizeof(buffer)) { + } else if ((size_t)written >= sizeof(buffer)) { written = sizeof(buffer) - 1; } @@ -34,7 +36,7 @@ static void debug_write(int fd, int first_call, char const *format, va_list ap) DLSYM_FUNCTION(real_close, "close"); if (first_call) { - char nl = '\n'; + char const nl = '\n'; real_write(fd, &nl, 1); } real_write(fd, buffer, (size_t)written);