Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755658AbbGCQl4 (ORCPT ); Fri, 3 Jul 2015 12:41:56 -0400 Received: from smtprelay0198.hostedemail.com ([216.40.44.198]:60438 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755389AbbGCQlp (ORCPT ); Fri, 3 Jul 2015 12:41:45 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:2898:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:6120:6261:7903:8603:8660:10004:10400:10848:11026:11232:11658:11914:12114:12296:12438:12517:12519:12740:13069:13148:13230:13255:13311:13357:13869:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: sound77_665a0d3396f43 X-Filterd-Recvd-Size: 2933 Message-ID: <1435941701.2487.71.camel@perches.com> Subject: Re: [RFC patch] sctp: sctp_generate_fwdtsn: Initialize sctp_fwdtsn_skip array, neatening From: Joe Perches To: Neil Horman Cc: Vlad Yasevich , "David S. Miller" , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 03 Jul 2015 09:41:41 -0700 In-Reply-To: <20150703115105.GA3503@hmsreliant.think-freely.org> References: <1435874096.2487.51.camel@perches.com> <20150703115105.GA3503@hmsreliant.think-freely.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.11-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2142 Lines: 65 On Fri, 2015-07-03 at 07:51 -0400, Neil Horman wrote: > On Thu, Jul 02, 2015 at 02:54:56PM -0700, Joe Perches wrote: > > It's not clear to me that the sctp_fwdtsn_skip array is > > always initialized when used. > > > > It is appropriate to initialize the array to 0? > > > > This patch initializes the array too 0 and moves the > > local variables into the blocks where used. > > > > It also does some miscellaneous neatening by using > > continue; and unindenting the following block and > > using ARRAY_SIZE rather than 10 to decouple the > > array declaration size from a constant. > > --- > We don't set ftsn_skip_arr to a known value because we limit the amount of > elements that get read from it prior to those elements being set. That is to > say, in our first use (the call to sctp_get_skip_pos), we pass the uninitialized > array, and the nskips value, which is initalized to 0. Looking at the > definition of sctp_get_skip_pos, the for loop there becomes a nop, meaning the > uninitalized array is irrelevant, as we never visit any of its elements. > element zero is returned, and thats what the for_each loop in > sctp_generate_fwdtsn sets in that element of the array. On the next iteration > of the for_each loop, we call sctp_get_skip_pos with nskips = 1, so only the > first element is visited, whcih was set by the previous loop iteration. Alright. I might have chosen a while loop to limit the # of returns but it likely compiles to the same code. static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist, int nskips, __be16 stream) { int i; for (i = 0; i < nskips; i++) { if (skiplist[i].stream == stream) return i; } return i; } to: { int i = 0; while (i < nskips && skiplist[i].stream != stream) i++; return i; } > The rest of the cleanups look ok I think. Can you tell me what you did to test > it? Just code inspection. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/