From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1abC91-0003DR-Lb for mharc-grub-devel@gnu.org; Wed, 02 Mar 2016 14:09:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abC8v-000395-K0 for grub-devel@gnu.org; Wed, 02 Mar 2016 14:09:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1abC8q-0003WQ-G9 for grub-devel@gnu.org; Wed, 02 Mar 2016 14:09:05 -0500 Received: from mail-lb0-x22d.google.com ([2a00:1450:4010:c04::22d]:36566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1abC8q-0003WM-2v for grub-devel@gnu.org; Wed, 02 Mar 2016 14:09:00 -0500 Received: by mail-lb0-x22d.google.com with SMTP id x1so123814911lbj.3 for ; Wed, 02 Mar 2016 11:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=5dGEmbmPHhrI6cFjklJLVLy7jSXscDRAVTr7/tuLgwo=; b=G3NHxbAY86L9JbkHMz13IrPFXRQ/fIa5wQ6IbhyR3Ydh/LCmPjfQQuJ2dsII5J+Wv0 s67+VnkxxOgxv63ZKZuvq25dLTlJIuTXXVngELnjGeKHxPaIK/dHdF6V7Muoa+a+lTFB h/EVHbCK6HBPIpxC7Gmd/QFGSQWOaA5/C5eemDO2zbNILctA9q0xcTNkdCIJJVRAbXy3 +Mu/9xnoDI246T7FxQFhvuSl13iivKz1QlaX5nUt85Pi4C5NUagNOaFYGkH7VhiKd0CA EBMCEV01ntejU21UJ6JsIHzMAnvhQKMijHiyogrk3OnY7TnlsqMYic7vuggxDAku4TGj sQ6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5dGEmbmPHhrI6cFjklJLVLy7jSXscDRAVTr7/tuLgwo=; b=PHVwQgk4+kBKjaF1Zv73ZdnJrDbJcRip40/5y2z5eNDCtptoh/XVwQzFTD9G/ehWLz OCnTR0by51KW7LPcDc7u4z3vyI+9maYfQ2xxrOeBJl53PSNJcEF8pVW9GKk/mTM0LD+j G8bniFPzLw6TD08JK3BIB+MwGN+GZS/ShuLtpnmqfZLyBdvj4RQrkt8O5nST4VwGJTyI W5Ndps7gOd73usFVeYKekfRoxHNC8BW1fGfGr2omI4P7+NHTR3Zu3XJayL5rtWrM1ILF tEy8x69EI1PuOZc3tRdEd3fcVIreE3eKL0Ht5dENwN7E/sfsYWgusWZtbbUwSyma2eyR UDCw== X-Gm-Message-State: AD7BkJLfPUCeK0qX8JCnqwOGyhG37+FLzD3L35Dsi80h6AiHN3qJqKsd9dczjSNqeTvP/w== X-Received: by 10.112.143.68 with SMTP id sc4mr10573897lbb.122.1456945739372; Wed, 02 Mar 2016 11:08:59 -0800 (PST) Received: from [192.168.1.41] (ppp109-252-76-159.pppoe.spdop.ru. [109.252.76.159]) by smtp.gmail.com with ESMTPSA id k65sm5855302lfe.41.2016.03.02.11.08.57 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 02 Mar 2016 11:08:58 -0800 (PST) Subject: Re: [PATCH v5 2/2] Add a module for retrieving SMBIOS information To: The development of GNU GRUB References: <87y4af9ox0.fsf@gmail.com> From: Andrei Borzenkov X-Enigmail-Draft-Status: N1110 Message-ID: <56D73A44.6010602@gmail.com> Date: Wed, 2 Mar 2016 22:08:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <87y4af9ox0.fsf@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::22d Cc: phcoder@gmail.com X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2016 19:09:10 -0000 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 . > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +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?