From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752568AbdG1PkJ convert rfc822-to-8bit (ORCPT ); Fri, 28 Jul 2017 11:40:09 -0400 Received: from smtp-out4.electric.net ([192.162.216.189]:56808 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbdG1Pjw (ORCPT ); Fri, 28 Jul 2017 11:39:52 -0400 From: David Laight To: "'Arnd Bergmann'" , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI CC: Eric Dumazet , Neal Cardwell , Soheil Hassas Yeganeh , Yuchung Cheng , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH net] tcp: avoid bogus gcc-7 array-bounds warning Thread-Topic: [PATCH net] tcp: avoid bogus gcc-7 array-bounds warning Thread-Index: AQHTB6+/4YtcmlNAIUSveKSL+nr30aJpXSGw Date: Fri, 28 Jul 2017 15:39:41 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DD0045AAA@AcuExch.aculab.com> References: <20170728144153.2024234-1-arnd@arndb.de> In-Reply-To: <20170728144153.2024234-1-arnd@arndb.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann > Sent: 28 July 2017 15:42 ... > --- a/net/ipv4/tcp_output.c > +++ b/net/ipv4/tcp_output.c > @@ -2202,9 +2202,10 @@ static bool tcp_small_queue_check(struct sock *sk, const struct sk_buff *skb, > static void tcp_chrono_set(struct tcp_sock *tp, const enum tcp_chrono new) > { > const u32 now = tcp_jiffies32; > + enum tcp_chrono old = tp->chrono_type; > > - if (tp->chrono_type > TCP_CHRONO_UNSPEC) > - tp->chrono_stat[tp->chrono_type - 1] += now - tp->chrono_start; > + if (old > TCP_CHRONO_UNSPEC) > + tp->chrono_stat[old - 1] += now - tp->chrono_start; > tp->chrono_start = now; > tp->chrono_type = new; What a horrid combination of enum and integers. Also have u32 chrono_stat[3]; - should probably be [__TCP_CHRONO_MAX - 1] (or - CHRONO_FIRST which is defined to be 1). Checking if (old != 0) would make the code more readable. David