[LTP] [PATCH v2] mem/hugetlb: shift an empty region to use in hugemmap02.c
Li Wang
liwang@redhat.com
Tue Oct 13 15:39:24 CEST 2015
Hi,
On Tue, Oct 13, 2015 at 6:53 PM, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
> > okay, seems you are right. I tried and achieved another one, following
> > code test pass on my s390x system.
> > -----------------------------------------
> > int range_is_mapped(unsigned long low, unsigned long high)
> > {
> > FILE *f = SAFE_FOPEN(NULL, "/proc/self/maps", "r");
>
> If we start to use SAFE_MACROS() here we have to pass the cleanup
> callback to the range_is_mapped() as a first parameter so that we can
> pass correct cleanup callback to the SAFE_MACROS().
>
ok, now I prefer to use fopen()/fclose() to keep simple.
>
> > char buf[512];
> >
> > while (!feof(f)) {
> > unsigned long start, end;
> > int ret;
> >
> > ret = fscanf(f, "%lx-%lx %[^\n]%*c]", &start, &end, buf);
>
> You can do even better with:
>
> ret = fscanf(f, "%lx-%lx %*[^\n]\n", &start, &end);
>
great!
>
> Which says read two long ints and then ignore everything until the end
> of line.
>
> You could have ommited the last '\n' in the format string, but then you
> would need to exit the loop when the fscanf() returns -1 since the
> feof() would not exit the loop since there would still be the last
> newline in the buffer after we read the last line...
>
ok, agreed. I will sent V3.
thanks for reviewing the patch.
--
Regards,
Li Wang
Email: liwang@redhat.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20151013/d3351495/attachment.html>
More information about the Ltp
mailing list