* [PATCH libnftnl 1/3] expr: numgen: use switch to handle numgen types from snprintf
@ 2016-08-30 10:41 Pablo Neira Ayuso
2016-08-30 10:41 ` [PATCH libnftnl 2/3] expr: numgen: add missing trailing whitespace Pablo Neira Ayuso
2016-08-30 10:41 ` [PATCH libnftnl 3/3] expr: hash: missing trailing space and modulus in hexadecimal in snprintf Pablo Neira Ayuso
0 siblings, 2 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-30 10:41 UTC (permalink / raw)
To: netfilter-devel
Use switch instead of if branch.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/expr/numgen.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/expr/numgen.c b/src/expr/numgen.c
index 0981d72..7be8270 100644
--- a/src/expr/numgen.c
+++ b/src/expr/numgen.c
@@ -189,16 +189,17 @@ nftnl_expr_ng_snprintf_default(char *buf, size_t size,
struct nftnl_expr_ng *ng = nftnl_expr_data(e);
int len = size, offset = 0, ret;
- if (ng->type == NFT_NG_INCREMENTAL) {
+ switch (ng->type) {
+ case NFT_NG_INCREMENTAL:
ret = snprintf(buf, len, "reg %u = inc(%u)", ng->dreg,
ng->until);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
- }
-
- if (ng->type == NFT_NG_RANDOM) {
+ break;
+ case NFT_NG_RANDOM:
ret = snprintf(buf, len, "reg %u = random(%u)", ng->dreg,
ng->until);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ break;
}
return offset;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH libnftnl 2/3] expr: numgen: add missing trailing whitespace
2016-08-30 10:41 [PATCH libnftnl 1/3] expr: numgen: use switch to handle numgen types from snprintf Pablo Neira Ayuso
@ 2016-08-30 10:41 ` Pablo Neira Ayuso
2016-08-30 10:41 ` [PATCH libnftnl 3/3] expr: hash: missing trailing space and modulus in hexadecimal in snprintf Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-30 10:41 UTC (permalink / raw)
To: netfilter-devel
Before patch:
[ numgen reg 1 = inc(2)]
After patch:
[ numgen reg 1 = inc(2) ]
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/expr/numgen.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/expr/numgen.c b/src/expr/numgen.c
index 7be8270..e8fa9a1 100644
--- a/src/expr/numgen.c
+++ b/src/expr/numgen.c
@@ -191,12 +191,12 @@ nftnl_expr_ng_snprintf_default(char *buf, size_t size,
switch (ng->type) {
case NFT_NG_INCREMENTAL:
- ret = snprintf(buf, len, "reg %u = inc(%u)", ng->dreg,
+ ret = snprintf(buf, len, "reg %u = inc(%u) ", ng->dreg,
ng->until);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
break;
case NFT_NG_RANDOM:
- ret = snprintf(buf, len, "reg %u = random(%u)", ng->dreg,
+ ret = snprintf(buf, len, "reg %u = random(%u) ", ng->dreg,
ng->until);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
break;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH libnftnl 3/3] expr: hash: missing trailing space and modulus in hexadecimal in snprintf
2016-08-30 10:41 [PATCH libnftnl 1/3] expr: numgen: use switch to handle numgen types from snprintf Pablo Neira Ayuso
2016-08-30 10:41 ` [PATCH libnftnl 2/3] expr: numgen: add missing trailing whitespace Pablo Neira Ayuso
@ 2016-08-30 10:41 ` Pablo Neira Ayuso
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-30 10:41 UTC (permalink / raw)
To: netfilter-devel
Before patch:
[ hash reg 1 = jhash(reg 2, 8, 3735928559) % modulus 2]
After patch:
[ hash reg 1 = jhash(reg 2, 8, 0xdeadbeef) % mod 2 ]
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/expr/hash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/expr/hash.c b/src/expr/hash.c
index a3439d8..2d61508 100644
--- a/src/expr/hash.c
+++ b/src/expr/hash.c
@@ -235,7 +235,7 @@ nftnl_expr_hash_snprintf_default(char *buf, size_t size,
struct nftnl_expr_hash *hash = nftnl_expr_data(e);
int len = size, offset = 0, ret;
- ret = snprintf(buf, len, "reg %u = jhash(reg %u, %u, %u) %% modulus %u",
+ ret = snprintf(buf, len, "reg %u = jhash(reg %u, %u, 0x%x) %% mod %u ",
hash->dreg, hash->sreg, hash->len, hash->seed,
hash->modulus);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-30 10:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30 10:41 [PATCH libnftnl 1/3] expr: numgen: use switch to handle numgen types from snprintf Pablo Neira Ayuso
2016-08-30 10:41 ` [PATCH libnftnl 2/3] expr: numgen: add missing trailing whitespace Pablo Neira Ayuso
2016-08-30 10:41 ` [PATCH libnftnl 3/3] expr: hash: missing trailing space and modulus in hexadecimal in snprintf Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).