[PATCH 5/6] lib/scatterlist: Use appropriate type for elem_len in sgl_alloc_order

Tvrtko Ursulin
2018-09-26T14:16:44Z

We should not use an explicit width u32 for elem_len but unsinged int to
match the underlying type in struct scatterlist.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Jens Axboe <axboe@kernel.dk>
---
lib/scatterlist.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 0caed79d7291..581a2e91e515 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -481,8 +481,7 @@ struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order,
{
struct scatterlist *sgl, *sg;
struct page *page;
- unsigned int nent, nalloc, i;
- u32 elem_len;
+ unsigned int nent, nalloc, elem_len, i;

nent = round_up(length, PAGE_SIZE << order) >> (PAGE_SHIFT + order);
/* Check for integer overflow */
@@ -503,7 +502,7 @@ struct scatterlist *sgl_alloc_order(unsigned long length, unsigned int order,
sg = sgl;
i = 0;
while (length) {
- elem_len = min_t(u64, length, PAGE_SIZE << order);
+ elem_len = min_t(unsigned long, length, PAGE_SIZE << order);
page = alloc_pages(gfp, order);
if (!page) {
sgl_free_n_order(sgl, i, order);
--
2.17.1