* zhanghailiang ([email protected]) wrote:
> On 2014/8/11 22:29, Dr. David Alan Gilbert (git) wrote:
> >From: "Dr. David Alan Gilbert"<[email protected]>
> >
<snip>
> >+ testarea2 = mmap(NULL, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE |
> >+ MAP_ANONYMOUS, -1, 0);
> >+ if (!testarea2) {
> >+ perror("postcopy_ram_hosttest: Failed to map second test area");
>
> Before return, should we munmap testarea?
> BTW, i think it is better to use goto statement,
> which we can handle the error cases together!
Yes, thank you for spotting this; I'll fix it in my next version.
Dave
>
> Best regards,
> zhanghailiang
> >+ return -1;
> >+ }
> >+ g_assert(((size_t)testarea2& (pagesize-1)) == 0);
> >+ *(char *)testarea = 0; /* Force the map of the new page */
> >+ if (syscall(__NR_remap_anon_pages, testarea2, testarea, pagesize, 0) !=
> >+ pagesize) {
> >+ perror("postcopy_ram_hosttest: remap_anon_pages not available");
> >+ munmap(testarea, pagesize);
> >+ munmap(testarea2, pagesize);
> >+ return -1;
> >+ }
> >+
> >+ munmap(testarea, pagesize);
> >+ munmap(testarea2, pagesize);
> >+ return 0;
> >+}
> >+
> >+#else
> >+/* No target OS support, stubs just fail */
> >+
> >+int postcopy_ram_hosttest(void)
> >+{
> >+ error_report("postcopy_ram_hosttest: No OS support");
> >+ return -1;
> >+}
> >+
> >+#endif
> >+
>
>
--
Dr. David Alan Gilbert / [email protected] / Manchester, UK