SMBIOS: Use macro to set smbios defaults
The function smbios_set_defaults() uses a repeating code pattern for each field. This patch replaces that pattern with a macro. This patch contains no functional changes. Signed-off-by: Gabriel Somlo <somlo@cmu.edu> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
e41fca3da7
commit
cb36acb672
@ -260,20 +260,6 @@ static void smbios_build_type_1_fields(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void smbios_set_defaults(const char *manufacturer, const char *product,
|
|
||||||
const char *version)
|
|
||||||
{
|
|
||||||
if (!type1.manufacturer) {
|
|
||||||
type1.manufacturer = manufacturer;
|
|
||||||
}
|
|
||||||
if (!type1.product) {
|
|
||||||
type1.product = product;
|
|
||||||
}
|
|
||||||
if (!type1.version) {
|
|
||||||
type1.version = version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *smbios_get_table_legacy(size_t *length)
|
uint8_t *smbios_get_table_legacy(size_t *length)
|
||||||
{
|
{
|
||||||
if (!smbios_immutable) {
|
if (!smbios_immutable) {
|
||||||
@ -288,6 +274,19 @@ uint8_t *smbios_get_table_legacy(size_t *length)
|
|||||||
/* end: legacy setup functions for <= 2.0 machines */
|
/* end: legacy setup functions for <= 2.0 machines */
|
||||||
|
|
||||||
|
|
||||||
|
#define SMBIOS_SET_DEFAULT(field, value) \
|
||||||
|
if (!field) { \
|
||||||
|
field = value; \
|
||||||
|
}
|
||||||
|
|
||||||
|
void smbios_set_defaults(const char *manufacturer, const char *product,
|
||||||
|
const char *version)
|
||||||
|
{
|
||||||
|
SMBIOS_SET_DEFAULT(type1.manufacturer, manufacturer);
|
||||||
|
SMBIOS_SET_DEFAULT(type1.product, product);
|
||||||
|
SMBIOS_SET_DEFAULT(type1.version, version);
|
||||||
|
}
|
||||||
|
|
||||||
static void save_opt(const char **dest, QemuOpts *opts, const char *name)
|
static void save_opt(const char **dest, QemuOpts *opts, const char *name)
|
||||||
{
|
{
|
||||||
const char *val = qemu_opt_get(opts, name);
|
const char *val = qemu_opt_get(opts, name);
|
||||||
|
Loading…
Reference in New Issue
Block a user