summaryrefslogtreecommitdiffstats
path: root/src/hci/commands
diff options
context:
space:
mode:
authorMichael Brown2013-12-03 17:48:56 +0100
committerMichael Brown2013-12-05 01:37:02 +0100
commit22001cb206c1320aee27f679a63d2171d35e99c5 (patch)
treea972bb914371a68d4925dcc007238dcb836546ba /src/hci/commands
parent[fbcon] Add support for displaying a cursor (diff)
downloadipxe-22001cb206c1320aee27f679a63d2171d35e99c5.tar.gz
ipxe-22001cb206c1320aee27f679a63d2171d35e99c5.tar.xz
ipxe-22001cb206c1320aee27f679a63d2171d35e99c5.zip
[settings] Explicitly separate the concept of a completed fetched setting
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>
Diffstat (limited to 'src/hci/commands')
-rw-r--r--src/hci/commands/nvo_cmd.c23
-rw-r--r--src/hci/commands/pci_cmd.c4
2 files changed, 13 insertions, 14 deletions
diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c
index 3fd684d0..e63dab08 100644
--- a/src/hci/commands/nvo_cmd.c
+++ b/src/hci/commands/nvo_cmd.c
@@ -58,8 +58,10 @@ static int show_exec ( int argc, char **argv ) {
struct show_options opts;
struct named_setting setting;
struct settings *origin;
+ struct setting fetched;
char name_buf[32];
char *value;
+ int len;
int rc;
/* Parse options */
@@ -71,19 +73,16 @@ static int show_exec ( int argc, char **argv ) {
goto err_parse_setting;
/* Fetch formatted setting value */
- if ( ( rc = fetchf_setting_copy ( setting.settings, &setting.setting,
- &value ) ) < 0 ) {
+ if ( ( len = fetchf_setting_copy ( setting.settings, &setting.setting,
+ &origin, &fetched, &value ) ) < 0 ) {
+ rc = len;
printf ( "Could not find \"%s\": %s\n",
setting.setting.name, strerror ( rc ) );
goto err_fetchf;
}
- /* Fetch origin and format fully-qualified name */
- origin = fetch_setting_origin ( setting.settings, &setting.setting );
- assert ( origin != NULL );
- setting_name ( origin, &setting.setting, name_buf, sizeof ( name_buf ));
-
/* Print setting value */
+ setting_name ( origin, &fetched, name_buf, sizeof ( name_buf ) );
printf ( "%s = %s\n", name_buf, value );
/* Success */
@@ -234,7 +233,8 @@ static int read_value ( struct named_setting *setting, char **args __unused,
/* Read existing value, treating errors as equivalent to an
* empty initial setting.
*/
- fetchf_setting_copy ( setting->settings, &setting->setting, &existing );
+ fetchf_setting_copy ( setting->settings, &setting->setting,
+ NULL, &setting->setting, &existing );
/* Read new value */
if ( ( rc = readline_history ( NULL, existing, NULL, value ) ) != 0 )
@@ -294,12 +294,11 @@ static int inc_exec ( int argc, char **argv ) {
( ( rc = parse_integer ( argv[ optind + 1 ], &increment ) ) != 0))
goto err_parse_increment;
- /* Fetch existing setting value, if any, allowing for the fact
- * that numeric settings are big-endian and variable-length.
+ /* Read existing value, treating errors as equivalent to a
+ * zero-valued :int32 initial setting.
*/
if ( ( rc = fetchn_setting ( setting.settings, &setting.setting,
- &value ) ) != 0 ) {
- /* Treat as a non-existent :int32 setting with a zero value */
+ NULL, &setting.setting, &value ) ) != 0 ) {
value = 0;
if ( ! setting.setting.type )
setting.setting.type = &setting_type_int32;
diff --git a/src/hci/commands/pci_cmd.c b/src/hci/commands/pci_cmd.c
index f2d69569..f5145fb3 100644
--- a/src/hci/commands/pci_cmd.c
+++ b/src/hci/commands/pci_cmd.c
@@ -68,8 +68,8 @@ static int pciscan_exec ( int argc, char **argv ) {
goto err_parse_setting;
/* Determine starting bus:dev.fn address */
- if ( ( len = fetch_uint_setting ( setting.settings, &setting.setting,
- &prev ) ) < 0 ) {
+ if ( ( len = fetchn_setting ( setting.settings, &setting.setting,
+ NULL, &setting.setting, &prev ) ) < 0 ) {
/* Setting not yet defined: start searching from 00:00.0 */
prev = 0;
} else {