From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4696 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: src/string/strstr.c, src/string/wcsstr.c: wrong estimates for MIN(l,63)? Date: Fri, 21 Mar 2014 13:44:06 -0400 Message-ID: <20140321174406.GK26358@brightrain.aerifal.cx> References: <20140321164817.GJ26358@brightrain.aerifal.cx> <20140321170745.GC27448@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1395423855 11369 80.91.229.3 (21 Mar 2014 17:44:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Mar 2014 17:44:15 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4700-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 21 18:44:24 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1WR3UT-0004Fq-Ht for gllmg-musl@plane.gmane.org; Fri, 21 Mar 2014 18:44:21 +0100 Original-Received: (qmail 17452 invoked by uid 550); 21 Mar 2014 17:44:19 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 17444 invoked from network); 21 Mar 2014 17:44:18 -0000 Content-Disposition: inline In-Reply-To: <20140321170745.GC27448@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:4696 Archived-At: On Fri, Mar 21, 2014 at 06:07:45PM +0100, Szabolcs Nagy wrote: > * Rich Felker [2014-03-21 12:48:17 -0400]: > > On Fri, Mar 21, 2014 at 03:07:22PM +0100, Yves Bastide wrote: > > > /* Fast estimate for MIN(l,63) */ > > > size_t grow = l | 63; > > > > > > "grow" is thus always at least 63... > > > > If you look at how grow is used on the very next line, this should > > make sense. > > the comment is wrong though > z grows by at least max(63,l) unless end-of-string is reached Yes, (l|63) is >= both l and 63, so it should read MAX, not MIN. The idea is that it's useless to grow by less than l, but it's inefficient to grow by less than some fixed threshold even if the needle is tiny. Rich