netem: fix checkpatch warnings
Subsystems (2)
PATCH 1/2 netem: fix checkpatch warnings
netem is old and pre-dates checkpatch, so fix it up. Switch to SPDX and remove boilerplate.
Signed-off-by Stephen Hemminger <[email protected]>
--- tc/q_netem.c | 59 +++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 33 deletions(-)
tc/q_netem.c +26 -33
@@ -1,13 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* -* q_netem.c NETEM. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version -* 2 of the License, or (at your option) any later version. -* -* Authors: Stephen Hemminger <[email protected]> -* +* Author: Stephen Hemminger <[email protected]> */ #include <stdio.h>
@@ -30,22 +23,20 @@static void explain (void ) {fprintf (stderr, -"Usage: ... netem [ limit PACKETS ]\n" \ -" [ delay TIME [ JITTER [CORRELATION]]]\n" \ -" [ distribution {uniform|normal|pareto|paretonormal} ]\n" \ -" [ corrupt PERCENT [CORRELATION]]\n" \ -" [ duplicate PERCENT [CORRELATION]]\n" \ -" [ loss random PERCENT [CORRELATION]]\n" \ -" [ loss state P13 [P31 [P32 [P23 P14]]]\n" \ -" [ loss gemodel PERCENT [R [1-H [1-K]]]\n" \ -" [ ecn ]\n" \ -" [ reorder PERCENT [CORRELATION] [ gap DISTANCE ]]\n" \ -" [ rate RATE [PACKETOVERHEAD] [CELLSIZE] [CELLOVERHEAD]]\n" \ -" [ slot MIN_DELAY [MAX_DELAY] [packets MAX_PACKETS]" \ -" [bytes MAX_BYTES]]\n" \ -" [ slot distribution" \ -" {uniform|normal|pareto|paretonormal|custom} DELAY JITTER" \ -" [packets MAX_PACKETS] [bytes MAX_BYTES]]\n" ); +"Usage: ... netem [ limit PACKETS ]\n" +" [ delay TIME [ JITTER [CORRELATION]]]\n" +" [ distribution {uniform|normal|pareto|paretonormal} ]\n" +" [ corrupt PERCENT [CORRELATION]]\n" +" [ duplicate PERCENT [CORRELATION]]\n" +" [ loss random PERCENT [CORRELATION]]\n" +" [ loss state P13 [P31 [P32 [P23 P14]]]\n" +" [ loss gemodel PERCENT [R [1-H [1-K]]]\n" +" [ ecn ]\n" +" [ reorder PERCENT [CORRELATION] [ gap DISTANCE ]]\n" +" [ rate RATE [PACKETOVERHEAD] [CELLSIZE] [CELLOVERHEAD]]\n" +" [ slot MIN_DELAY [MAX_DELAY] [packets MAX_PACKETS] [bytes MAX_BYTES]]\n" +" [ slot distribution {uniform|normal|pareto|paretonormal|custom}\n" +" DELAY JITTER [packets MAX_PACKETS] [bytes MAX_BYTES]]\n" ); }static void explain1 (const char *arg)
@@ -138,7 +129,8 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)char name[128 ];snprintf (name,sizeof (name),"%s/%s.dist" ,get_tc_lib (), type); -if ((f =fopen (name,"r" )) ==NULL ) { + f =fopen (name,"r" ); +if (f ==NULL ) {fprintf (stderr,"No distribution data for %s (%s: %s)\n" , type, name,strerror (errno));return -1 ;
@@ -175,8 +167,10 @@ static int get_distribution(const char *type, __s16 *data, int maxdata)#define NEXT_IS_SIGNED_NUMBER () \ (NEXT_ARG_OK() && (isdigit(argv[1][0]) || argv[1][0] == '-')) -/* Adjust for the fact that psched_ticks aren't always usecs -(based on kernel PSCHED_CLOCK configuration */ +/* +* Adjust for the fact that psched_ticks aren't always usecs +* (based on kernel PSCHED_CLOCK configuration +*/ static int get_ticks (__u32 *ticks,const char *str) {unsigned int t;
@@ -258,7 +252,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,if (!strcmp (*argv,"random" )) {NEXT_ARG (); - random_loss_model: +random_loss_model:if (get_percent (&opt.loss, *argv)) {explain1 ("loss percent" );return -1 ;
@@ -523,6 +517,7 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv,if (NEXT_ARG_OK () &&matches (*(argv+1 ),"bytes" ) ==0 ) {unsigned int max_bytes; +NEXT_ARG ();if (!NEXT_ARG_OK () ||get_size (&max_bytes, *(argv+1 ))) {
@@ -532,11 +527,9 @@ static int netem_parse_opt(struct qdisc_util *qu, int argc, char **argv, slot.max_bytes = (int ) max_bytes;NEXT_ARG (); } - }else if (strcmp (*argv,"help" ) ==0 ) { -explain (); -return -1 ; }else { -fprintf (stderr,"What is \"%s\"?\n" , *argv); +if (strcmp (*argv,"help" ) !=0 ) +fprintf (stderr,"What is \"%s\"?\n" , *argv);explain ();return -1 ; }
Signature · 1 line
2.30.2
PATCH 2/2 f_flower: fix checkpatch warnings
Fix minor whitespace and other easy to fix complaints from checkpatch.
Signed-off-by Stephen Hemminger <[email protected]>
--- tc/f_flower.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
tc/f_flower.c +7 -11
@@ -84,7 +84,7 @@ static void explain(void)" geneve_opts MASKED-OPTIONS |\n" " vxlan_opts MASKED-OPTIONS |\n" " erspan_opts MASKED-OPTIONS |\n" -" ip_flags IP-FLAGS | \n" +" ip_flags IP-FLAGS |\n" " enc_dst_port [ port_number ] |\n" " ct_state MASKED_CT_STATE |\n" " ct_label MASKED_CT_LABEL |\n"
@@ -118,7 +118,7 @@ static int flower_parse_eth_addr(char *str, int addr_type, int mask_type,addattr_l (n,MAX_MSG , addr_type, addr,sizeof (addr));if (slash) { -unsigned bits; +unsigned int bits;if (!get_unsigned (&bits, slash +1 ,10 )) {uint64_t mask;
@@ -529,8 +529,7 @@ static int flower_parse_u8(char *str, int value_type, int mask_type, ret =get_u8 (&mask, slash +1 ,10 );if (ret) goto err; - } -else { + }else { mask =UINT8_MAX ; }
@@ -1865,11 +1864,9 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,return -1 ; }continue ; - }else if (strcmp (*argv,"help" ) ==0 ) { -explain (); -return -1 ; }else { -fprintf (stderr,"What is \"%s\"?\n" , *argv); +if (strcmp (*argv,"help" ) !=0 ) +fprintf (stderr,"What is \"%s\"?\n" , *argv);explain ();return -1 ; }
@@ -1917,7 +1914,7 @@ static int __mask_bits(char *addr, size_t len) bits++; }else if (bits) { hole = true; - }else { + }else {return -1 ; } }
@@ -2780,8 +2777,7 @@ static int flower_print_opt(struct filter_util *qu, FILE *f,print_uint (PRINT_ANY ,"in_hw_count" ," in_hw_count %u" , count); } - } -else if (flags &TCA_CLS_FLAGS_NOT_IN_HW ) { + }else if (flags &TCA_CLS_FLAGS_NOT_IN_HW ) {print_nl ();print_bool (PRINT_ANY ,"not_in_hw" ," not_in_hw" , true); }
Signature · 1 line
2.30.2