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] Allow nonstandard ports when specifying network protocols. (take 2)
Date: Thu, 22 Jan 2015 20:31:53 +0100	[thread overview]
Message-ID: <54C15029.6070803@gmail.com> (raw)
In-Reply-To: <CAMy6mN+-igzBO2t7cLob2VyqBJyZu+FGQPDBsGcE3MGTQT+OnQ@mail.gmail.com>

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


> @@ -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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

      parent reply	other threads:[~2015-01-22 19:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-13  2:00 [PATCH] Allow nonstandard ports when specifying network protocols. (take 2) Victor Lowther
2014-12-19 10:13 ` Andrei Borzenkov
2015-01-22 19:31 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]

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=54C15029.6070803@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.