Skip to content

Commit

Permalink
[settings] Remove now-unused fetchf_named_setting() and storef_named_…
Browse files Browse the repository at this point in the history
…setting()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 22, 2013
1 parent 652abb6 commit bd6c3a1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 121 deletions.
114 changes: 0 additions & 114 deletions src/core/settings.c
Expand Up @@ -1316,120 +1316,6 @@ int setting_name ( struct settings *settings, struct setting *setting,
setting->name, setting->type->name );
}

/**
* Parse and store value of named setting
*
* @v name Name of setting
* @v default_type Default type to use, if none specified
* @v value Formatted setting data, or NULL
* @ret rc Return status code
*/
int storef_named_setting ( const char *name, struct setting_type *default_type,
const char *value ) {
struct settings *settings;
struct setting setting;
char tmp_name[ strlen ( name ) + 1 ];
int rc;

/* Create modifiable copy of setting name */
strcpy ( tmp_name, name );

/* Parse setting name */
if ( ( rc = parse_setting_name ( tmp_name, autovivify_child_settings,
&settings, &setting ) ) != 0 )
return rc;

/* Apply default type if necessary */
if ( ! setting.type )
setting.type = default_type;

/* Store setting */
if ( ( rc = storef_setting ( settings, &setting, value ) ) != 0 )
return rc;

return 0;
}

/**
* Fetch and format value of named setting
*
* @v name Name of setting
* @v name_buf Buffer to contain canonicalised name
* @v name_len Length of canonicalised name buffer
* @v value_buf Buffer to contain formatted value
* @v value_len Length of formatted value buffer
* @ret len Length of formatted value, or negative error
*/
int fetchf_named_setting ( const char *name,
char *name_buf, size_t name_len,
char *value_buf, size_t value_len ) {
struct settings *settings;
struct setting setting;
struct settings *origin;
char tmp_name[ strlen ( name ) + 1 ];
int len;
int rc;

/* Create modifiable copy of setting name */
strcpy ( tmp_name, name );

/* Parse setting name */
if ( ( rc = parse_setting_name ( tmp_name, find_child_settings,
&settings, &setting ) ) != 0 )
return rc;

/* Fetch setting */
if ( ( len = fetchf_setting ( settings, &setting, value_buf,
value_len ) ) < 0 )
return len;

/* Construct setting name */
origin = fetch_setting_origin ( settings, &setting );
assert ( origin != NULL );
setting_name ( origin, &setting, name_buf, name_len );

return len;
}

/**
* Fetch and format copy of value of named setting
*
* @v name Name of setting
* @v data Buffer to allocate and fill with formatted value
* @ret len Length of formatted value, or negative error
*
* The caller is responsible for eventually freeing the allocated
* buffer.
*
* To allow the caller to distinguish between a non-existent setting
* and an error in allocating memory for the copy, this function will
* return success (and a NULL buffer pointer) for a non-existent
* setting.
*/
int fetchf_named_setting_copy ( const char *name, char **data ) {
int len;
int check_len;

/* Avoid returning uninitialised data on error */
*data = NULL;

/* Fetch formatted value length, and return success if non-existent */
len = fetchf_named_setting ( name, NULL, 0, NULL, 0 );
if ( len < 0 )
return 0;

/* Allocate buffer */
*data = malloc ( len + 1 /* NUL */ );
if ( ! *data )
return -ENOMEM;

/* Fetch formatted value */
check_len = fetchf_named_setting ( name, NULL, 0, *data,
( len + 1 /* NUL */ ) );
assert ( check_len == len );
return len;
}

/******************************************************************************
*
* Setting types
Expand Down
7 changes: 0 additions & 7 deletions src/include/ipxe/settings.h
Expand Up @@ -315,13 +315,6 @@ extern int fetchf_setting_copy ( struct settings *settings,
extern int storef_setting ( struct settings *settings,
struct setting *setting,
const char *value );
extern int storef_named_setting ( const char *name,
struct setting_type *default_type,
const char *value );
extern int fetchf_named_setting ( const char *name, char *name_buf,
size_t name_len, char *value_buf,
size_t value_len );
extern int fetchf_named_setting_copy ( const char *name, char **data );
extern char * expand_settings ( const char *string );

extern struct setting_type setting_type_string __setting_type;
Expand Down

0 comments on commit bd6c3a1

Please sign in to comment.