From: Zebity Spring Date: Thu, 24 Oct 2019 11:08:22 +0000 (+1100) Subject: Fix conflict from remove of ssnprintf2 and align utils/common/common.h X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=1137e9e5025a3413da5539bbaeb19b0a37ba9fc0;hp=b5b5d43f302e0b9290d3e247ea29699814d46abb Fix conflict from remove of ssnprintf2 and align utils/common/common.h --- diff --git a/src/collectdctl.c b/src/collectdctl.c index df83b50b..3974fd06 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -81,8 +81,7 @@ extern char *optarg; extern int optind; -/* ssnprintf returns zero on success, one if truncation occurred - and a negative integer onerror. */ +/* _ssnprintf returns result from vsnprintf (consistent with snprintf) */ static int _ssnprintf(char *str, size_t sz, const char *format, ...) { va_list ap; va_start(ap, format); @@ -91,10 +90,7 @@ static int _ssnprintf(char *str, size_t sz, const char *format, ...) { va_end(ap); - if (ret < 0) { - return ret; - } - return (size_t)ret >= sz; + return ret; } /* int _ssnprintf */ __attribute__((noreturn)) static void exit_usage(const char *name, int status) { diff --git a/src/utils/common/common.c b/src/utils/common/common.c index 6a0ac28f..aad767ea 100644 --- a/src/utils/common/common.c +++ b/src/utils/common/common.c @@ -89,8 +89,7 @@ char *sstrncpy(char *dest, const char *src, size_t n) { return dest; } /* char *sstrncpy */ -/* ssnprintf returns zero on success, one if truncation occurred - and a negative integer onerror. */ +/* ssnprintf returns result from vsnprintf conistent with snprintf */ int ssnprintf(char *str, size_t sz, const char *format, ...) { va_list ap; va_start(ap, format);