From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JMnz2-0004NT-8R for mharc-grub-devel@gnu.org; Wed, 06 Feb 2008 12:22:52 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JMnz0-0004N3-2J for grub-devel@gnu.org; Wed, 06 Feb 2008 12:22:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JMnyy-0004Lk-Hi for grub-devel@gnu.org; Wed, 06 Feb 2008 12:22:49 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JMnyx-0004LA-KS for grub-devel@gnu.org; Wed, 06 Feb 2008 12:22:48 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JMnyx-0002Jj-Cf for grub-devel@gnu.org; Wed, 06 Feb 2008 12:22:47 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JMnym-0002Wa-QI; Wed, 06 Feb 2008 18:22:40 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JMnOV-0000sP-1B; Wed, 06 Feb 2008 17:45:07 +0100 Date: Wed, 6 Feb 2008 17:45:07 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080206164507.GA3287@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline Content-Transfer-Encoding: 8bit Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Jeroen Dekkers Subject: [PATCH] simplify grub_raid_array X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2008 17:22:50 -0000 --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Unless I missed something, it seems that grub_raid_array contains redundant information (`name' is already present via `disk->name'). I propose to simplify it this way. -- Robert Millan I know my rights; I want my phone call! What use is a phone call… if you are unable to speak? (as seen on /.) --Q68bSM7Ycu6FN28Q Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="simplify_grub_raid_array.diff" diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/disk/raid.c ./disk/raid.c --- ../grub2/disk/raid.c 2007-12-30 09:52:03.000000000 +0100 +++ ./disk/raid.c 2008-02-06 17:35:24.000000000 +0100 @@ -146,7 +146,7 @@ grub_raid_read (grub_disk_t disk, grub_d { grub_uint32_t i; - err = grub_disk_read (array->device[disknr].disk, read_sector, 0, + err = grub_disk_read (array->device[disknr], read_sector, 0, read_size << GRUB_DISK_SECTOR_BITS, buf); if (err) break; @@ -189,9 +189,9 @@ grub_raid_read (grub_disk_t disk, grub_d for (i = 0; i < array->total_devs; i++) { - if (array->device[i].disk) + if (array->device[i]) { - err = grub_disk_read (array->device[i].disk, sector, 0, + err = grub_disk_read (array->device[i], sector, 0, size << GRUB_DISK_SECTOR_BITS, buf); if (!err) @@ -234,8 +234,8 @@ grub_raid_read (grub_disk_t disk, grub_d { grub_uint32_t i; - if (array->device[disknr].disk) - err = grub_disk_read (array->device[disknr].disk, read_sector, 0, + if (array->device[disknr]) + err = grub_disk_read (array->device[disknr], read_sector, 0, read_size << GRUB_DISK_SECTOR_BITS, buf); /* If an error occurs when we already have an degraded @@ -243,7 +243,7 @@ grub_raid_read (grub_disk_t disk, grub_d if (err && ((array->total_devs - 1) == array->nr_devs)) break; - if (err || ! array->device[disknr].disk) + if (err || ! array->device[disknr]) { /* Either an error occured or the disk is not available. We have to compute this block from the @@ -260,7 +260,7 @@ grub_raid_read (grub_disk_t disk, grub_d if (j != (unsigned int) disknr) { - err = grub_disk_read (array->device[j].disk, read_sector, + err = grub_disk_read (array->device[j], read_sector, 0, buf_size, buf2); if (err) return err; @@ -410,7 +410,7 @@ grub_raid_scan_device (const char *name) return 0; } - if (array->device[sb.this_disk.number].name != 0) + if (array->device[sb.this_disk.number]->name != 0) { /* We found multiple devices with the same number. Again, this shouldn't happen.*/ @@ -491,14 +491,10 @@ grub_raid_scan_device (const char *name) } /* Add the device to the array. */ - array->device[sb.this_disk.number].name = grub_strdup (name); - array->device[sb.this_disk.number].disk = grub_disk_open (name); + array->device[sb.this_disk.number] = grub_disk_open (name); - if (! array->device[sb.this_disk.number].name - || ! array->device[sb.this_disk.number].disk) + if (! array->device[sb.this_disk.number]) { - grub_free (array->device[sb.this_disk.number].name); - /* Remove array from the list if we have just added it. */ if (array->nr_devs == 0) { diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/include/grub/raid.h ./include/grub/raid.h --- ../grub2/include/grub/raid.h 2007-07-22 01:32:22.000000000 +0200 +++ ./include/grub/raid.h 2008-02-06 17:34:37.000000000 +0100 @@ -37,11 +37,7 @@ struct grub_raid_array char *name; /* That will be "md". */ grub_uint64_t disk_size; /* Size of an individual disk, in 512 byte sectors. */ - struct - { - char *name; /* Name of the device */ - grub_disk_t disk; /* The device itself. */ - } device[32]; /* Array of total_devs devices. */ + grub_disk_t device[32]; /* Array of total_devs devices. */ struct grub_raid_array *next; }; --Q68bSM7Ycu6FN28Q--