Skip to content

Commit

Permalink
[settings] Eliminate call to store_named_setting() in nslookup.c
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 19, 2013
1 parent 129a706 commit 44fd309
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/usr/nslookup.c
Expand Up @@ -46,7 +46,7 @@ struct nslookup {
struct interface resolver;

/** Setting name */
const char *setting_name;
char *setting_name;
};

/**
Expand All @@ -71,7 +71,9 @@ static void nslookup_close ( struct nslookup *nslookup, int rc ) {
static void nslookup_resolv_done ( struct nslookup *nslookup,
struct sockaddr *sa ) {
struct sockaddr_in *sin;
struct setting_type *type;
struct setting_type *default_type;
struct settings *settings;
struct setting setting;
void *data;
size_t len;
int rc;
Expand All @@ -82,16 +84,25 @@ static void nslookup_resolv_done ( struct nslookup *nslookup,
sin = ( ( struct sockaddr_in * ) sa );
data = &sin->sin_addr;
len = sizeof ( sin->sin_addr );
type = &setting_type_ipv4;
default_type = &setting_type_ipv4;
break;
default:
rc = -ENOTSUP;
goto err;
}

/* Save in specified setting */
if ( ( rc = store_named_setting ( nslookup->setting_name, type,
data, len ) ) != 0 )
/* Parse specified setting name */
if ( ( rc = parse_setting_name ( nslookup->setting_name,
autovivify_child_settings, &settings,
&setting ) ) != 0 )
goto err;

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

/* Store in specified setting */
if ( ( rc = store_setting ( settings, &setting, data, len ) ) != 0 )
goto err;

err:
Expand Down

0 comments on commit 44fd309

Please sign in to comment.