From: Andrei Borzenkov <arvidjaar@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: phcoder@gmail.com
Subject: Re: [PATCH v5 2/2] Add a module for retrieving SMBIOS information
Date: Wed, 2 Mar 2016 22:08:52 +0300 [thread overview]
Message-ID: <56D73A44.6010602@gmail.com> (raw)
In-Reply-To: <87y4af9ox0.fsf@gmail.com>
Two nitpicks otherwise looks good. Thanks!
20.02.2016 22:12, David Michael пишет:
...
> diff --git a/grub-core/commands/smbios.c b/grub-core/commands/smbios.c
> new file mode 100644
> index 0000000..80a01a3
> --- /dev/null
> +++ b/grub-core/commands/smbios.c
> @@ -0,0 +1,364 @@
> +/* smbios.c - retrieve smbios information. */
> +/*
> + * GRUB -- GRand Unified Bootloader
> + * Copyright (C) 2016 Free Software Foundation, Inc.
> + *
> + * GRUB is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 3 of the License, or
> + * (at your option) any later version.
> + *
> + * GRUB is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <grub/dl.h>
> +#include <grub/env.h>
> +#include <grub/extcmd.h>
> +#include <grub/i18n.h>
> +#include <grub/misc.h>
> +#include <grub/mm.h>
> +#include <grub/smbios.h>
> +
> +GRUB_MOD_LICENSE ("GPLv3+");
> +
> +
> +/* Locate the SMBIOS entry point structure depending on the hardware. */
> +struct grub_smbios_eps *
> +grub_smbios_get_eps (void)
> +{
> + static struct grub_smbios_eps *eps = NULL;
> + if (eps != NULL)
> + return eps;
> + eps = grub_machine_smbios_get_eps ();
> + return eps;
> +}
> +
> +/* Locate the SMBIOS3 entry point structure depending on the hardware. */
> +struct grub_smbios_eps3 *
> +grub_smbios_get_eps3 (void)
> +{
> + static struct grub_smbios_eps3 *eps = NULL;
> + if (eps != NULL)
> + return eps;
> + eps = grub_machine_smbios_get_eps3 ();
> + return eps;
> +}
> +
> +/* Abstract useful values found in either the SMBIOS3 or SMBIOS EPS. */
> +static struct {
> + grub_addr_t start;
> + grub_addr_t end;
> + grub_uint16_t structures;
> +} table_desc = {0, 0, 0};
Static is supposed to be initialized to zero by default.
...
> +static grub_err_t
> +grub_cmd_smbios (grub_extcmd_context_t ctxt,
> + int argc __attribute__ ((unused)),
> + char **argv __attribute__ ((unused)))
> +{
> + struct grub_arg_list *state = ctxt->state;
> +
> + grub_int16_t type = -1;
> + grub_int32_t handle = -1;
> + grub_uint16_t match = 0;
> + grub_uint8_t offset = 0;
> +
> + const grub_uint8_t *structure;
> + const char *value;
> + grub_int32_t option;
> + grub_int8_t field_type = -1;
> + grub_uint8_t i;
> +
> + if (table_desc.start == 0)
> + return grub_error (GRUB_ERR_IO,
> + N_("the SMBIOS entry point structure was not found"));
> +
> + /* Read the given filtering options. */
> + if (state[0].set)
> + {
> + option = grub_strtol (state[0].arg, NULL, 0);
> + if (option < 0 || option > 255)
> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> + N_("the type must be between 0 and 255"));
> + type = (grub_int16_t)option;
> + }
> + if (state[1].set)
> + {
> + option = grub_strtol (state[1].arg, NULL, 0);
> + if (option < 0 || option > 65535)
> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> + N_("the handle must be between 0 and 65535"));
> + handle = (grub_int32_t)option;
> + }
> + if (state[2].set)
> + {
> + option = grub_strtol (state[2].arg, NULL, 0);
> + if (option <= 0)
> + return grub_error (GRUB_ERR_BAD_ARGUMENT,
> + N_("the match must be a positive integer"));
> + match = (grub_uint16_t)option;
Should we check that option <= 65535?
next prev parent reply other threads:[~2016-03-02 19:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-20 19:12 [PATCH v5 2/2] Add a module for retrieving SMBIOS information David Michael
2016-03-02 19:08 ` Andrei Borzenkov [this message]
2016-03-03 4:13 ` David Michael
2016-03-08 5:02 ` Andrei Borzenkov
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=56D73A44.6010602@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=phcoder@gmail.com \
/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.