Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20130927155618.GD20515@brightrain.aerifal.cx>
Date: Fri, 27 Sep 2013 11:56:18 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] mbsrtowcs: Fix bug when wn is a multiple of 4

On Fri, Sep 27, 2013 at 11:28:49AM -0400, Rich Felker wrote:
> >  src/multibyte/mbsrtowcs.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/src/multibyte/mbsrtowcs.c b/src/multibyte/mbsrtowcs.c
> > index b9bbc33..c5a30de 100644
> > --- a/src/multibyte/mbsrtowcs.c
> > +++ b/src/multibyte/mbsrtowcs.c
> > @@ -66,6 +66,7 @@ resume0:
> >  				*ws++ = *s++;
> >  				wn -= 4;
> >  			}
> > +			if (!wn) continue;
> 
> Rather than adding an extra branch here, why not just either change
> the >=4 condition to >=5 or unconditionally continue here? Any
> thoughts on what would be better?

Forget what I said about just continuing; it would lead to an infinite
loop. I think checking for wn>=5 is probably the best solution to
avoid extra branches in a fairly common code path (ASCII at an aligned
position but not 4 ASCII characters in a row). At some point perhaps
all of this code should be reworked (with proper benchmarking to
measure the effect of changes) but for now we just need a fix.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.