dump: simplify a bit kdump get_next_page()
This should be functionally equivalent, but slightly easier to read, with simplified paths and checks at the end of the function. The following patch is a major rewrite to get rid of the assert(). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: David Hildenbrand <david@redhat.com>
This commit is contained in:
parent
2341a94d3a
commit
08df343874
21
dump/dump.c
21
dump/dump.c
@ -1132,17 +1132,11 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|||||||
if (!block) {
|
if (!block) {
|
||||||
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
|
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
|
||||||
*blockptr = block;
|
*blockptr = block;
|
||||||
assert((block->target_start & ~target_page_mask) == 0);
|
addr = block->target_start;
|
||||||
assert((block->target_end & ~target_page_mask) == 0);
|
} else {
|
||||||
*pfnptr = dump_paddr_to_pfn(s, block->target_start);
|
addr = dump_pfn_to_paddr(s, *pfnptr + 1);
|
||||||
if (bufptr) {
|
|
||||||
*bufptr = block->host_addr;
|
|
||||||
}
|
}
|
||||||
return true;
|
assert(block != NULL);
|
||||||
}
|
|
||||||
|
|
||||||
*pfnptr = *pfnptr + 1;
|
|
||||||
addr = dump_pfn_to_paddr(s, *pfnptr);
|
|
||||||
|
|
||||||
if ((addr >= block->target_start) &&
|
if ((addr >= block->target_start) &&
|
||||||
(addr + s->dump_info.page_size <= block->target_end)) {
|
(addr + s->dump_info.page_size <= block->target_end)) {
|
||||||
@ -1154,12 +1148,13 @@ static bool get_next_page(GuestPhysBlock **blockptr, uint64_t *pfnptr,
|
|||||||
if (!block) {
|
if (!block) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert((block->target_start & ~target_page_mask) == 0);
|
addr = block->target_start;
|
||||||
assert((block->target_end & ~target_page_mask) == 0);
|
|
||||||
*pfnptr = dump_paddr_to_pfn(s, block->target_start);
|
|
||||||
buf = block->host_addr;
|
buf = block->host_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert((block->target_start & ~target_page_mask) == 0);
|
||||||
|
assert((block->target_end & ~target_page_mask) == 0);
|
||||||
|
*pfnptr = dump_paddr_to_pfn(s, addr);
|
||||||
if (bufptr) {
|
if (bufptr) {
|
||||||
*bufptr = buf;
|
*bufptr = buf;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user