[fs/squashfs PATCH v3 2/2] avoid 64-bit divisions on 32-bit

Thomas Petazzoni thomas.petazzoni at bootlin.com
Thu Oct 8 09:42:51 CEST 2020


Hello,

The commit title lacks a proper prefix, it should start with
"fs/squashfs". You confused the prefix of the commit title with the
"subject prefix" of format-patch.

On Thu,  8 Oct 2020 00:30:21 +0200
Mauro Condarelli <mc5686 at mclink.it> wrote:

> diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
> index 15208b4dab..ef9f5e3449 100644
> --- a/fs/squashfs/sqfs.c
> +++ b/fs/squashfs/sqfs.c
> @@ -10,14 +10,14 @@
>  #include <asm/unaligned.h>
>  #include <errno.h>
>  #include <fs.h>
> -#include <linux/types.h>
> +#include <linux/kernel.h>
> +#include <div64.h>

Do we need both ?

>  #include <linux/byteorder/little_endian.h>
>  #include <linux/byteorder/generic.h>
>  #include <memalign.h>
>  #include <stdlib.h>
>  #include <string.h>
>  #include <squashfs.h>
> -#include <part.h>

Is this change related ?

>  #include "sqfs_decompressor.h"
>  #include "sqfs_filesystem.h"
> @@ -85,10 +85,10 @@ static int sqfs_calc_n_blks(__le64 start, __le64 end, u64 *offset)
>  	u64 start_, table_size;
>  
>  	table_size = le64_to_cpu(end) - le64_to_cpu(start);
> -	start_ = le64_to_cpu(start) / ctxt.cur_dev->blksz;
> +	start_ = DIV_ROUND_DOWN_ULL(le64_to_cpu(start), ctxt.cur_dev->blksz);
>  	*offset = le64_to_cpu(start) - (start_ * ctxt.cur_dev->blksz);
>  
> -	return DIV_ROUND_UP(table_size + *offset, ctxt.cur_dev->blksz);
> +	return (table_size + *offset + ctxt.cur_dev->blksz - 1) >> ctxt.cur_dev->log2blksz;

Why are you not using DIV_ROUND_UP_ULL() here ?

Thanks,

Thomas Petazzoni
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


More information about the U-Boot mailing list