diff options
author | Florian Westphal <fw@strlen.de> | 2016-07-27 15:22:25 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2016-10-27 22:34:31 +0200 |
commit | 2c6a3b7c4f662b7a94a8ba6870565a45df0cbe2c (patch) | |
tree | fde8efcc7449fbd9d11722e158a1eba690f86793 /include/utils.h | |
parent | 986aa0a5aea34ebb17a3abc03f01cc232a90ebd1 (diff) |
utils: provide snprintf helper macro
lifted from libnftnl, except that we will abort on snprintf errors.
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/utils.h')
-rw-r--r-- | include/utils.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/utils.h b/include/utils.h index d8867647..bb58ba42 100644 --- a/include/utils.h +++ b/include/utils.h @@ -83,6 +83,16 @@ (void) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) +#define SNPRINTF_BUFFER_SIZE(ret, size, len, offset) \ + if (ret < 0) \ + abort(); \ + offset += ret; \ + assert(ret < len); \ + if (ret > len) \ + ret = len; \ + size += ret; \ + len -= ret; + #define MSEC_PER_SEC 1000L /** |