Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Tq3JZ-0003DZ-Nz for mharc-grub-devel@gnu.org; Tue, 01 Jan 2013 09:59:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:46426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tq3JW-0003B5-8Z for grub-devel@gnu.org; Tue, 01 Jan 2013 09:59:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tq3JU-0004OY-IV for grub-devel@gnu.org; Tue, 01 Jan 2013 09:59:34 -0500 Received: from chiark.greenend.org.uk ([212.13.197.229]:46098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tq3JU-0004Na-By for grub-devel@gnu.org; Tue, 01 Jan 2013 09:59:32 -0500 Received: from [172.20.153.9] (helo=riva.pelham.vpn.ucam.org) by chiark.greenend.org.uk (Debian Exim 4.72 #1) with esmtps (return-path cjwatson@ubuntu.com) id 1Tq3JT-0007Ce-Aj for grub-devel@gnu.org; Tue, 01 Jan 2013 14:59:31 +0000 Received: from localhost ([127.0.0.1] helo=sarantium.pelham.vpn.ucam.org) by riva.pelham.vpn.ucam.org with esmtp (Exim 4.72) (envelope-from ) id 1Tq3JS-00070U-Ju for grub-devel@gnu.org; Tue, 01 Jan 2013 14:59:30 +0000 Received: from riva.dynamic.greenend.org.uk (localhost [127.0.0.1]) by sarantium.pelham.vpn.ucam.org (Postfix) with ESMTPS id 3F0443E5027 for ; Tue, 1 Jan 2013 14:58:54 +0000 (GMT) Date: Tue, 1 Jan 2013 14:58:52 +0000 From: Colin Watson To: grub-devel@gnu.org Subject: [PATCH] Remove unnecessary zero-initialisations from *io.c Message-ID: <20130101145852.GA21398@riva.dynamic.greenend.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 212.13.197.229 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jan 2013 14:59:35 -0000 This patch removes explicit zero-initialisations from *io.c in favour of grub_zalloc. Is there any good reason to initialise these explicitly? This reduces the size of all four of these modules on i386-pc as follows: bufio -56 gzio -24 lzopio -20 xzio -64 2013-01-01 Colin Watson * grub-core/io/bufio.c (grub_bufio_open): Use grub_zalloc instead of explicitly zeroing elements. * grub-core/io/gzio.c (grub_gzio_open): Likewise. * grub-core/io/lzopio.c (grub_lzopio_open): Remove explicit zeroing of elements in a structure already allocated using grub_zalloc. * grub-core/io/xzio.c (grub_xzio_open): Likewise. === modified file 'grub-core/io/bufio.c' --- grub-core/io/bufio.c 2011-12-25 14:43:15 +0000 +++ grub-core/io/bufio.c 2013-01-01 14:38:07 +0000 @@ -48,7 +48,7 @@ grub_bufio_open (grub_file_t io, int siz grub_file_t file; grub_bufio_t bufio = 0; - file = (grub_file_t) grub_malloc (sizeof (*file)); + file = (grub_file_t) grub_zalloc (sizeof (*file)); if (! file) return 0; @@ -61,7 +61,7 @@ grub_bufio_open (grub_file_t io, int siz size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE : io->size); - bufio = grub_malloc (sizeof (struct grub_bufio) + size); + bufio = grub_zalloc (sizeof (struct grub_bufio) + size); if (! bufio) { grub_free (file); @@ -70,14 +70,10 @@ grub_bufio_open (grub_file_t io, int siz bufio->file = io; bufio->block_size = size; - bufio->buffer_len = 0; - bufio->buffer_at = 0; file->device = io->device; - file->offset = 0; file->size = io->size; file->data = bufio; - file->read_hook = 0; file->fs = &grub_bufio_fs; file->not_easily_seekable = io->not_easily_seekable; === modified file 'grub-core/io/gzio.c' --- grub-core/io/gzio.c 2012-03-06 13:11:10 +0000 +++ grub-core/io/gzio.c 2013-01-01 14:38:03 +0000 @@ -1130,7 +1130,7 @@ grub_gzio_open (grub_file_t io) grub_file_t file; grub_gzio_t gzio = 0; - file = (grub_file_t) grub_malloc (sizeof (*file)); + file = (grub_file_t) grub_zalloc (sizeof (*file)); if (! file) return 0; @@ -1144,9 +1144,7 @@ grub_gzio_open (grub_file_t io) gzio->file = io; file->device = io->device; - file->offset = 0; file->data = gzio; - file->read_hook = 0; file->fs = &grub_gzio_fs; file->not_easily_seekable = 1; === modified file 'grub-core/io/lzopio.c' --- grub-core/io/lzopio.c 2012-04-07 17:54:51 +0000 +++ grub-core/io/lzopio.c 2013-01-01 14:38:26 +0000 @@ -428,9 +428,7 @@ grub_lzopio_open (grub_file_t io) lzopio->file = io; file->device = io->device; - file->offset = 0; file->data = lzopio; - file->read_hook = 0; file->fs = &grub_lzopio_fs; file->size = GRUB_FILE_SIZE_UNKNOWN; file->not_easily_seekable = 1; === modified file 'grub-core/io/xzio.c' --- grub-core/io/xzio.c 2012-02-12 14:25:25 +0000 +++ grub-core/io/xzio.c 2013-01-01 14:39:38 +0000 @@ -186,12 +186,9 @@ grub_xzio_open (grub_file_t io) } xzio->file = io; - xzio->saved_offset = 0; file->device = io->device; - file->offset = 0; file->data = xzio; - file->read_hook = 0; file->fs = &grub_xzio_fs; file->size = GRUB_FILE_SIZE_UNKNOWN; file->not_easily_seekable = 1; @@ -210,10 +207,7 @@ grub_xzio_open (grub_file_t io) } xzio->buf.in = xzio->inbuf; - xzio->buf.in_pos = 0; - xzio->buf.in_size = 0; xzio->buf.out = xzio->outbuf; - xzio->buf.out_pos = 0; xzio->buf.out_size = XZBUFSIZ; /* FIXME: don't test footer on not easily seekable files. */ Thanks, -- Colin Watson [cjwatson@ubuntu.com]