From patchwork Tue Jan 18 05:05:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 12715899 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D653C433F5 for ; Tue, 18 Jan 2022 05:05:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbiARFFR (ORCPT ); Tue, 18 Jan 2022 00:05:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiARFFQ (ORCPT ); Tue, 18 Jan 2022 00:05:16 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4332DC061574 for ; Mon, 17 Jan 2022 21:05:16 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id x83so12845264pgx.4 for ; Mon, 17 Jan 2022 21:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nN9NpJjxaNk+PMjOnDVcI733qB2iOALHz4zWXgC/ixA=; b=y/gfqybBaMY4cAFptBpgB6rIaplVCe+uAazb1aiXsaC3wpsIUOt7TsS+daoIBANdL6 IB8Cpc2IydtMqGrRMErb6S9aO8m64gcE2a4TOW7l3nE20Etea6GKhmGRtvnBw0kucyjr U3VP3HTWPUTC/1Enig04W3q74pJG11ai6fpAkaKoRHPgYsvZE0Kq+908YPNIWYvcHXVF pW8+EdDt2+vIeq506DHL0ab8QdRheSMIeYrsvULPcpI7u1i/+Y2If/mMdJ+VQ3YEI05C SXNIGXHW2YMIPNZXvqJCfTU43sByuLlUN6qnKMHl5kX+FngkUjOqnfugRucLpBzgOhIM R8OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nN9NpJjxaNk+PMjOnDVcI733qB2iOALHz4zWXgC/ixA=; b=eoQr+H31aPoj7pqA9Y0QIVwps+5Lnop6CeAZPWkddz3X/ovh3HRe78/9f//1rd4/VF Sgb2/SFhEegg9ek62EOjuQAxCtE4G6KZsdwUzJfqXQAgD+AA/pCxRrFZmFIRHTh0SBsg hxWlCaeoaH5ZP3PhCYAVadUDa/NAbznnTk2gMF65vQFfmlglS3QTBKcw9GryPuh1nsR8 AJQmc45BcmQQfKjcVKZvGAg0Ki85FfQsNGoQw2ZWJQzlNR6mJA7D5Wt8lFPkpisXiJ1K iZkwyH3neHyRXENROHyvIM5tA+Tnjeabwqu7wabCjkWxa19qxV1KiaSkdMOr0LLlOEMV /xQw== X-Gm-Message-State: AOAM531pAiw9X3Zks1PzPJOxLsTMtBTBWQMf3DypX0MIXwX2Rfm4Tl5a V3X4T62I4urfpKj77b+V6Xc+O9Ds1LjEoQ== X-Google-Smtp-Source: ABdhPJw68/A0JDhVTC2T5XMAK/ngRjUzqJIUIceItHGSZy75Vs9qNyPmfQLiJyr0h2O3ztfcFal/gg== X-Received: by 2002:a05:6a00:1505:b0:4c4:330:b86d with SMTP id q5-20020a056a00150500b004c40330b86dmr9736208pfu.82.1642482315409; Mon, 17 Jan 2022 21:05:15 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id j20sm14987664pfh.22.2022.01.17.21.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 21:05:14 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 1/2] netem: fix checkpatch warnings Date: Mon, 17 Jan 2022 21:05:11 -0800 Message-Id: <20220118050512.14198-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com netem is old and pre-dates checkpatch, so fix it up. Switch to SPDX and remove boilerplate. Signed-off-by: Stephen Hemminger --- tc/q_netem.c | 59 +++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/tc/q_netem.c b/tc/q_netem.c index 2e5a46ab7b25..f45a64b9d554 100644 --- a/tc/q_netem.c +++ b/tc/q_netem.c @@ -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 - * + * Author: Stephen Hemminger */ #include @@ -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; } From patchwork Tue Jan 18 05:05:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 12715900 X-Patchwork-Delegate: stephen@networkplumber.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F3E2C433EF for ; Tue, 18 Jan 2022 05:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbiARFFR (ORCPT ); Tue, 18 Jan 2022 00:05:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiARFFR (ORCPT ); Tue, 18 Jan 2022 00:05:17 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A54C061574 for ; Mon, 17 Jan 2022 21:05:17 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id q25so6316336pfl.8 for ; Mon, 17 Jan 2022 21:05:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pgHBVqzyss5z67PjOd+ce1TqPbJGOrA2LTgEJUVAU04=; b=1qeL+mYH8QS9g/RME3UDJ3ZDiFr5snEElkBOfQWpjN2s7DpUbfSVAzYsiYCyFvbm+4 99jCL3AtNAjXnx25AHwfFV68U0WXwMGCicDrgEO7hikTjy1TBVS3VpLd2u5C1s0007/V lodqr91lWsylRwds9C5sl4UhA+Yj0TRzad8QIPgEeNHJbOw/3PfCVSfPIzMot7h4soH4 OgmZ/dB020pZNAS28NQEWhMOf7tw13GMQdRfHtuxcM6w59tFgy0t49Z314M/vAHGvlmV JrMotWqcgNmKTIuhpc2r5myWzxzXO/nKoOBdQnVnSoqC4Wyz68WMz6L2gqlLQLS3V8cP yCgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pgHBVqzyss5z67PjOd+ce1TqPbJGOrA2LTgEJUVAU04=; b=Y0S2g81QGxpNaKKFZpzG1JUKzJtapD+wwiR0jKmTNfjA7Lm+9J/LaJ0QPi4Ng6Pg3m gqGnfbYQm0fGQj93C38eHv1U9n9mmPuo1dkBnTLd4bSNRfr27iZEIQCGfuLRJTTEPLkH WwvOo5FcO71BREh7HNH+hdLBCuNKpzmVq+/V1LsGEhVoq/FZDfjtemCuOQnIAzPdZGU4 hTZzQF2vVAmTv4OarRW9T/bjQqamr6edqQQ4BR57PFgoU+dcAiiARfgMQK3ZrMa/o4VN Ln4q4SoENUgt9n/9SAeiFGRTkqp2ticFzwCvR/bkq+hWlJtYPxS2rNucI0AQ6eRiz5zp 6+Qw== X-Gm-Message-State: AOAM531Enu03z4YWBhwGEB/E0lwkp397k0tqG0AmsAdwQ3W1Doi6gz/V WBDZCV8gYpuGehtae6KdEnaU3De3cYF3EQ== X-Google-Smtp-Source: ABdhPJyE2qwJ9rZdks3/F8CbhSbj36Awn3GbwpBJZFpJiz5BItENrtwL4Nui++SW2yU3rNp4dR/jbA== X-Received: by 2002:aa7:9483:0:b0:4bf:29d6:75a9 with SMTP id z3-20020aa79483000000b004bf29d675a9mr24334511pfk.36.1642482316328; Mon, 17 Jan 2022 21:05:16 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id j20sm14987664pfh.22.2022.01.17.21.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 21:05:15 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH iproute2 2/2] f_flower: fix checkpatch warnings Date: Mon, 17 Jan 2022 21:05:12 -0800 Message-Id: <20220118050512.14198-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118050512.14198-1-stephen@networkplumber.org> References: <20220118050512.14198-1-stephen@networkplumber.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com Fix minor whitespace and other easy to fix complaints from checkpatch. Signed-off-by: Stephen Hemminger --- tc/f_flower.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tc/f_flower.c b/tc/f_flower.c index 6d70b92a2894..728b280c708c 100644 --- a/tc/f_flower.c +++ b/tc/f_flower.c @@ -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); }