extensions: libebt_stp: Eliminate duplicate space in output
Phil Sutter
reviewerPATCH 1/3 extensions: libebt_stp: Eliminate duplicate space in output
No need for print_range() to print a trailing whitespace, caller does this already.
Fixes fd8d7d7e5d911 ("ebtables-nft: add stp match")
Signed-off-by Phil Sutter <[email protected]>
--- extensions/libebt_stp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
extensions/libebt_stp.c +2 -2
@@ -146,9 +146,9 @@ static int parse_range(const char *portstring, void *lower, void *upper,static void print_range (unsigned int l,unsigned int u) {if (l == u) -printf ("%u " , l); +printf ("%u" , l);else -printf ("%u:%u " , l, u); +printf ("%u:%u" , l, u); } static int
Signature · 1 line
2.34.1
Phil Sutter
reviewerPATCH 2/3 extensions: libip6t_dst: Fix output for empty options
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 <[email protected]>
--- extensions/libip6t_dst.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
extensions/libip6t_dst.c +3 -3
@@ -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 =',' ; } }
Signature · 1 line
2.34.1
Phil Sutter
reviewerPATCH 3/3 extensions: TCPOPTSTRIP: Do not print empty options
In reply to Phil SutterNo point in printing anything if none of the bits are set.
Fixes aef4c1e727563 ("libxt_TCPOPTSTRIP")
Signed-off-by Phil Sutter <[email protected]>
--- extensions/libxt_TCPOPTSTRIP.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
extensions/libxt_TCPOPTSTRIP.c +13 -0
@@ -142,6 +142,13 @@ tcpoptstrip_print_list(const struct xt_tcpoptstrip_target_info *info, } } +static bool tcpoptstrip_empty (const struct xt_tcpoptstrip_target_info *info) +{ +static const struct xt_tcpoptstrip_target_info empty = {}; + +return memcmp (info, &empty,sizeof (empty)) ==0 ; +} +static void tcpoptstrip_tg_print (const void *ip,const struct xt_entry_target *target,int numeric)
@@ -149,6 +156,9 @@ tcpoptstrip_tg_print(const void *ip, const struct xt_entry_target *target,const struct xt_tcpoptstrip_target_info *info = (const void *)target->data; +if (tcpoptstrip_empty (info)) +return ; +printf (" TCPOPTSTRIP options " );tcpoptstrip_print_list (info, numeric); }
@@ -159,6 +169,9 @@ tcpoptstrip_tg_save(const void *ip, const struct xt_entry_target *target)const struct xt_tcpoptstrip_target_info *info = (const void *)target->data; +if (tcpoptstrip_empty (info)) +return ; +printf (" --strip-options " );tcpoptstrip_print_list (info, true); }
Signature · 1 line
2.34.1