summaryrefslogtreecommitdiffstats
path: root/src/expr/data_reg.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2025-10-15 23:41:36 +0200
committerPhil Sutter <phil@nwl.cc>2026-01-27 22:59:15 +0100
commit7daf5a4fde637dfc2aee4480c48777b6e5b22aa2 (patch)
tree40621581fad41e6f6ad09daee5b35afc48af4fcc /src/expr/data_reg.c
parent5f72061e6e34328ad40e0f1ffd2b8188356bd5f9 (diff)
expr: data_reg: Avoid extra whitespace
Do not append a space to data regs, they may appear at end of line or followed by a tab. Have callers print the space if needed. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src/expr/data_reg.c')
-rw-r--r--src/expr/data_reg.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c
index fd5e0d6..bf4153c 100644
--- a/src/expr/data_reg.c
+++ b/src/expr/data_reg.c
@@ -25,15 +25,14 @@ nftnl_data_reg_value_snprintf_default(char *buf, size_t remain,
const union nftnl_data_reg *reg,
uint32_t flags)
{
- const char *pfx = flags & DATA_F_NOPFX ? "" : "0x";
+ const char *pfx = flags & DATA_F_NOPFX ? "" : "0x", *sep = "";
int offset = 0, ret, i;
-
-
for (i = 0; i < div_round_up(reg->len, sizeof(uint32_t)); i++) {
ret = snprintf(buf + offset, remain,
- "%s%.8x ", pfx, reg->val[i]);
+ "%s%s%.8x", sep, pfx, reg->val[i]);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
+ sep = " ";
}
return offset;
@@ -46,11 +45,11 @@ nftnl_data_reg_verdict_snprintf_def(char *buf, size_t size,
{
int remain = size, offset = 0, ret = 0;
- ret = snprintf(buf, size, "%s ", nftnl_verdict2str(reg->verdict));
+ ret = snprintf(buf, size, "%s", nftnl_verdict2str(reg->verdict));
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
if (reg->chain != NULL) {
- ret = snprintf(buf + offset, remain, "-> %s ", reg->chain);
+ ret = snprintf(buf + offset, remain, " -> %s", reg->chain);
SNPRINTF_BUFFER_SIZE(ret, remain, offset);
}