From: "Javier Martín" <lordhabbit@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: grub-probe detects ext4 wronly as ext2
Date: Sat, 30 Aug 2008 23:28:25 +0200 [thread overview]
Message-ID: <1220131705.2622.19.camel@localhost> (raw)
In-Reply-To: <20080830111753.GA16775@thorin>
[-- Attachment #1: Type: text/plain, Size: 3751 bytes --]
Hello there! It's nice to be in town again, though post-vacation
syndrome is hitting me full... Resuming the thread,
El sáb, 30-08-2008 a las 13:17 +0200, Robert Millan escribió:
> On Mon, Aug 11, 2008 at 04:14:00PM +0200, Javier Martín wrote:
> > >> > This overrides the grub_errno and grub_errmsg provided by grub_disk_read and
> > >> > replaces them with values that hide the true problem. If there was a disk
> > >> > read error, we really want to know about it from the lower layer.
> > >> Well, the old version did just the same (even worse, because the message
> > >> was generic). What would be the correct path of action here? I mean, how
> > >> can we propagate the error messages?
> > >
> > > It shouldn't call grub_error().
> >
> > So in the cases the fail is caused by an underlying error (like I/O)
> > the code should just return failure and leave the old error in errno
> > and errmsg?
>
> Yes.
Ok, so that's already done in the previous patch.
>
> > static struct grub_ext2_data *
> > grub_ext2_mount (grub_disk_t disk)
> > {
> > struct grub_ext2_data *data;
> > + const char *local_error = 0;
>
> Please use NULL for pointers.
I don't object at all, but 0 is used throughout the GRUB code to
represent null pointers (see the args struct in any command source
file), so I don't understand the criterion being applied here.
>
> > - if (grub_errno)
> > + if (grub_errno != GRUB_ERR_NONE)
>
> Why?
1st, because the condition being checked is explicit and thus clearer.
These int->bool C conventions are, even though enshrined by ANSI and
thus pretty standard and reliable, irky at best and due only to the lack
of a proper boolean type. As I think I stated before, the only cases I
use such "cast" is when checking for null pointers and when using
variables that are explicitly boolean in nature.
2nd, because the new code does not assume that GRUB_ERR_NONE is defined
to zero. Even though this definition will most likely never change, we
might one day decide that -42 is a better value for success.
3rd, because in addition to all that, with any sensible compiler, the
additional binary size cost is nothing at all.
>
> > - goto fail;
> > + EXT2_DRIVER_MOUNT_FAIL(0);
>
> I find very little use in this. I assume it's supposed to simplify things,
> but in fact it adds an extra level of indirection for someone who's reading
> the code. It provides no runtime improvement, and it's inconsistent with what
> we do elsewhere.
It is not meant to provide any runtime improvement, it's just for
consistency: since local_error is already zero, a "goto fail" would
suffice but I think this uniformity adds readability, not hinders it:
the referenced macro is at the very top of the function, not on a
included header, so the reference is not very time-consuming; and it's
not very complex, so it only needs to be read once. Besides, most
compilers should just optimize the extra assignment away given that the
value of local_error is ct-known for the code paths leading to that
statement and it is not a "volatile" variable.
>
> > + /* Only call grub_error if the fail was _not_ caused by underlying errors. */
>
> No need to document this. It's the same deal in a huge amount of routines
> throurough the GRUB source.
OK, removed the comment. Maybe a similar comment will be fine over the
macro, though.
That was all, folks! Given that I (think I) addressed your two main
objections, I won't send a new patch right now. I will continue to read
the list this month, but my availability is likely to vary wildly, as I
will be trapped by the ensnaring bureaucracy of the Spanish
universities, scholarships, etc.
-Habbit
[-- Attachment #2: Esta parte del mensaje está firmada digitalmente --]
[-- Type: application/pgp-signature, Size: 827 bytes --]
next prev parent reply other threads:[~2008-08-30 21:26 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-29 18:11 grub-probe detects ext4 wronly as ext2 Felix Zielcke
2008-06-29 18:46 ` Javier Martín
2008-06-29 19:17 ` Bean
2008-06-29 19:53 ` Javier Martín
2008-06-29 21:19 ` Robert Millan
2008-06-30 3:02 ` Javier Martín
2008-06-30 7:10 ` Felix Zielcke
2008-06-30 11:14 ` Isaac Dupree
2008-06-30 12:12 ` Javier Martín
2008-06-30 12:27 ` Bean
2008-06-30 12:43 ` Javier Martín
2008-07-01 16:08 ` Robert Millan
2008-07-01 16:25 ` Pavel Roskin
2008-07-01 18:42 ` Javier Martín
2008-07-01 19:01 ` Pavel Roskin
2008-07-01 20:48 ` Robert Millan
2008-07-01 23:05 ` Javier Martín
2008-07-01 23:28 ` Javier Martín
2008-07-02 14:22 ` Robert Millan
2008-07-02 16:03 ` Pavel Roskin
2008-07-02 19:32 ` Javier Martín
2008-07-03 14:02 ` Robert Millan
2008-07-03 14:21 ` Isaac Dupree
2008-07-03 17:07 ` Javier Martín
2008-07-04 0:08 ` Robert Millan
2008-07-04 1:20 ` Javier Martín
2008-08-05 17:23 ` Felix Zielcke
2008-08-06 10:36 ` Felix Zielcke
2008-08-11 0:35 ` Javier Martín
2008-08-11 7:56 ` Felix Zielcke
2008-07-04 1:32 ` Javier Martín
2008-07-04 6:49 ` Bean
2008-07-04 8:33 ` Felix Zielcke
2008-07-04 10:34 ` Javier Martín
2008-07-04 11:29 ` Bean
2008-07-04 12:00 ` Javier Martín
2008-07-04 14:09 ` Robert Millan
2008-07-04 14:33 ` Javier Martín
2008-07-04 14:11 ` Bean
2008-07-04 14:34 ` Javier Martín
2008-07-04 14:04 ` Robert Millan
2008-07-04 14:23 ` Robert Millan
2008-07-04 14:21 ` Robert Millan
2008-07-04 14:45 ` Javier Martín
2008-07-04 18:57 ` Robert Millan
2008-07-04 20:41 ` Javier Martín
2008-07-05 12:07 ` Robert Millan
2008-07-05 18:36 ` Javier Martín
2008-07-16 15:09 ` Javier Martín
2008-07-16 15:27 ` Felix Zielcke
2008-07-16 16:38 ` Javier Martín
2008-07-16 17:13 ` Felix Zielcke
2008-07-16 17:21 ` Felix Zielcke
2008-07-16 17:44 ` Felix Zielcke
2008-07-16 19:07 ` Javier Martín
2008-07-16 19:33 ` Felix Zielcke
2008-07-19 14:27 ` Robert Millan
2008-08-11 14:14 ` Javier Martín
2008-08-27 13:58 ` Felix Zielcke
2008-08-30 11:17 ` Robert Millan
2008-08-30 21:28 ` Javier Martín [this message]
2008-09-24 17:05 ` Javier Martín
2009-02-04 7:41 ` Felix Zielcke
2009-02-04 13:08 ` Javier Martín
2009-02-07 19:30 ` Felix Zielcke
2009-02-07 23:54 ` Javier Martín
2009-02-08 0:28 ` Robert Millan
2008-07-01 16:03 ` Robert Millan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220131705.2622.19.camel@localhost \
--to=lordhabbit@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox