[CRIU] [PATCH] bdf: remove wrong optimization

Andrew Vagin avagin at parallels.com
Wed Sep 24 02:56:06 PDT 2014


On Wed, Sep 24, 2014 at 01:51:40PM +0400, Pavel Emelyanov wrote:
> On 09/24/2014 01:42 PM, Andrey Vagin wrote:
> > This optimization skips all new read data.
> 
> How?

ss = b->bleft after brefill(f)

I think you wanted to write smth like that:
diff --git a/bfd.c b/bfd.c
index 1ced0b0..34030f5 100644
--- a/bfd.c
+++ b/bfd.c
@@ -141,16 +141,17 @@ again:
                return b->pos;
        }
 
-       /* no full line in the buffer -- refill one */
-       if (brefill(f))
-               return BREADERR;
-
        /*
         * small optimization -- we've scanned b->bleft
         * symols already, no need to re-scan them after
         * the buffer refill.
         */
        ss = b->bleft;
+
+       /* no full line in the buffer -- refill one */
+       if (brefill(f))
+               return BREADERR;
+
        refilled = true;
 
        goto again;


> 
> > Reported-by: Mr Jenkins
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> >  bfd.c | 6 ------
> >  1 file changed, 6 deletions(-)
> > 
> > diff --git a/bfd.c b/bfd.c
> > index 1ced0b0..70c7028 100644
> > --- a/bfd.c
> > +++ b/bfd.c
> > @@ -145,12 +145,6 @@ again:
> >  	if (brefill(f))
> >  		return BREADERR;
> >  
> > -	/*
> > -	 * small optimization -- we've scanned b->bleft
> > -	 * symols already, no need to re-scan them after
> > -	 * the buffer refill.
> > -	 */
> > -	ss = b->bleft;
> >  	refilled = true;
> >  
> >  	goto again;
> > 
> 


More information about the CRIU mailing list