Make memalign print useful messages on failure
Brevity is the soul of wit, except for error messages; then it's a sign of witlessness. I can say this because this error message may be my fault, although it is lost in the 20th century code base so who knows. Anyway, when memalign dies, it's not a bad idea to have a lot of information about what went wrong. So instead of the terse single bit of "something failed" this patch changes things to be a bit more useful. Change-Id: I8851502297e0ae9773912839ebfdf4f9574c8087 Signed-off-by: Ronald G. Minnich <rminnich@chromium.org> Reviewed-on: http://review.coreboot.org/1270 Reviewed-by: Ronald G. Minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
496f4a0c83
commit
79431f5f09
|
@ -18,7 +18,7 @@ void *memalign(size_t boundary, size_t size)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
MALLOCDBG("%s Enter, boundary %ld, size %ld, free_mem_ptr %p\n",
|
MALLOCDBG("%s Enter, boundary %zu, size %zu, free_mem_ptr %p\n",
|
||||||
__func__, boundary, size, free_mem_ptr);
|
__func__, boundary, size, free_mem_ptr);
|
||||||
|
|
||||||
/* Overzealous linker check */
|
/* Overzealous linker check */
|
||||||
|
@ -30,8 +30,15 @@ void *memalign(size_t boundary, size_t size)
|
||||||
p = free_mem_ptr;
|
p = free_mem_ptr;
|
||||||
free_mem_ptr += size;
|
free_mem_ptr += size;
|
||||||
|
|
||||||
if (free_mem_ptr >= free_mem_end_ptr)
|
if (free_mem_ptr >= free_mem_end_ptr) {
|
||||||
|
printk(BIOS_ERR, "memalign(boundary=%zu, size=%zu): failed: ",
|
||||||
|
boundary, size);
|
||||||
|
printk(BIOS_ERR, "Tried to round up free_mem_ptr %p to %p\n",
|
||||||
|
p, free_mem_ptr);
|
||||||
|
printk(BIOS_ERR, "but free_mem_end_ptr is %p\n",
|
||||||
|
free_mem_end_ptr);
|
||||||
die("Error! memalign: Out of memory (free_mem_ptr >= free_mem_end_ptr)");
|
die("Error! memalign: Out of memory (free_mem_ptr >= free_mem_end_ptr)");
|
||||||
|
}
|
||||||
|
|
||||||
MALLOCDBG("memalign %p\n", p);
|
MALLOCDBG("memalign %p\n", p);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue