From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1L3uWr-0000p4-Ln for mharc-grub-devel@gnu.org; Sat, 22 Nov 2008 10:36:13 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L3uWo-0000nK-Qo for grub-devel@gnu.org; Sat, 22 Nov 2008 10:36:11 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L3uWl-0000jW-6x for grub-devel@gnu.org; Sat, 22 Nov 2008 10:36:09 -0500 Received: from [199.232.76.173] (port=49022 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L3uWk-0000j9-PX for grub-devel@gnu.org; Sat, 22 Nov 2008 10:36:06 -0500 Received: from aybabtu.com ([69.60.117.155]:60298) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L3uWk-0001bv-EX for grub-devel@gnu.org; Sat, 22 Nov 2008 10:36:06 -0500 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1L3uUN-0004AM-0H; Sat, 22 Nov 2008 16:33:40 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1L3uVp-0000AR-KQ; Sat, 22 Nov 2008 16:35:09 +0100 Date: Sat, 22 Nov 2008 16:35:09 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20081122153509.GA576@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline 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-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [PATCH] (ata.mod) avoid passing grub_errno to upper layer 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: Sat, 22 Nov 2008 15:36:12 -0000 --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, When an error is detected by ata.mod during drive scan, it will pass it to the upper layer. This results in GRUB aborting when trying to enter normal mode, even if the error is not critical (e.g. affects a drive not used during boot). There are a number of places in ata.mod where these errors could be handled, so I'm not sure if my proposed change would be the best approach. Some comment would be appreciated. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --k+w/mQv8wyuph6w0 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ata.diff" 2008-11-22 Robert Millan * disk/ata.c (grub_ata_device_initialize): Avoid passing grub_errno conditions to the upper layer unless they're critical. Index: disk/ata.c =================================================================== --- disk/ata.c (revision 1926) +++ disk/ata.c (working copy) @@ -421,19 +421,13 @@ grub_ata_device_initialize (int port, in grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A); grub_ata_wait (); if (grub_ata_regget (dev, GRUB_ATA_REG_SECTORS) != 0x5A) - { - grub_free(dev); - return 0; - } + goto fail; /* Detect if the device is present by issuing a EXECUTE DEVICE DIAGNOSTICS command. */ grub_ata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4); if (grub_ata_cmd (dev, GRUB_ATA_CMD_EXEC_DEV_DIAGNOSTICS)) - { - grub_free (dev); - return grub_errno; - } + goto fail; grub_ata_wait (); grub_dprintf ("ata", "Registers: %x %x %x %x\n", @@ -460,23 +454,29 @@ grub_ata_device_initialize (int port, in else { grub_dprintf ("ata", "incorrect signature\n"); - grub_free (dev); - return 0; + goto fail; } /* Use the IDENTIFY DEVICE command to query the device. */ if (grub_ata_identify (dev)) - { - grub_free (dev); - return 0; - } + goto fail; /* Register the device. */ for (devp = &grub_ata_devices; *devp; devp = &(*devp)->next); *devp = dev; return 0; + + fail: + grub_free (dev); + + /* If there were errors it means we didn't register this device. Since other + devices may be fine, we don't pass this to the upper layer. */ + if (grub_errno) + grub_print_error (); + + return 0; } static int --k+w/mQv8wyuph6w0--