From: Marko Kreen Date: Mon, 12 Apr 2010 09:14:49 +0000 (+0300) Subject: logging: fix signed vs. unsigned cmp warning X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=06dd57b1300401d69a55c0e6c8d07b9862297333;p=libusual.git logging: fix signed vs. unsigned cmp warning --- diff --git a/usual/logging.c b/usual/logging.c index 2237531..36e34e4 100644 --- a/usual/logging.c +++ b/usual/logging.c @@ -106,6 +106,8 @@ void log_generic(enum LogLevel level, void *ctx, const char *fmt, ...) pfxlen = logging_prefix_cb(level, ctx, buf, sizeof(buf)); if (pfxlen < 0) return; + if (pfxlen >= (int)sizeof(buf)) + pfxlen = sizeof(buf) - 1; } va_start(ap, fmt); vsnprintf(buf + pfxlen, sizeof(buf) - pfxlen, fmt, ap);