lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 19 Aug 2019 00:39:25 -0400
From:   "Theodore Y. Ts'o" <tytso@....edu>
To:     Dongyang Li <dongyangli@....com>
Cc:     "linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
        "adilger@...ger.ca" <adilger@...ger.ca>
Subject: Re: [PATCH 1/2] libext2fs: optimize
 ext2fs_convert_subcluster_bitmap()

On Fri, Aug 16, 2019 at 03:49:12AM +0000, Dongyang Li wrote:
> @@ -28,6 +28,7 @@
>  #ifdef HAVE_SYS_TIME_H
>  #include <sys/time.h>
>  #endif
> +#include <sys/param.h>
>  
>  #include "ext2_fs.h"
>  #include "ext2fsP.h"

Please don't don't depend on <sys/param.h> for definitions of macros
like roundup().  It's not going to be present on all OS's, and
e2fsprogs needs to be portable to more systems than just Linux.

Furthermore, if you look in ext2fs.h, we already have the macros:

#define EXT2FS_B2C(fs, blk) 	      ((blk) >> (fs)->cluster_ratio_bits)
#define EXT2FS_C2B(fs, cluster)	   ((cluster) << (fs)->cluster_ratio_bits)

... which translates a block to a cluster number and vice versa.
(Note that the cluster:block ratio is always a power of two.)

So instead of this:

> +		i = bmap->start + roundup(next - bmap->start + 1, ratio);

you can do this:

		i = EXT2FS_C2B(fs, EXT2FS_B2C(fs, next) + 1);

cheers,

					- Ted

Powered by blists - more mailing lists