All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vesa Jääskeläinen" <chaac@nic.fi>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Grub2 cannot find LVM volume groups with a dash (-) in the name
Date: Tue, 02 Sep 2008 17:59:25 +0300	[thread overview]
Message-ID: <48BD54CD.3000907@nic.fi> (raw)
In-Reply-To: <1220344081.4101.2.camel@fz.local>

Felix Zielcke wrote:
> Am Dienstag, den 02.09.2008, 00:46 +0200 schrieb Felix Zielcke:
> 
>> I'm too lazy now to make a new patch and go sleeping now.
>> [...]
>>
>> I hope that Marco could have a quick look over it especially the
>> changelog part :)
> 
> Final patch attached.
> In changelog I had again past and present mixed and I just use now the
> `normal' types instead of grub_uintN_t, seems like that's more used on
> util/
> So if there are no objections I'd like to commit this :)

> +	unsigned short i, j;
> +	const unsigned char k = sizeof ("/dev/mapper/") - 1;
> +	const unsigned short l = strlen (os_dev) - k + 1;

sizeof returns type of size_t so it would be good that char k uses that.
I am a bit surprised that this didn't generate compiler warning? And
there is no reason to define integers as constants unless you really
want to make sure they don't change :)

I assume we have grub_size_t or comparable there.

> +	const unsigned short l = strlen (os_dev) - k + 1;
>  
> -      break;
> +	grub_dev = xmalloc (strlen (os_dev) - k + 1);

if you already calculate something to variable it would be nice to
re-use that calculation again.

> +	for (i = 0, j = 0; i < l; i++, j++)
> +	  {
> +	    grub_dev[j] = os_dev[k + i];
> +	    if (os_dev[k + i] == '-' && os_dev[k + i + 1] == '-')
> +	      i++;
> +	  }

Can't you index i: k <= i < strlen(os_dev)? Would make this a bit more
readable. Or as you could just increment k in every loop and use that to
index. Your 0 <= j < l should limit char array.

You could use a bit more descriptive names like l->len, k->start/offset.
For indexes we quite often use i,j,k.

> +	  p = strchr (os_dev, 'p');
> +	  if (p)
> +	    *p = ',';

It is usually a bad idea to modify source string.



  reply	other threads:[~2008-09-02 14:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080808202337.3440.57502.reportbug@sylvester.jejik.com.jejik.com>
2008-08-09 10:26 ` Bug#494383: grub-pc: Grub2 cannot find LVM volume groups with a dash (-) in the name Felix Zielcke
2008-08-09 12:55   ` Felix Zielcke
2008-08-10 13:19   ` Sander Marechal
2008-08-11 16:18     ` [PATCH] " Felix Zielcke
2008-08-11 21:48       ` Sander Marechal
2008-08-14 17:34       ` Felix Zielcke
2008-08-14 18:03         ` Robert Millan
2008-08-14 19:32           ` Felix Zielcke
2008-08-14 20:38             ` Robert Millan
2008-08-14 21:15               ` Felix Zielcke
2008-08-18 15:05                 ` Felix Zielcke
2008-08-18 15:16                   ` Felix Zielcke
2008-09-01  7:08                     ` Felix Zielcke
2008-09-01 22:14                   ` Robert Millan
2008-09-01 22:46                     ` Felix Zielcke
2008-09-02  8:28                       ` Felix Zielcke
2008-09-02 14:59                         ` Vesa Jääskeläinen [this message]
2008-09-02 15:59                           ` Felix Zielcke
2008-09-02 16:21                             ` Vesa Jääskeläinen
2008-09-04 19:56                             ` Felix Zielcke
2008-09-02 13:37                       ` 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=48BD54CD.3000907@nic.fi \
    --to=chaac@nic.fi \
    --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.