grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Allow nonstandard ports when specifying network protocols. (


From: Vladimir 'φ-coder/phcoder' Serbinenko
Subject: Re: [PATCH] Allow nonstandard ports when specifying network protocols. (take 2)
Date: Thu, 22 Jan 2015 20:31:53 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0

> @@ -545,6 +545,7 @@ http_packets_pulled (struct grub_file *file)
>  static struct grub_net_app_protocol grub_http_protocol =
>    {
>      .name = "http",
> +    .port = HTTP_PORT,
Wrong. This way you'll modify the default port for subsequent calls.
Port should be passed as an additional argument to open. Use int and
value -1 to indicate that no port is specified and change code to
replace it by right port. Don't use 0 as 0 is a valid port.
> +  char *protname, *server;
> +  const char *work, *comma;
> +  grub_uint16_t port;
> +  grub_net_t ret;
> +  port = 0;
> +  work = name;
> +  server = NULL;
> +  protname = NULL;
> +  ret = NULL;
> +
> +  /* Pick off the protocol first. */
> +  comma = grub_strchr (work, ':');
> +  if (!comma)
> +    comma = grub_strchr (work, ',');
This makes colon equivalent to comma. We don't want another separator.
"pxe:" is for compatibility. Leave it at that, don't add new functions
to it.
> +  if (!comma)
>      {
> -      protname = "tftp";
> -      protnamelen = sizeof ("tftp") - 1;
> -      server = grub_net_default_server;
> +      protname = grub_strdup(work);
> +      server = grub_strdup(grub_net_default_server);
>      }
>    else
>      {
> -      const char *comma;
> -      comma = grub_strchr (name, ',');
> -      if (comma)
> - {
> -  protnamelen = comma - name;
> -  server = comma + 1;
> -  protname = name;
> - }
Please follow whitespace conventions (although it's minor concern).
> +  if (!grub_dl_load(protname))
> +    {
> +      grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
> +                  name);
> +      goto out;
> +    }
Please don't jumble unrelated changes. This has nothing to do with
parser changes.
The change you intend to make should be more like 20 lines of modified
code, probably even less, not a jumbled case of many unrelated changes.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]