netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: netfilter-devel@vger.kernel.org
Subject: [iptables PATCH 2/3] extensions: libip6t_dst: Fix output for empty options
Date: Sun,  2 Oct 2022 01:39:05 +0200	[thread overview]
Message-ID: <20221001233906.5386-2-phil@nwl.cc> (raw)
In-Reply-To: <20221001233906.5386-1-phil@nwl.cc>

If no --dst-opts were given, print_options() would print just a
whitespace.

Fixes: 73866357e4a7a ("iptables: do not print trailing whitespaces")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 extensions/libip6t_dst.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/extensions/libip6t_dst.c b/extensions/libip6t_dst.c
index bf0e3e436665d..baa010f56ac22 100644
--- a/extensions/libip6t_dst.c
+++ b/extensions/libip6t_dst.c
@@ -125,15 +125,15 @@ static void
 print_options(unsigned int optsnr, uint16_t *optsp)
 {
 	unsigned int i;
+	char sep = ' ';
 
-	printf(" ");
 	for(i = 0; i < optsnr; i++) {
-		printf("%d", (optsp[i] & 0xFF00) >> 8);
+		printf("%c%d", sep, (optsp[i] & 0xFF00) >> 8);
 
 		if ((optsp[i] & 0x00FF) != 0x00FF)
 			printf(":%d", (optsp[i] & 0x00FF));
 
-		printf("%c", (i != optsnr - 1) ? ',' : ' ');
+		sep = ',';
 	}
 }
 
-- 
2.34.1


  reply	other threads:[~2022-10-01 23:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-01 23:39 [iptables PATCH 1/3] extensions: libebt_stp: Eliminate duplicate space in output Phil Sutter
2022-10-01 23:39 ` Phil Sutter [this message]
2022-10-01 23:39 ` [iptables PATCH 3/3] extensions: TCPOPTSTRIP: Do not print empty options Phil Sutter

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=20221001233906.5386-2-phil@nwl.cc \
    --to=phil@nwl.cc \
    --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 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).