From patchwork Tue Feb 1 04:28:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 12731394 X-Patchwork-Delegate: dsahern@gmail.com 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 4A560C433EF for ; Tue, 1 Feb 2022 04:28:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233441AbiBAE2Y (ORCPT ); Mon, 31 Jan 2022 23:28:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232890AbiBAE2X (ORCPT ); Mon, 31 Jan 2022 23:28:23 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4EE2C061714 for ; Mon, 31 Jan 2022 20:28:23 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id z14-20020a17090ab10e00b001b6175d4040so1435909pjq.0 for ; Mon, 31 Jan 2022 20:28:23 -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=g+QlftrcaXfoEEpJhh1t78sHHpIFJnjZ0IbJpz4Ch7Y=; b=lT0i5q3ii0Nr5lJgP+ZL9zoyNWzc1ldlWtnmwQBt1NuPqYh0H8uzKdJ7J3QqStu2xo MlfTc8IBgRk3j/Xsn+QfHC8Gl5SozgfTBNn+gu8CYq8GGEp1ITBRKmpf/kGIrehxgpVy ASJTDnqEeIVhgZwZB9awPkl+jZQZONoiDG6gG/TWLeNn8bXNllDR2l1URYGtPmSGXLhl hYoTJVJg4IwnjIxLWnWJJM0nkiK/ptqDqF7mmT3k3DVIRrPVhxL1f7rNNZuEMTeySzqq ZatwHlKwSnrriFV1kCNAcq+jaguWlSS3QacRQdMJB3nOgGHbZSp+TOkr5FZaA1QgS5N0 4R9g== 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=g+QlftrcaXfoEEpJhh1t78sHHpIFJnjZ0IbJpz4Ch7Y=; b=kH2dYPPlAfQpTFr3A5gPGeeH/W7S7gdu4oBYIt6bFz5+LTwwSUQ3jvKTwd1wmJGsbd qHYSDkAcQDlb708iNkr26hwpf44UKWs3li2+wY5mwUw5Fdci5yQVEFguNlTX+od/uQLX tctoHUBO4kiN92kL3bGdgmhxdz+V9vbyGkb6Q5rbYmxZd/QhJvPNX/jd+UY6ddiJcnEK RCLVh22yqYTrVizHPED0qOm11c4h9bAzMZ05LVyGv/JD3rkmI5kJtltp4ojA+Uf7f2D7 HvF9Af+BQk42LICewqFPwJhQTpYwYrohfifr3DGizB0i1dlpx7P+9JY3AAfkK/xfqRn+ nhbQ== X-Gm-Message-State: AOAM533R2bDLSYr2m7K2GrIfTThz61KsAaY/Yjohw8r3Dohd1w4MFUBl tYNi7K2xFOZl9A3a2THtA7rDLg== X-Google-Smtp-Source: ABdhPJwG+bFt51qvRhkS7o3hWO07JoYabSANgVn81zoKHdO+pBJTKg3eqURSr084YMpi/Lboggk1+g== X-Received: by 2002:a17:90a:d188:: with SMTP id fu8mr267471pjb.60.1643689703230; Mon, 31 Jan 2022 20:28:23 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id l8sm20441335pfc.187.2022.01.31.20.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 20:28:22 -0800 (PST) From: Stephen Hemminger To: dsahern@gmail.com Cc: netdev@vger.kernel.org, Victor Nogueira , Jamal Hadi Salim , Stephen Hemminger Subject: [PATCH iproute2-next 1/2] tc_util: fix breakage from clang changes Date: Mon, 31 Jan 2022 20:28:18 -0800 Message-Id: <20220201042819.322106-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com This fixes the indentation of types with newline flag. Signed-off-by: Stephen Hemminger --- The clang changes merged an earlier version of the changes to print_masked_type. tc/tc_util.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/tc/tc_util.c b/tc/tc_util.c index 67960d2c03d7..78cb9901f7b9 100644 --- a/tc/tc_util.c +++ b/tc/tc_util.c @@ -784,8 +784,6 @@ static void print_masked_type(__u32 type_max, struct rtattr *mask_attr, bool newline) { __u32 value, mask; - SPRINT_BUF(out); - size_t done; if (!attr) return; @@ -793,21 +791,18 @@ static void print_masked_type(__u32 type_max, value = rta_getattr_type(attr); mask = mask_attr ? rta_getattr_type(mask_attr) : type_max; - if (is_json_context()) { - print_hu(PRINT_JSON, name, NULL, value); - if (mask != type_max) { - char mask_name[SPRINT_BSIZE-6]; + if (newline) + print_string(PRINT_FP, NULL, "%s ", _SL_); + else + print_string(PRINT_FP, NULL, " ", _SL_); - sprintf(mask_name, "%s_mask", name); - print_hu(PRINT_JSON, mask_name, NULL, mask); - } - } else { - done = sprintf(out, "%u", value); - if (mask != type_max) - sprintf(out + done, "/0x%x", mask); + print_uint_name_value(name, value); + + if (mask != type_max) { + char mask_name[SPRINT_BSIZE-6]; - print_nl(); - print_string_name_value(name, out); + snprintf(mask_name, sizeof(mask_name), "%s_mask", name); + print_hex(PRINT_ANY, mask_name, "/0x%x", mask); } } From patchwork Tue Feb 1 04:28:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 12731395 X-Patchwork-Delegate: dsahern@gmail.com 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 AA338C433F5 for ; Tue, 1 Feb 2022 04:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbiBAE20 (ORCPT ); Mon, 31 Jan 2022 23:28:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233450AbiBAE2Y (ORCPT ); Mon, 31 Jan 2022 23:28:24 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0C18C061714 for ; Mon, 31 Jan 2022 20:28:24 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id l13so5723168plg.9 for ; Mon, 31 Jan 2022 20:28:24 -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=rlG4REPOvHPZswdOoTuu1A8AEMNjKEsA0Bsepvhgcvs=; b=l450vmeV10TGSXR3/Pwka9DfQNr4fvuBp1Fmny/U6ELJ4BZAWV5lwnmo95K05ZePNW xRNq1vVfRXE/opYB8FEWkP1T1DvwhMBTnQu8/F0l/q2ExkXeZ3GpLTQElzRyADxmrK2p DijPRe/0CYleTreJvdClfmbhpR87k0hrMgef5WpgYlq4QaMFoXd34Jh3kNthgStOUp/Q wcYPaZFqw57cMu0UEqAZMv9JB4mKKETKvW1KrK0AkIzKIDas3CpqgfWrGAadfFnAs5hU IUKpEm95te47iJkhxOk7VlVYZh77yfMC9tIJJRpcBEyxyilV4lhf0QxG7EZ4+0p4Invo RdvA== 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=rlG4REPOvHPZswdOoTuu1A8AEMNjKEsA0Bsepvhgcvs=; b=VqMna/02dskF+YjgD44KyrHeJA3slg44NKVl9QL9fg0GtJH/Q1gMxJJd4sRJYWVrlj Y613HvuoFDZ1S7VOi7YslAweiimCH/U2i5xzfHTFI6PsNcWPl7W4O1stb0CL/0BApld1 jkkJJlybrTUrD+YflPSd1fO1myd2lLDpCSJLe3kwjrmE8aGpDTasRPXHL9bV4tsp59DU pVRsVX6q9s/AwjkEr1gXSpBwoka4kkKwvccqRY0hIeTTe6MDwMmDypu9kUTR/nh/ULxB hB1T/NWY2x/98ZtE78srEIoRbHvsLqTFMx+TucF3PcNTyQNYLkouvzjxBmwxDue1ZEhl vSrg== X-Gm-Message-State: AOAM531WNmF/DGQ6x7iQorgllnpsHksyMa8BlH3WQ4CYSkm60cmIXjGA VqmL6h0aloURa5Sffzo0C6hi7g== X-Google-Smtp-Source: ABdhPJyySmsN7f5ghhdyHU4AHztHc7y7mm2rdVWKzxohS4/HI+Z6tCM8l9801eke6i0KInOQ1T1kEQ== X-Received: by 2002:a17:90b:911:: with SMTP id bo17mr221796pjb.165.1643689704260; Mon, 31 Jan 2022 20:28:24 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id l8sm20441335pfc.187.2022.01.31.20.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 20:28:23 -0800 (PST) From: Stephen Hemminger To: dsahern@gmail.com Cc: netdev@vger.kernel.org, Victor Nogueira , Jamal Hadi Salim , Stephen Hemminger Subject: [PATCH iproute2-next 2/2] tc/f_flower: fix indentation Date: Mon, 31 Jan 2022 20:28:19 -0800 Message-Id: <20220201042819.322106-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220201042819.322106-1-stephen@networkplumber.org> References: <20220201042819.322106-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 Introduce print_indent_name_value to do the indented style used in flower. Signed-off-by: Stephen Hemminger --- This was in second version of clang patches but missed during merge. tc/f_flower.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tc/f_flower.c b/tc/f_flower.c index 674e0d0384db..d3f79bdf4252 100644 --- a/tc/f_flower.c +++ b/tc/f_flower.c @@ -102,6 +102,13 @@ static void explain(void) " to specify different mask, he has to use different prio.\n"); } +/* prints newline, two spaces, name/value */ +static void print_indent_name_value(const char *name, const char *value) +{ + print_string(PRINT_FP, NULL, "%s ", _SL_); + print_string_name_value(name, value); +} + static int flower_parse_eth_addr(char *str, int addr_type, int mask_type, struct nlmsghdr *n) { @@ -1945,8 +1952,7 @@ static void flower_print_eth_addr(const char *name, struct rtattr *addr_attr, sprintf(out + done, "/%d", bits); } - print_nl(); - print_string_name_value(name, out); + print_indent_name_value(name, out); } static void flower_print_eth_type(__be16 *p_eth_type, @@ -2089,8 +2095,7 @@ static void flower_print_ip_addr(char *name, __be16 eth_type, else if (bits < len * 8) sprintf(out + done, "/%d", bits); - print_nl(); - print_string_name_value(name, out); + print_indent_name_value(name, out); } static void flower_print_ip4_addr(char *name, struct rtattr *addr_attr, @@ -2123,8 +2128,7 @@ static void flower_print_port_range(char *name, struct rtattr *min_attr, done = sprintf(out, "%u", rta_getattr_be16(min_attr)); sprintf(out + done, "-%u", rta_getattr_be16(max_attr)); - print_nl(); - print_string_name_value(name, out); + print_indent_name_value(name, out); } } @@ -2141,8 +2145,7 @@ static void flower_print_tcp_flags(const char *name, struct rtattr *flags_attr, if (mask_attr) sprintf(out + done, "/%x", rta_getattr_be16(mask_attr)); - print_nl(); - print_string_name_value(name, out); + print_indent_name_value(name, out); } static void flower_print_ct_state(struct rtattr *flags_attr, @@ -2438,8 +2441,7 @@ static void flower_print_masked_u8(const char *name, struct rtattr *attr, if (mask != UINT8_MAX) sprintf(out + done, "/%d", mask); - print_nl(); - print_string_name_value(name, out); + print_indent_name_value(name, out); } static void flower_print_u8(const char *name, struct rtattr *attr)