From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 1/3] utils: provide snprintf helper macro
Date: Thu, 27 Oct 2016 00:36:06 +0200 [thread overview]
Message-ID: <1477521368-12696-2-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1477521368-12696-1-git-send-email-fw@strlen.de>
lifted from libnftnl, except that we will abort on snprintf errors.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/utils.h | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/include/utils.h b/include/utils.h
index d88676476efb..bb58ba424165 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
/**
--
2.7.3
next prev parent reply other threads:[~2016-10-26 22:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 22:36 [PATCH nft 0/3] support ct/meta key lookups at runtime Florian Westphal
2016-10-26 22:36 ` Florian Westphal [this message]
2016-10-26 22:36 ` [PATCH nft 2/3] ct: allow resolving ct keys at run time Florian Westphal
2016-10-26 22:36 ` [PATCH nft 3/3] meta: allow resolving meta " Florian Westphal
2016-10-27 16:48 ` [PATCH nft 0/3] support ct/meta key lookups at runtime Pablo Neira Ayuso
2016-10-27 16:51 ` Pablo Neira Ayuso
2016-10-27 16:58 ` Florian Westphal
2016-10-27 17:16 ` Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477521368-12696-2-git-send-email-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.