[Ocfs2-test-devel] [PATCH 42/59] mmap-test: fix segment fault

Eric Ren zren at suse.com
Thu Sep 24 20:04:30 PDT 2015


Hi Junxiao,

> >> +
> >> +    /* fix offset if the file size is multiple of page size */
> >> +    if (offset == 0)
> >> +	    offset = page_size;
> >> +
> > 
> > I cannot understand the below.
> > 1. if (.st_size < page_size && .st_size != 0)
> >         both if-statement won't hit;
> > 
> > 2. if (.st_size > page_size && .st_size % page_size != 0)
> >         1st if-statement won't hit;
> >         2st if-statement won't hit, also;
> > 
> > 3. if (.st_size !=0 && .st_size % page_size == 0)
> >         1st if-statement hit!
> >         2st if-statement won't hit!
> > 
> > 4. if (.st_size == 0)
> >         1st if-statement hit;
> >         2st if-statement will hit!!! As a result, offset varied 0,
> >         page_size, and 0 again.
> > 
> > So, the 2th if-statement is odd! Or I mistake something?
> 2th is for the case st_size == 0, do you mean it's useless and can be
> dropped?

If so, yes, it's useless.

Thanks,
Eric

> 
> Thanks,
> Junxiao.
> > 
> > Thanks,
> > Eric Ren
> > 
> >> +    if (offset > stat_buf.st_size)
> >> +	    offset = stat_buf.st_size;
> >> +
> >>      ptr = buf + (stat_buf.st_size - offset);
> >>      remain = page_size - offset;
> >>  
> >> -- 
> >> 1.7.9.5
> >>
> >>
> >> _______________________________________________
> >> Ocfs2-test-devel mailing list
> >> Ocfs2-test-devel at oss.oracle.com
> >> https://oss.oracle.com/mailman/listinfo/ocfs2-test-devel
> >>
> 
> 



More information about the Ocfs2-test-devel mailing list