a5bd9f6
From c86f86069fd8d600ebc4ffbd8a786c58fccff886 Mon Sep 17 00:00:00 2001
a5bd9f6
From: Colin Watson <cjwatson@ubuntu.com>
a5bd9f6
Date: Mon, 7 Jan 2013 10:45:05 +0000
a5bd9f6
Subject: [PATCH 090/364] * grub-core/io/bufio.c (grub_bufio_open): Use
a5bd9f6
 grub_zalloc instead of explicitly zeroing elements. * grub-core/io/gzio.c
a5bd9f6
 (grub_gzio_open): Likewise. * grub-core/io/lzopio.c (grub_lzopio_open):
a5bd9f6
 Remove explicit zeroing of elements in a structure already allocated using
a5bd9f6
 grub_zalloc. * grub-core/io/xzio.c (grub_xzio_open): Likewise.
a5bd9f6
a5bd9f6
---
a5bd9f6
 ChangeLog             | 9 +++++++++
a5bd9f6
 grub-core/io/bufio.c  | 8 ++------
a5bd9f6
 grub-core/io/gzio.c   | 4 +---
a5bd9f6
 grub-core/io/lzopio.c | 2 --
a5bd9f6
 grub-core/io/xzio.c   | 6 ------
a5bd9f6
 5 files changed, 12 insertions(+), 17 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index 097ef0d..75fb85a 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,5 +1,14 @@
a5bd9f6
 2013-01-07  Colin Watson  <cjwatson@ubuntu.com>
a5bd9f6
 
a5bd9f6
+	* grub-core/io/bufio.c (grub_bufio_open): Use grub_zalloc instead of
a5bd9f6
+	explicitly zeroing elements.
a5bd9f6
+	* grub-core/io/gzio.c (grub_gzio_open): Likewise.
a5bd9f6
+	* grub-core/io/lzopio.c (grub_lzopio_open): Remove explicit zeroing
a5bd9f6
+	of elements in a structure already allocated using grub_zalloc.
a5bd9f6
+	* grub-core/io/xzio.c (grub_xzio_open): Likewise.
a5bd9f6
+
a5bd9f6
+2013-01-07  Colin Watson  <cjwatson@ubuntu.com>
a5bd9f6
+
a5bd9f6
 	* docs/grub.texi (grub_cpu): New subsection.
a5bd9f6
 	(grub_platform): Likewise.
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c
a5bd9f6
index 2a315e2..2243827 100644
a5bd9f6
--- a/grub-core/io/bufio.c
a5bd9f6
+++ b/grub-core/io/bufio.c
a5bd9f6
@@ -48,7 +48,7 @@ grub_bufio_open (grub_file_t io, int size)
a5bd9f6
   grub_file_t file;
a5bd9f6
   grub_bufio_t bufio = 0;
a5bd9f6
 
a5bd9f6
-  file = (grub_file_t) grub_malloc (sizeof (*file));
a5bd9f6
+  file = (grub_file_t) grub_zalloc (sizeof (*file));
a5bd9f6
   if (! file)
a5bd9f6
     return 0;
a5bd9f6
 
a5bd9f6
@@ -61,7 +61,7 @@ grub_bufio_open (grub_file_t io, int size)
a5bd9f6
     size = ((io->size > GRUB_BUFIO_MAX_SIZE) ? GRUB_BUFIO_MAX_SIZE :
a5bd9f6
             io->size);
a5bd9f6
 
a5bd9f6
-  bufio = grub_malloc (sizeof (struct grub_bufio) + size);
a5bd9f6
+  bufio = grub_zalloc (sizeof (struct grub_bufio) + size);
a5bd9f6
   if (! bufio)
a5bd9f6
     {
a5bd9f6
       grub_free (file);
a5bd9f6
@@ -70,14 +70,10 @@ grub_bufio_open (grub_file_t io, int size)
a5bd9f6
 
a5bd9f6
   bufio->file = io;
a5bd9f6
   bufio->block_size = size;
a5bd9f6
-  bufio->buffer_len = 0;
a5bd9f6
-  bufio->buffer_at = 0;
a5bd9f6
 
a5bd9f6
   file->device = io->device;
a5bd9f6
-  file->offset = 0;
a5bd9f6
   file->size = io->size;
a5bd9f6
   file->data = bufio;
a5bd9f6
-  file->read_hook = 0;
a5bd9f6
   file->fs = &grub_bufio_fs;
a5bd9f6
   file->not_easily_seekable = io->not_easily_seekable;
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c
a5bd9f6
index 83c0b64..59f2206 100644
a5bd9f6
--- a/grub-core/io/gzio.c
a5bd9f6
+++ b/grub-core/io/gzio.c
a5bd9f6
@@ -1130,7 +1130,7 @@ grub_gzio_open (grub_file_t io)
a5bd9f6
   grub_file_t file;
a5bd9f6
   grub_gzio_t gzio = 0;
a5bd9f6
 
a5bd9f6
-  file = (grub_file_t) grub_malloc (sizeof (*file));
a5bd9f6
+  file = (grub_file_t) grub_zalloc (sizeof (*file));
a5bd9f6
   if (! file)
a5bd9f6
     return 0;
a5bd9f6
 
a5bd9f6
@@ -1144,9 +1144,7 @@ grub_gzio_open (grub_file_t io)
a5bd9f6
   gzio->file = io;
a5bd9f6
 
a5bd9f6
   file->device = io->device;
a5bd9f6
-  file->offset = 0;
a5bd9f6
   file->data = gzio;
a5bd9f6
-  file->read_hook = 0;
a5bd9f6
   file->fs = &grub_gzio_fs;
a5bd9f6
   file->not_easily_seekable = 1;
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c
a5bd9f6
index 77291d0..7fdb6d4 100644
a5bd9f6
--- a/grub-core/io/lzopio.c
a5bd9f6
+++ b/grub-core/io/lzopio.c
a5bd9f6
@@ -428,9 +428,7 @@ grub_lzopio_open (grub_file_t io)
a5bd9f6
   lzopio->file = io;
a5bd9f6
 
a5bd9f6
   file->device = io->device;
a5bd9f6
-  file->offset = 0;
a5bd9f6
   file->data = lzopio;
a5bd9f6
-  file->read_hook = 0;
a5bd9f6
   file->fs = &grub_lzopio_fs;
a5bd9f6
   file->size = GRUB_FILE_SIZE_UNKNOWN;
a5bd9f6
   file->not_easily_seekable = 1;
a5bd9f6
diff --git a/grub-core/io/xzio.c b/grub-core/io/xzio.c
a5bd9f6
index ae30e6f..27657d8 100644
a5bd9f6
--- a/grub-core/io/xzio.c
a5bd9f6
+++ b/grub-core/io/xzio.c
a5bd9f6
@@ -186,12 +186,9 @@ grub_xzio_open (grub_file_t io)
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
   xzio->file = io;
a5bd9f6
-  xzio->saved_offset = 0;
a5bd9f6
 
a5bd9f6
   file->device = io->device;
a5bd9f6
-  file->offset = 0;
a5bd9f6
   file->data = xzio;
a5bd9f6
-  file->read_hook = 0;
a5bd9f6
   file->fs = &grub_xzio_fs;
a5bd9f6
   file->size = GRUB_FILE_SIZE_UNKNOWN;
a5bd9f6
   file->not_easily_seekable = 1;
a5bd9f6
@@ -210,10 +207,7 @@ grub_xzio_open (grub_file_t io)
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
   xzio->buf.in = xzio->inbuf;
a5bd9f6
-  xzio->buf.in_pos = 0;
a5bd9f6
-  xzio->buf.in_size = 0;
a5bd9f6
   xzio->buf.out = xzio->outbuf;
a5bd9f6
-  xzio->buf.out_pos = 0;
a5bd9f6
   xzio->buf.out_size = XZBUFSIZ;
a5bd9f6
 
a5bd9f6
   /* FIXME: don't test footer on not easily seekable files.  */
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6