Skip to content

Commit

Permalink
[settings] Explicitly separate the concept of a completed fetched set…
Browse files Browse the repository at this point in the history
…ting

The fetch_setting() family of functions may currently modify the
definition of the specified setting (e.g. to add missing type
information).  Clean up this interface by requiring callers to provide
an explicit buffer to contain the completed definition of the fetched
setting, if required.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Dec 5, 2013
1 parent a2638a8 commit 22001cb
Show file tree
Hide file tree
Showing 37 changed files with 610 additions and 563 deletions.
2 changes: 1 addition & 1 deletion src/arch/i386/interface/vmware/guestinfo.c
Expand Up @@ -51,7 +51,7 @@ static int guestinfo_channel;
*/
static int guestinfo_fetch_type ( struct settings *settings,
struct setting *setting,
struct setting_type *type,
const struct setting_type *type,
void *data, size_t len, int *found ) {
const char *parent_name = settings->parent->name;
char command[ 24 /* "info-get guestinfo.ipxe." */ +
Expand Down
6 changes: 3 additions & 3 deletions src/arch/x86/core/cpuid_settings.c
Expand Up @@ -117,7 +117,7 @@ enum cpuid_registers {
#define CPUID_NUM_REGISTERS( tag ) ( ( ( (tag) >> 16 ) & 0x3 ) + 1 )

/** CPUID settings scope */
static struct settings_scope cpuid_settings_scope;
static const struct settings_scope cpuid_settings_scope;

/**
* Check applicability of CPUID setting
Expand All @@ -127,7 +127,7 @@ static struct settings_scope cpuid_settings_scope;
* @ret applies Setting applies within this settings block
*/
static int cpuid_settings_applies ( struct settings *settings __unused,
struct setting *setting ) {
const struct setting *setting ) {

return ( setting->scope == &cpuid_settings_scope );
}
Expand Down Expand Up @@ -252,7 +252,7 @@ struct init_fn cpuid_settings_init_fn __init_fn ( INIT_NORMAL ) = {
};

/** CPUID predefined settings */
struct setting cpuid_predefined_settings[] __setting ( SETTING_HOST_EXTRA ) = {
const struct setting cpuid_predefined_settings[] __setting ( SETTING_HOST_EXTRA ) = {
{
.name = "cpuvendor",
.description = "CPU vendor",
Expand Down
6 changes: 3 additions & 3 deletions src/core/memmap_settings.c
Expand Up @@ -108,7 +108,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define MEMMAP_SCALE( tag ) ( (tag) & 0x3f )

/** Memory map settings scope */
static struct settings_scope memmap_settings_scope;
static const struct settings_scope memmap_settings_scope;

/**
* Check applicability of memory map setting
Expand All @@ -118,7 +118,7 @@ static struct settings_scope memmap_settings_scope;
* @ret applies Setting applies within this settings block
*/
static int memmap_settings_applies ( struct settings *settings __unused,
struct setting *setting ) {
const struct setting *setting ) {

return ( setting->scope == &memmap_settings_scope );
}
Expand Down Expand Up @@ -231,7 +231,7 @@ struct init_fn memmap_settings_init_fn __init_fn ( INIT_NORMAL ) = {
};

/** Memory map predefined settings */
struct setting memmap_predefined_settings[] __setting ( SETTING_MISC ) = {
const struct setting memmap_predefined_settings[] __setting ( SETTING_MISC ) = {
{
.name = "memsize",
.description = "Memory size (in MB)",
Expand Down
4 changes: 2 additions & 2 deletions src/core/nvo.c
Expand Up @@ -193,7 +193,7 @@ static int nvo_save ( struct nvo_block *nvo ) {
* @ret applies Setting applies within this settings block
*/
int nvo_applies ( struct settings *settings __unused,
struct setting *setting ) {
const struct setting *setting ) {

return ( ( setting->scope == NULL ) &&
dhcpopt_applies ( setting->tag ) );
Expand All @@ -208,7 +208,7 @@ int nvo_applies ( struct settings *settings __unused,
* @v len Length of setting data
* @ret rc Return status code
*/
static int nvo_store ( struct settings *settings, struct setting *setting,
static int nvo_store ( struct settings *settings, const struct setting *setting,
const void *data, size_t len ) {
struct nvo_block *nvo =
container_of ( settings, struct nvo_block, settings );
Expand Down

0 comments on commit 22001cb

Please sign in to comment.