On Mon, Apr 23, 2018 at 03:57:22PM +0200, Daniel Kiper wrote: > On Fri, Apr 20, 2018 at 03:21:30PM +0800, Michael Chang wrote: > > Rounding up the bufio->block_size to meet power of 2 to facilitate next_buf > > calcuation in grub_bufio_read. > > > > Signed-off-by: Michael Chang <mch...@suse.com> > > --- > > grub-core/io/bufio.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c > > index 22438277d..4d66b65a3 100644 > > --- a/grub-core/io/bufio.c > > +++ b/grub-core/io/bufio.c > > @@ -61,6 +61,14 @@ grub_bufio_open (grub_file_t io, int size) > > size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE : > > io->size); > > > > + /* round up size to power of 2 */ > > May I ask you to say why here?
OK. > > > + if (size & (size - 1)) > > + { > > + int round_up; > > + for (round_up = 1; round_up < size; round_up <<= 1); > > + size = round_up; > > + } > > Please use this (stolen from linux/drivers/md/raid5.c): > while (size & (size - 1)) > size = (size | (size - 1)) + 1; Cool. They will be added in upcoming V2 patch. Thanks, Michael > > Daniel _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel