Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1195043ybt; Wed, 24 Jun 2020 23:28:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJtTpUTAvEcdWTT3sKlo/3P1y+ZkHv6zU5g3DnK/E1OWlXJSbR+bDnjJ4PY1RJy10NVuvh X-Received: by 2002:a17:906:4a45:: with SMTP id a5mr19401939ejv.384.1593066510130; Wed, 24 Jun 2020 23:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593066510; cv=none; d=google.com; s=arc-20160816; b=Leb7In/H2fpmsSJIdGeI6LnZshKJZC0QNbyp/qBQ6tpwKvhglRv+C0EckCpMy6Xrlq j9wsdQfZclAcxeNNA1LlNJYf/Auiwi+Kp2rLonU22XzIYktS2/b8b5vynDea1ze14gaR E5I4xefRuFisfF+pqX0PMiKgGCpHMtBH7ThEzkUJgtdV5API8fNZwG+8B1TVl87tKRzv g7r8Tf/oBNpb3nAljh1351k+LpXympAmGBC/eYYoDoomSiecpW4FYV4c2NbpVYLvLzV/ WATHVuV1yOdGYuDf0/9rgFpSB+kWbXZl/OKQJm+u+pVBW/jx3GRnn4ktCR4fkcznibvp jGKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=gPouN/ZT0iqc9no93FsdOlROh0qIrC/oJSn/NZqgASw=; b=jRZZHQWXIYy8Ufd9heN5I/dgX8XeieQLYyqqyOfWqTi5mK5qCC7mHbLR1C2cBcP6kQ i1jeunMrJGpvQoYDCWt7RRgtL/eHfCnAxMaKrNY2L1cTpbqKlY2H2Gx8I1qFoQv/JOPk Of9pUkQobHgGwyU58z9tixuxTfXTfZmyuirufzJnM4fWPz219vqHDoWSQarYGXuCk5p/ W/sQwW2OP49Y64x/wftpKpYxLGZxbx858U8hV+BjTMm3E4CzLA+QKOxNRbaXCsEN/PJ2 ZeW62BK7bSD3MCW4OS/gVmJ5E043AWR1WQ5+RpcUm+StncLDo1b96ADE3FIN+kSM/zmy wK0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u5si2758413edo.548.2020.06.24.23.28.06; Wed, 24 Jun 2020 23:28:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389617AbgFYFvA (ORCPT + 99 others); Thu, 25 Jun 2020 01:51:00 -0400 Received: from smtprelay0236.hostedemail.com ([216.40.44.236]:55878 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725998AbgFYFvA (ORCPT ); Thu, 25 Jun 2020 01:51:00 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id 2E12618029120; Thu, 25 Jun 2020 05:50:59 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:560:599:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:2895:3138:3139:3140:3141:3142:3353:3622:3867:3868:3871:3872:4321:5007:6742:7875:10004:10400:10848:11026:11232:11658:11914:12296:12297:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21627:21740:21990:30012:30034:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: head29_411519126e4a X-Filterd-Recvd-Size: 2280 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Thu, 25 Jun 2020 05:50:57 +0000 (UTC) Message-ID: <51ca818443648cb25a604448dea022d6ac2ea09f.camel@perches.com> Subject: Re: [RFC] Reed-Solomon Code: Update no_eras to the actual number of errors From: Joe Perches To: Kees Cook , Aiden Leong Cc: "Gustavo A. R. Silva" , Thomas Gleixner , Ferdinand Blomqvist , YueHaibing , dm-devel@redhat.com, linux-kernel@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Anton Vorontsov , Colin Cross , Tony Luck Date: Wed, 24 Jun 2020 22:50:56 -0700 In-Reply-To: <202006242231.E17DAB2@keescook> References: <20200625041141.8053-1-aiden.leong@aibsd.com> <202006242231.E17DAB2@keescook> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.2-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2020-06-24 at 22:35 -0700, Kees Cook wrote: > On Wed, Jun 24, 2020 at 09:10:53PM -0700, Aiden Leong wrote: > > Corr and eras_pos are updated to actual correction pattern and erasure > > positions, but no_eras is not. [] > > @@ -312,14 +313,21 @@ > > eras_pos[j++] = loc[i] - pad; > > } > > } > > + if (no_eras > 0) > > + *no_eras = j; > > Is this meant to be "if (j > 0)" or "if (no_eras != NULL)" ? It's > uncommon to use > 0 for a pointer value. > > > } else if (data && par) { > > /* Apply error to data and parity */ > > + j = 0; > > for (i = 0; i < count; i++) { > > if (loc[i] < (nn - nroots)) > > data[loc[i] - pad] ^= b[i]; > > else > > par[loc[i] - pad - len] ^= b[i]; > > + if (b[i]) > > + j++; > > } > > + if (no_eras > 0) > > + *no_eras = j; > > I assume it's a pointer test, so both would be: > > if (no_eras_ptr != NULL) > *no_eras_ptr = j; More common still would be if (no_eras_ptr) *no_eras_ptr = j; though I think using _ptr is too Hungarian.