<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 13, 2015 at 6:53 PM, Cyril Hrubis <span dir="ltr"><<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
<span class="">> okay, seems you are right. I tried and achieved another one,  following<br>
> code test pass on my s390x system.<br>
> -----------------------------------------<br>
> int range_is_mapped(unsigned long low, unsigned long high)<br>
> {<br>
>     FILE *f = SAFE_FOPEN(NULL, "/proc/self/maps", "r");<br>
<br>
</span>If we start to use SAFE_MACROS() here we have to pass the cleanup<br>
callback to the range_is_mapped() as a first parameter so that we can<br>
pass correct cleanup callback to the SAFE_MACROS().<br></blockquote><div><br>ok, now I prefer to use fopen()/fclose() to keep simple.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><br>
>     char buf[512];<br>
><br>
>     while (!feof(f)) {<br>
>         unsigned long start, end;<br>
>         int ret;<br>
><br>
>         ret = fscanf(f, "%lx-%lx %[^\n]%*c]", &start, &end, buf);<br>
<br>
</span>You can do even better with:<br>
<br>
                ret = fscanf(f, "%lx-%lx %*[^\n]\n", &start, &end);<br></blockquote><div><br>great! <br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Which says read two long ints and then ignore everything until the end<br>
of line.<br>
<br>
You could have ommited the last '\n' in the format string, but then you<br>
would need to exit the loop when the fscanf() returns -1 since the<br>
feof() would not exit the loop since there would still be the last<br>
newline in the buffer after we read the last line...<br></blockquote><div><br>ok, agreed. I will sent V3. <br><br><span style="color:rgb(51,51,51);font-family:Arial,"Microsoft YaHei";font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:23px;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;display:inline!important;float:none;background-color:rgb(242,242,245)"></span> thanks for reviewing the patch.<br></div></div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Regards,<br></div>Li Wang<br></div><div>Email: <a href="mailto:liwang@redhat.com" target="_blank">liwang@redhat.com</a><br></div></div></div></div></div></div>
</div></div>