lib/alloc_page: Revert to 'unsigned long' for @size params
Subsystems (2)
PATCH 1/1 lib/alloc_page: Revert to 'unsigned long' for @size params
Revert to using 'unsigned long' instead of 'size_t' for free_pages() and get_order(). The recent change to size_t for free_pages() breaks i386 with -Werror as the assert_msg() formats expect unsigned longs, whereas size_t is an 'unsigned int' on i386 (though both longs and ints are 4 bytes).
Message formatting aside, unsigned long is the correct choice given the current code base as alloc_pages() and free_pages_by_order() explicitly expect, work on, and/or assert on the size being an unsigned long.
--- lib/alloc_page.c | 2 +- lib/alloc_page.h | 2 +- lib/bitops.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
lib/alloc_page.c +1 -1
@@ -21,7 +21,7 @@ bool page_alloc_initialized(void)return freelist !=0 ; } -void free_pages (void *mem,size_t size) +void free_pages (void *mem,unsigned long size) {void *old_freelist;void *end;
lib/alloc_page.h +1 -1
@@ -13,7 +13,7 @@ void page_alloc_ops_enable(void);void *alloc_page (void );void *alloc_pages (unsigned int order);void free_page (void *page); -void free_pages (void *mem,size_t size); +void free_pages (void *mem,unsigned long size);void free_pages_by_order (void *mem,unsigned int order);#endif
lib/bitops.h +1 -1
@@ -79,7 +79,7 @@ static inline bool is_power_of_2(unsigned long n)return n && !(n & (n -1 )); } -static inline unsigned int get_order (size_t size) +static inline unsigned int get_order (unsigned long size) {return size ?fls (size) + !is_power_of_2 (size) :0 ; }
Signature · 1 line
2.26.0
Quoted 15 lines · Sean Christopherson
Revert to using 'unsigned long' instead of '
size_t' forfree_pages()andget_order(). The recent change tosize_tforfree_pages()breaks i386 with -Werror as theassert_msg()formats expect unsigned longs, whereassize_tis an 'unsigned int' on i386 (though both longs and ints are 4 bytes).Message formatting aside, unsigned long is the correct choice given the current code base as
alloc_pages()andfree_pages_by_order()explicitly expect, work on, and/or assert on the size being an unsigned long.Fixes 73f4b202beb39 ("lib/alloc_page: change some parameter types")Cc Claudio Imbrenda <[email protected]>Cc Andrew Jones <[email protected]>Cc Jim Mattson <[email protected]>Signed-off-by Sean Christopherson <[email protected]>
Quoted 6 lines
--- lib/alloc_page.c | 2 +- lib/alloc_page.h | 2 +- lib/bitops.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Fixes compilation on arm32.
Quoted 16 lines · Sean Christopherson
Revert to using 'unsigned long' instead of '
size_t' forfree_pages()andget_order(). The recent change tosize_tforfree_pages()breaks i386 with -Werror as theassert_msg()formats expect unsigned longs, whereassize_tis an 'unsigned int' on i386 (though both longs and ints are 4 bytes).Message formatting aside, unsigned long is the correct choice given the current code base as
alloc_pages()andfree_pages_by_order()explicitly expect, work on, and/or assert on the size being an unsigned long.Fixes 73f4b202beb39 ("lib/alloc_page: change some parameter types")Cc Claudio Imbrenda <[email protected]>Cc Andrew Jones <[email protected]>Cc Jim Mattson <[email protected]>Signed-off-by Sean Christopherson <[email protected]>---
[...]
Quoted 6 lines
lib/bitops.h +0
-0
lib/bitops.h static inline bool is_power_of_2(unsigned long n) · line 85
Quoted 8 lines
lib/bitops.h +1
-1@@ -79,7 +79,7 @@ static inline bool is_power_of_2(unsigned long n)return n && !(n & (n -1 )); } -static inline unsigned int get_order (size_t size) +static inline unsigned int get_order (unsigned long size) {return size ?fls (size) + !is_power_of_2 (size) :0 ; }
get_order() already used size_t when it was introduced in commit f22e527df02ffaba ... is it necessary to switch it to unsigned long now?
Apart from that, this patch fixes the compilation problems, indeed, I just checked it in the travis-CI.
Quoted 38 lines · On Tue, 14 Jul 2020 09:12:52 +0200 Thomas Huth <[email protected]> wrote:
Quoted 17 lines · Sean Christopherson
Revert to using 'unsigned long' instead of '
size_t' forfree_pages()andget_order(). The recent change tosize_tforfree_pages()breaks i386 with -Werror as theassert_msg()formats expect unsigned longs, whereassize_tis an 'unsigned int' on i386 (though both longs and ints are 4 bytes).Message formatting aside, unsigned long is the correct choice given the current code base as
alloc_pages()andfree_pages_by_order()explicitly expect, work on, and/or assert on the size being an unsigned long.Fixes 73f4b202beb39 ("lib/alloc_page: change some parameter types")Cc Claudio Imbrenda <[email protected]>Cc Andrew Jones <[email protected]>Cc Jim Mattson <[email protected]>Signed-off-by Sean Christopherson <[email protected]>---
[...]
Quoted 6 lines
lib/bitops.h +0
-0lib/bitops.h static inline bool is_power_of_2(unsigned long n) · line 85
Quoted 8 lines
lib/bitops.h +1
-1@@ -79,7 +79,7 @@ static inline bool is_power_of_2(unsigned long n)return n && !(n & (n -1 )); } -static inline unsigned int get_order (size_t size) +static inline unsigned int get_order (unsigned long size) {return size ?fls (size) + !is_power_of_2 (size) :0 ; }
get_order()already usedsize_twhen it was introduced in commitf22e527df02ffaba... is it necessary to switch it to unsigned long now?
Quoted 4 lines
Apart from that, this patch fixes the compilation problems, indeed, I just checked it in the travis-CI.
Tested-by Thomas Huth <[email protected]>
Yeah I don't think there is any reason to change get_order...