All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH,HURD] Fix grub-probe with userland partition support
Date: Fri, 27 Apr 2012 20:45:43 +0200	[thread overview]
Message-ID: <4F9AE957.1050209@gmail.com> (raw)
In-Reply-To: <20120425093721.GX29782@type.famille.thibault.fr>

[-- Attachment #1: Type: text/plain, Size: 2036 bytes --]

On 25.04.2012 11:37, Samuel Thibault wrote:
> +  /* Make sure the string is terminated.  */
> +  argz[argz_len-1] = 0;
This would fail if argz_len == 0. You have to check this case.
> +
> +  /* Skip first word (translator path) and options.  */
> +  for (i = strlen (&argz[0]) + 1; i < argz_len; i += strlen (&argz[i]) + 1)
> +    {
please use argz and argz + i
> +      if (argz[i] != '-')
> +        {
> +          /* Non-option.  Only accept one, assumed to be the FS path.  */
> +          /* XXX: this should be replaced by an RPC to the translator.  */
> +          if (name)
> +            /* TRANSLATORS: we expect to get something like
> +               /hurd/foobar --option1 --option2=baz /dev/something
> +             */
> +            grub_util_error (_("Translator `%s' for path `%s' has several "
> +                               "non-option words, at least `%s' and `%s'"),
> +                               &argz[0], path, name, &argz[i]);
> +          name = &argz[i];
ditto
> +        }
> +    }
> +
> +  if (!name)
> +    /* TRANSLATORS: we expect to get something like
> +       /hurd/foobar --option1 --option2=baz /dev/something
> +     */
> +    grub_util_error (_("Translator `%s' for path `%s' is given only options, "
> +                       "cannot find device part"), &argz[0], path);
> +
> +  if (!strncmp (name, "device:", strlen ("device:")))
Please use explicit == 0 and use sizeof ("...")-1 instead of strlen on
const string.
> +    {
> +      char *dev_name = name + strlen ("device:");
> +      size_t size = strlen ("/dev/") + strlen (dev_name) + 1;
> +      ret = malloc (size);
> +      snprintf (ret, size, "/dev/%s", dev_name);
stpcpy is more appropriate than snprintf here.

> +    }
> +  else if (!strncmp (name, "file:", strlen ("file:")))
> +    ret = strdup (name + strlen ("file:"));
> +  else
> +    ret = strdup (name);
> +
> +  munmap (argz, argz_len);
> +  return ret;


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

  reply	other threads:[~2012-04-27 18:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 18:24 [PATCH,HURD] Fix grub-probe with userland partition support Samuel Thibault
2012-04-23  8:52 ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-23  9:40   ` Samuel Thibault
2012-04-23 10:45     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-23 11:06       ` Samuel Thibault
2012-04-23 11:17         ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-23 21:26           ` Samuel Thibault
2012-04-23 23:34             ` Samuel Thibault
2012-04-24  8:55               ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24  9:00                 ` Samuel Thibault
2012-04-24  9:12                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24  9:16                     ` Samuel Thibault
2012-04-24  9:26                       ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24  9:36                         ` Samuel Thibault
2012-04-24  9:38                           ` Samuel Thibault
2012-04-24  9:44                             ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24  9:49                               ` Samuel Thibault
2012-04-24  9:04               ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24  9:19                 ` Samuel Thibault
2012-04-24  9:55                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24 12:42                     ` Samuel Thibault
2012-04-24 13:19                       ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24 17:13                         ` Samuel Thibault
2012-04-24 20:14                           ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24 22:21                             ` Samuel Thibault
2012-04-24 22:31                               ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24 22:39                                 ` Samuel Thibault
2012-04-24 22:46                                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-24 23:52                                 ` Samuel Thibault
2012-04-24 23:57                                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-25  0:27                                     ` Samuel Thibault
2012-04-25  8:36                                       ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-25  9:37                                         ` Samuel Thibault
2012-04-27 18:45                                           ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2012-04-30 18:58                                             ` Samuel Thibault
2012-05-01 13:12                                               ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-05-03 21:42                                               ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-04-23  9:07 ` Vladimir 'φ-coder/phcoder' Serbinenko

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=4F9AE957.1050209@gmail.com \
    --to=phcoder@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 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.