All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marco Gerards <mgerards@xs4all.nl>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Allow build without dirent.d_type, fix "ls (host)" crash
Date: Sat, 10 Nov 2007 17:03:48 +0100	[thread overview]
Message-ID: <87ve8agk9n.fsf@xs4all.nl> (raw)
In-Reply-To: <4734CBEB.7080500@t-online.de> (Christian Franke's message of "Fri, 09 Nov 2007 22:06:51 +0100")

Christian Franke <Christian.Franke@t-online.de> writes:

> Marco Gerards wrote:
>
>>> ...
>>> +static int
>>> +is_dir(const char *path, const char *name)
>>>
>>
>> is_dir (
>>
>>
>
> OK. Too many projects, too many policies, sorry :-)

np, don't worry :-)

Hopefully you are not annoyed by my comments.  A consistent style
throughout GRUB is important to me.

>>> +{
>>> +  int len1 = strlen(path), len2 = strlen(name);
>>>
>>
>> Please split this up.  Or even better use separate declarations and
>> code.
>>
>>
>
> Yes. No. See comment below.
>
>>> +  char pathname[len1+1+len2+1+13];
>>>
>>
>> Please add spaces around binary operators.
>>
>>
>>> +  struct stat st;
>>> +  strcpy (pathname, path);
>>>
>>
>> Please add more blank lines between your code to make it easier to
>> read. :-)
>>
>>
>
> OK.
>
>
>>> ...
>>> +    strcat (pathname, "/");
>>> +  strcat (pathname, name);
>>> +  if (stat (pathname, &st))
>>> +    return 0;
>>> +  return S_ISDIR(st.st_mode);
>>> +}
>>> +#endif
>>>
>>
>> Why can't you just use S_ISDIR?
>>
>>
>
> ??

Nevermind, I wasn't really awake ;)

>>> ...
>>> @@ -81,6 +108,7 @@ grub_hostfs_read (grub_file_t file, char
>>>    FILE *f;
>>>     f = (FILE *) file->data;
>>> +  fseek (f, file->offset, SEEK_SET);
>>>    int s= fread (buf, 1, len, f);
>>>
>>
>> "int s = "
>>
>>
>
> Code janitor work outside the scope of this patch ... done ;-)

LOL!  Sorry, I was a bit enthousiastic ;-)

Thanks! :)

> BTW: This line uses "declaration statement" syntax, therefore this is
> apparently accepted in GRUB2 codebase :-)
> I definitely prefer this (first use = declaration = initialization)
> style, which is state of the art in most (all?) modern languages.
> This C++ (1986) feature and early GCC (1.*) extension was finally
> included into C99, so it is portable now.
> is_dir() rewritten accordingly.

It is.  The problem is that you had two function calls on one line.  I
want to avoid that.

> Christian
>
> 2007-11-09  Christian Franke  <franke@computer.org>
>
> 	* util/hostfs.c (is_dir): New function.
> 	(grub_hostfs_dir):  Handle missing dirent.d_type case.
> 	(grub_hostfs_read): Add missing fseek().
> 	(grub_hostfs_label): Clear label pointer.  This fixes a crash
> 	of grub-emu on "ls (host)".

Looks fine to me.

btw, when do you use (host)?  It's intended as a debugging tool.

--
Marco





  reply	other threads:[~2007-11-10 16:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-23 19:50 [PATCH] Allow build without dirent.d_type, fix "ls (host)" crash Christian Franke
2007-11-02 20:59 ` Christian Franke
2007-11-09 14:55   ` Marco Gerards
2007-11-09 21:06     ` Christian Franke
2007-11-10 16:03       ` Marco Gerards [this message]
2007-11-10 18:16         ` Christian Franke
2007-11-18  7:14         ` 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=87ve8agk9n.fsf@xs4all.nl \
    --to=mgerards@xs4all.nl \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.