From patchwork Sun Nov 29 17:54:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 84630 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B6A0A04E7; Sun, 29 Nov 2020 18:55:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8A35DC99C; Sun, 29 Nov 2020 18:54:59 +0100 (CET) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 2249FC86E for ; Sun, 29 Nov 2020 18:54:54 +0100 (CET) Received: by mail-pl1-f195.google.com with SMTP id u2so5162048pls.10 for ; Sun, 29 Nov 2020 09:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g7pzjkA5EwGXh+RTbiPd2mm1I1pqZEiIlbzsMU7n4Vg=; b=L3N/WweE0HETdPNy6zsJsd/yHUqwztxmOMpDIR0jJtL5r18e+4l91DtSrftoK2CUEb BV6HS86AymF+EaTQd+jPhfrqcnDog6geYD8GBKtMIGdRd+Gwl0zMfacWguhPFLrH5sHY WIi5P6VBqdzcXK9kJiGd0K6OrTOaVwkMNinDNZoWgY3CkYlzpUozdadC1G8CjTj3rj7S 9i0TFHpzLkbcwqb42NPipijIzLKtQY33gi7nmqrMmX8/y/OZERFGpjT+gtd2j/fwUI0y YnjPi4PfmkkCIqCyXaPJ+VvMG7dFmEDKbiguLUOiGJ+dQ5qZH3WrG3g6GgCWLcClhb9w 9tBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g7pzjkA5EwGXh+RTbiPd2mm1I1pqZEiIlbzsMU7n4Vg=; b=hS+ptvnjzuQ1VRGeFYedbKCvAcXvKHVzyhQkN3gAc/WT+KoHn4Z6MvvEGA71KPEs3q 4l0Qmg+pfUkkfbi2liEAwSMQAd9Nml+7A0OHtU2gJT+/Hzzqc8DdlMEwXP65wttgC9W5 VrdwP4T3HWsITpXRNVDeruOvR5dZHBfdSc9FAcRY5V4o3efxfDhOegYFOdy/iqsA50US dIf3JMBVpsHoMy+2TQa/rOWK0+7/8sEwzdU6i+EqM1DW/wWCCEmTjdr0kQ6WMEquCnTI jJ2QGpwOvAtucBkfCefiQtCS5M9csQ25zDnZQoLSLMApknknAw4vUjoU7S80j1w8+3mu eaHQ== X-Gm-Message-State: AOAM530iJIi/Y36c7enJLLzlR0A2DRN7iUDX1X4oeuJoZfkDC/xvZ1X0 ITXb5+5Lgfq9F713lAUL0LptcUIaiIdlLjK3 X-Google-Smtp-Source: ABdhPJySjqNnCHZcGxobKH3wsR5PV7CJWuAQEEmjAy9zwIycVubbd7oRqxrWtd5MNIojdG12ZQzABg== X-Received: by 2002:a17:902:22e:b029:d9:e591:7bd1 with SMTP id 43-20020a170902022eb02900d9e5917bd1mr15335035plc.50.1606672491789; Sun, 29 Nov 2020 09:54:51 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l23sm13114850pgn.40.2020.11.29.09.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 09:54:50 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , shalomt@mellanox.com Date: Sun, 29 Nov 2020 09:54:33 -0800 Message-Id: <20201129175437.15346-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129175437.15346-1-stephen@networkplumber.org> References: <20201129175437.15346-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 1/5] devlink: fix unitialized warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" GCC-10 complains about uninitialized variable. devlink.c: In function ‘cmd_dev’: devlink.c:2803:12: warning: ‘val_u32’ may be used uninitialized in this function [-Wmaybe-uninitialized] 2803 | val_u16 = val_u32; | ~~~~~~~~^~~~~~~~~ devlink.c:2747:11: note: ‘val_u32’ was declared here 2747 | uint32_t val_u32; | ^~~~~~~ This is a false positive because it can't figure out the control flow when the parse returns error. Simplest fix is to initialize variable. Fixes: 2557dca2b028 ("devlink: Add string to uint{8,16,32} conversion for generic parameters") Cc: shalomt@mellanox.com Signed-off-by: Stephen Hemminger --- devlink/devlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devlink/devlink.c b/devlink/devlink.c index 1ff865bc5c22..ca99732efd00 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -2744,7 +2744,7 @@ static int cmd_dev_param_set(struct dl *dl) struct param_ctx ctx = {}; struct nlmsghdr *nlh; bool conv_exists; - uint32_t val_u32; + uint32_t val_u32 = 0; uint16_t val_u16; uint8_t val_u8; bool val_bool; From patchwork Sun Nov 29 17:54:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 84631 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 466B6A04E7; Sun, 29 Nov 2020 18:55:40 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5CD8AC9AA; Sun, 29 Nov 2020 18:55:01 +0100 (CET) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by dpdk.org (Postfix) with ESMTP id 4B7ECC8FA for ; Sun, 29 Nov 2020 18:54:55 +0100 (CET) Received: by mail-pl1-f176.google.com with SMTP id x4so3443571pln.8 for ; Sun, 29 Nov 2020 09:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fKMan7oWGvWyjqMhG7qMLjXbclAI34cwErrXXBHsZqg=; b=KZN3Bpyvo/JYB3IR9N8Ca2cIE5s0f3+R8fu8FckBeVCbwZLegJ79rm8JL/5Pr9P4bg 37vlB8mCoinWWtp3tWUQmCF/3vVtB3w+FD9HupxNKRxa2yxdxNtOcGuhwqiAbanHtoVA NxuCIhMFxSS4SrWv7gp7MQlO4NA2wdSqhRpZ8/2SKXhDMuV2BqgwkcJh89C/Vuv2R5yj x8qu8g1N3CTPr1rOQjooEw3/1/yDlK+PTKfxG4LZm3Wq8jNyy9pM9XYjniHilLYZP4Y6 KYmPqVD9VMXUVRxDpfktXoBdcvhikPGz2ce15qVAC4poGExUVN5wIDGsvweu7INAFDWG I7Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fKMan7oWGvWyjqMhG7qMLjXbclAI34cwErrXXBHsZqg=; b=i7OPpokbJinETkcV9Mf9xEITA/20eTbgX68z4lyUascB2v4jnBPIz5s98CFOcQet1a Ox37Vmuw72g8rWNtNBm1aCbA8+25QvSPwNS3v/uq+6lWABuzwbeoI9xwB7DGEpEcDyUH 3us2OUqgqeRLsJT/ioZN6yguDZ6rr7sZ9Kj7VxadNa9dgQgCdHVYuverIfhmoEYOJKjm LjxSOm9SdBhdNbwrkrPgIF6oiPePINcWlJk1CwoN/I91RoV2jdzBAl6xtjRtTM6QboAK 10CYEfh8/IsliIJz8bWmQYOjADSyr5ors71PXRuD3OCrn1igtsU/xvwjM4G9NG547vxq UG9g== X-Gm-Message-State: AOAM530c2QtxrFE0BScp4KIEhB71VRKWzGvTP5cBvEBDLI+Uy/X8gNJL ZJikgrNFXl1m/eGsHlwHFDaI8fSGNbdYK4OC X-Google-Smtp-Source: ABdhPJwMR7ew7negeo/wPMMbcXB/jaMljgPa0dMSTJwY8tKwnqsuyVxcyOb0K+3mJA1VKe+f8ZK2OA== X-Received: by 2002:a17:902:854a:b029:da:113b:2d3f with SMTP id d10-20020a170902854ab02900da113b2d3fmr15571599plo.49.1606672493088; Sun, 29 Nov 2020 09:54:53 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l23sm13114850pgn.40.2020.11.29.09.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 09:54:52 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , nikolay@cumulusnetworks.com Date: Sun, 29 Nov 2020 09:54:34 -0800 Message-Id: <20201129175437.15346-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129175437.15346-1-stephen@networkplumber.org> References: <20201129175437.15346-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 2/5] bridge: fix string length warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Gcc-10 complains about possible string length overflow. This can't happen Ethernet address format is always limited to 18 characters or less. Just resize the temp buffer. Fixes: 70dfb0b8836d ("iplink: bridge: export bridge_id and designated_root") Cc: nikolay@cumulusnetworks.com Signed-off-by: Stephen Hemminger --- ip/iplink_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c index 3e81aa059cb3..d12fd0558f7d 100644 --- a/ip/iplink_bridge.c +++ b/ip/iplink_bridge.c @@ -74,7 +74,7 @@ static void explain(void) void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len) { - char eaddr[32]; + char eaddr[18]; ether_ntoa_r((const struct ether_addr *)id->addr, eaddr); snprintf(buf, len, "%.2x%.2x.%s", id->prio[0], id->prio[1], eaddr); From patchwork Sun Nov 29 17:54:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 84632 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB2A5A04E7; Sun, 29 Nov 2020 18:55:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 841D1C9B8; Sun, 29 Nov 2020 18:55:04 +0100 (CET) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id CB7DBC938 for ; Sun, 29 Nov 2020 18:54:56 +0100 (CET) Received: by mail-pl1-f193.google.com with SMTP id r2so5188558pls.3 for ; Sun, 29 Nov 2020 09:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EkhG6AFxavZ5abglJ6kOnkEVdmyu4algVumO7xanA0Q=; b=gE4z8N0VVbWg2gjCU5KPfcz5JrqPadeKX5s9jg9Ll+8F6A9BIxf1Q5G1WkXaVbu+y3 jHSE/RpRbREt45a84PYY6qwaxuDIEO9upMKJR8FL/THKisFFOkx7R4WCv3Frqgf9x+qW 9v0TTClLilop/mRfnk5F4Lx3QEAv7r+nkczMvIN/lO17GcWYwtDH3qsiYXailCZr6WLU 4GzJSKT3ZG0VqIESqh3Ktx/XcooADIo0BRinl9iHMQ3BxsnK0I9Oba6PGPdYxWd10TWz 4a8ow9L4XCvx+wva5PZ8MAVDIU4I1sqdMsM1nsj2ZeCI45u/h0pRs6EUrFWLyC7uo3mJ XtSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EkhG6AFxavZ5abglJ6kOnkEVdmyu4algVumO7xanA0Q=; b=H6uamymkV71Cf4cgLVFYnUwdaGtkKyRNjDOZxtgS4XlYReIi2fJf4/MRhdysxkklS3 dIYxNUbq0o9MfHEeY0d0oCO0eG+3nwXysjulcJWflXx5fMAY2NQVG8Og7VW/+fWjRism qVgNDOcYlc7W7NmOeHHB9FgeIoJlotxMY7Av4OOozEoANCGooIADdqJWtjk0kMLQLEvn Q+n4XWyqkfwjIGjngCUOzG+XtlWePqCpa0ZuciSlG1Hg6mf04X25cU4eKas5YUrrqwWs hOs923fMG+k1piHiT1pTQM3JepNTmVef2izYjk9MhJn96+cue8qwyY2Le2w6uymBUfpv Oucg== X-Gm-Message-State: AOAM530GI7aMhyznULDfpmrhPkQCwzxIdaONC5hkVxJLel6BivMGO24w 4VIaJJonaNjfd08UCPEQINSAFOuw2J25r98Y X-Google-Smtp-Source: ABdhPJywfiPcIm5SlcRa1An3MqCAC8TlSl/2x1QRfTu9cA8iT509Y+0ZLcwB/SeI5BYl+Ke0OoCzJA== X-Received: by 2002:a17:902:b7c3:b029:da:76bc:2aa9 with SMTP id v3-20020a170902b7c3b02900da76bc2aa9mr1730765plz.21.1606672494598; Sun, 29 Nov 2020 09:54:54 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l23sm13114850pgn.40.2020.11.29.09.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 09:54:53 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , petrm@mellanox.com Date: Sun, 29 Nov 2020 09:54:35 -0800 Message-Id: <20201129175437.15346-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129175437.15346-1-stephen@networkplumber.org> References: <20201129175437.15346-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 3/5] tc: fix compiler warnings in ip6 pedit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Gcc-10 complains about referencing a zero size array. This occurs because the array of keys is actually in the following structure which is part of the overall selector. The original code was safe, but better to just use the key array directly. Fixes: 2d9a8dc439ee ("tc: p_ip6: Support pedit of IPv6 dsfield") Cc: petrm@mellanox.com Signed-off-by: Stephen Hemminger --- tc/p_ip6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/p_ip6.c b/tc/p_ip6.c index 71660c610c82..83a6ae8183a7 100644 --- a/tc/p_ip6.c +++ b/tc/p_ip6.c @@ -82,7 +82,7 @@ parse_ip6(int *argc_p, char ***argv_p, /* Shift the field by 4 bits on success. */ if (!res) { int nkeys = sel->sel.nkeys; - struct tc_pedit_key *key = &sel->sel.keys[nkeys - 1]; + struct tc_pedit_key *key = &sel->keys[nkeys - 1]; key->mask = htonl(ntohl(key->mask) << 4 | 0xf); key->val = htonl(ntohl(key->val) << 4); From patchwork Sun Nov 29 17:54:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 84633 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CFA57A04E7; Sun, 29 Nov 2020 18:56:14 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 16055C9C4; Sun, 29 Nov 2020 18:55:06 +0100 (CET) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 07E43C97A for ; Sun, 29 Nov 2020 18:54:58 +0100 (CET) Received: by mail-pf1-f196.google.com with SMTP id 131so8838816pfb.9 for ; Sun, 29 Nov 2020 09:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d+CBUwikwpql5D28/Ydzn/tkpCccjAYgynX4fCid50M=; b=xN/X9zn4oIUiO/HSRu7hnzwnOBfV+4k2sw2LGVLsPti+a6omkIJxOWKf3s7dH1Shsd QYnh46SU3V3oSFbaTtM3SlxKzPcs0DW6JUNHMLKh7t++8n1hTG0/wlijMStShxOiHxnR y1pM7sg4/A2ZWUdhRgDcq+Peb8k0kGPr2Iix9xONgW2/8kU/IfD1dUAZ8xUoiw874iyk 4G+n/itzyYfmLmCW428gj+sDMW7kYaC1QELdiM/NcsbY0dAzrEznYnVu5bS1IyU29R92 HD1n4vFyCn0kM0SJcqsM7B5buCi2mlsXe/5pTC6rEXnaneWQ7OCpkE8dlY1YqcINIodg oqAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d+CBUwikwpql5D28/Ydzn/tkpCccjAYgynX4fCid50M=; b=RrUe+ztd2vV+OV4Lb+AJbNIT7+7/HKXaO4EScx5Bo0CNlVhkDPRvSIDro5xKEpGxPj DgdTxpvWD9Q3cRYf+dcLxuc8xZkbVQilFoBBnRmT0HQB1VdoYEI+IFY3mLc3DWYBq30L pgejx2nXlZcjw+UOptPhha9dWvuWgrndLf4chf1ypb2CvZ0cegxvKMVK/EEpyRIXt3BO QFYu8oQ4hvREGc+3YlHHaW17zI6WLhXh6Hk9hw/EBprUVMg7GR0E0DpxyTDwthlL53Ml COy/c8KGVNKaLXls/qH1E462oYdwYjfcdWImigCJye00u9ur2gKhIAbxdBpfQmVCiHK/ 8b7w== X-Gm-Message-State: AOAM531cvL3wLGCvB5wBwNDjBFKfrky6Z7l3vjxkVNU9bKOm+eiocI8R 63ID+5lBH2DPVsrZ+vFQSQlK/08ZCXfkrKDI X-Google-Smtp-Source: ABdhPJzZki1Y2Y87Lh9IVBi4Q7jP08af5B00xuCu8ELdDDrUAVmg7/rI1IOpQe9k8lIs+yNWaBICSQ== X-Received: by 2002:a17:90b:4785:: with SMTP id hz5mr4035335pjb.157.1606672495765; Sun, 29 Nov 2020 09:54:55 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l23sm13114850pgn.40.2020.11.29.09.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 09:54:55 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sun, 29 Nov 2020 09:54:36 -0800 Message-Id: <20201129175437.15346-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129175437.15346-1-stephen@networkplumber.org> References: <20201129175437.15346-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 4/5] misc: fix compiler warning in ifstat and nstat X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The code here was doing strncpy() in a way that causes gcc 10 warning about possible string overflow. Just use strlcpy() which will null terminate and bound the string as expected. This has existed since start of git era so no Fixes tag. Signed-off-by: Stephen Hemminger --- misc/ifstat.c | 2 +- misc/nstat.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/misc/ifstat.c b/misc/ifstat.c index c05183d79a13..d4a33429dc50 100644 --- a/misc/ifstat.c +++ b/misc/ifstat.c @@ -251,7 +251,7 @@ static void load_raw_table(FILE *fp) buf[strlen(buf)-1] = 0; if (info_source[0] && strcmp(info_source, buf+1)) source_mismatch = 1; - strncpy(info_source, buf+1, sizeof(info_source)-1); + strlcpy(info_source, buf+1, sizeof(info_source)); continue; } if ((n = malloc(sizeof(*n))) == NULL) diff --git a/misc/nstat.c b/misc/nstat.c index 6fdd316cce84..ecdd4ce8266d 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -136,8 +136,7 @@ static void load_good_table(FILE *fp) buf[strlen(buf)-1] = 0; if (info_source[0] && strcmp(info_source, buf+1)) source_mismatch = 1; - info_source[0] = 0; - strncat(info_source, buf+1, sizeof(info_source)-1); + strlcpy(info_source, buf + 1, sizeof(info_source)); continue; } /* idbuf is as big as buf, so this is safe */ From patchwork Sun Nov 29 17:54:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 84634 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 34412A04E7; Sun, 29 Nov 2020 18:56:36 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 863B9C9D2; Sun, 29 Nov 2020 18:55:07 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 4DB8EC9A4 for ; Sun, 29 Nov 2020 18:54:59 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id v21so5154281plo.12 for ; Sun, 29 Nov 2020 09:54:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i/b3F1OiqGDBMwbHm3iD7dfFR9hiS2R0OKWSeitmuMk=; b=qQkcws/55pL5gVd0rXkjI+E1ay0gcP4U/8FHVGM19iHS8T0G6A3yV440BgxphkCzZl gkFFrzd6F6Hsx0uCl/J4n/7Xb+S1u5vpgZkC/Ty4foIgrtxFyevAxICvzdwcc1JhBYMf 5uF2wHaoU0L2VOMJKg7zolGTFcfUPYCtS5X38FUadJQj/u3RH8m2MBIvU8R9St4VYwbB gHXyOTYkkwsqQ4EIiq32b54UPPgelnjBMqI42jSTzK3QOMI7VXHpPEv+KY2No2P2724w Llz5DDsGweERqsxJOvZQvHcmXdtzxW1G1OD7n7+1sKxT9NiW2xihmkd9X+kLf0MLdTod GPkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=i/b3F1OiqGDBMwbHm3iD7dfFR9hiS2R0OKWSeitmuMk=; b=OseGACP9LHDWEvhy4/M+XsJOP8/BIrLcp9NW5NL9oorsypbLTioCF2yONBA7Glu+PK KQOrvA8HiCjp8fIVLdNT8fTzHuybshHN109JB69hbTJvtRIbM6qmqdeLOHf1G2N8XCgN 3p04dwJpjsfST55w/TmNEFBIMmEZpY5eNmroRny/8rhjQHnJuH0Ib++lldQBEl41YJ21 +JinA+8TsdSPdFIwWENbqUB6Swq0nvmqjQzHkvi3tvKMPUDPiqTAPLByQXqp/hXjCFRc SGxm74skxMDsx+Om7ITUBfCPPbGpDEGKoY1t2Fwiif5fVi5msVUu1RbgwP/Ce/U5AzAk 1ZcQ== X-Gm-Message-State: AOAM532RbWbvoExvdFgomD5Vq9+mD5JuKBHYXg2gYcZDIm9FtHbpuwkL o2YFiUhLpMO+P/8TRMD1nZM/iwiYtWF3JEhf X-Google-Smtp-Source: ABdhPJyHVUcWM4biERj2456LSzNw1akPd8oozo/Gf1RmdeGL5RG7OzmQ7BFD+hkvMLPtuLd+w4BgFA== X-Received: by 2002:a17:902:7e85:b029:da:726a:3a4f with SMTP id z5-20020a1709027e85b02900da726a3a4fmr3160078pla.65.1606672497156; Sun, 29 Nov 2020 09:54:57 -0800 (PST) Received: from hermes.local (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id l23sm13114850pgn.40.2020.11.29.09.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 09:54:56 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Sun, 29 Nov 2020 09:54:37 -0800 Message-Id: <20201129175437.15346-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201129175437.15346-1-stephen@networkplumber.org> References: <20201129175437.15346-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 5/5] f_u32: fix compiler gcc-10 compiler warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" With gcc-10 it complains about array subscript error. f_u32.c: In function ‘u32_parse_opt’: f_u32.c:1113:24: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘struct tc_u32_key[0]’ [-Wzero-length-bounds] 1113 | hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask; | ~~~~~~~~~~~~~^~~ In file included from tc_util.h:11, from f_u32.c:26: ../include/uapi/linux/pkt_cls.h:253:20: note: while referencing ‘keys’ 253 | struct tc_u32_key keys[0]; | This is because the keys are actually allocated in the second element of the parent structure. Simplest way to address the warning is to assign directly to the keys in the containing structure. This has always been in iproute2 (pre-git) so no Fixes. Signed-off-by: Stephen Hemminger --- tc/f_u32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tc/f_u32.c b/tc/f_u32.c index e0a322d5a11c..2ed5254a40d5 100644 --- a/tc/f_u32.c +++ b/tc/f_u32.c @@ -1110,7 +1110,7 @@ static int u32_parse_opt(struct filter_util *qu, char *handle, } NEXT_ARG(); } - hash = sel2.sel.keys[0].val & sel2.sel.keys[0].mask; + hash = sel2.keys[0].val & sel2.keys[0].mask; hash ^= hash >> 16; hash ^= hash >> 8; htid = ((hash % divisor) << 12) | (htid & 0xFFF00000);