]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Eliminate call to store_named_setting() in nslookup.c
authorMichael Brown <mcb30@ipxe.org>
Thu, 18 Jul 2013 13:49:06 +0000 (14:49 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 19 Jul 2013 14:29:23 +0000 (15:29 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/usr/nslookup.c

index c931ec5a1e31d7c323265f5854f2f1c5d0acfe95..cb6d8d2b1b9c9b7654430d1baa3f9270298f568b 100644 (file)
@@ -46,7 +46,7 @@ struct nslookup {
        struct interface resolver;
 
        /** Setting name */
-       const char *setting_name;
+       char *setting_name;
 };
 
 /**
@@ -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;
@@ -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: