Commit f6d21b50 authored by Rusty Russell's avatar Rusty Russell

alloc: fix page header size calculation bug, increase type safety.

parent dfdebb7c
...@@ -275,9 +275,9 @@ static unsigned long align_up(unsigned long x, unsigned long align) ...@@ -275,9 +275,9 @@ static unsigned long align_up(unsigned long x, unsigned long align)
return (x + align - 1) & ~(align - 1); return (x + align - 1) & ~(align - 1);
} }
static void *from_off(struct header *head, unsigned long off) static struct page_header *from_off(struct header *head, unsigned long off)
{ {
return (char *)head + off; return (struct page_header *)((char *)head + off);
} }
static unsigned long to_off(struct header *head, void *p) static unsigned long to_off(struct header *head, void *p)
...@@ -287,7 +287,7 @@ static unsigned long to_off(struct header *head, void *p) ...@@ -287,7 +287,7 @@ static unsigned long to_off(struct header *head, void *p)
static size_t used_size(unsigned int num_elements) static size_t used_size(unsigned int num_elements)
{ {
return (num_elements + BITS_PER_LONG-1) / BITS_PER_LONG; return align_up(num_elements, BITS_PER_LONG) / CHAR_BIT;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment