Kaynağa Gözat

[settings] Eliminate call to store_named_setting() in nslookup.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 yıl önce
ebeveyn
işleme
44fd309044
1 değiştirilmiş dosya ile 17 ekleme ve 6 silme
  1. 17
    6
      src/usr/nslookup.c

+ 17
- 6
src/usr/nslookup.c Dosyayı Görüntüle

@@ -46,7 +46,7 @@ struct nslookup {
46 46
 	struct interface resolver;
47 47
 
48 48
 	/** Setting name */
49
-	const char *setting_name;
49
+	char *setting_name;
50 50
 };
51 51
 
52 52
 /**
@@ -71,7 +71,9 @@ static void nslookup_close ( struct nslookup *nslookup, int rc ) {
71 71
 static void nslookup_resolv_done ( struct nslookup *nslookup,
72 72
 				   struct sockaddr *sa ) {
73 73
 	struct sockaddr_in *sin;
74
-	struct setting_type *type;
74
+	struct setting_type *default_type;
75
+	struct settings *settings;
76
+	struct setting setting;
75 77
 	void *data;
76 78
 	size_t len;
77 79
 	int rc;
@@ -82,16 +84,25 @@ static void nslookup_resolv_done ( struct nslookup *nslookup,
82 84
 		sin = ( ( struct sockaddr_in * ) sa );
83 85
 		data = &sin->sin_addr;
84 86
 		len = sizeof ( sin->sin_addr );
85
-		type = &setting_type_ipv4;
87
+		default_type = &setting_type_ipv4;
86 88
 		break;
87 89
 	default:
88 90
 		rc = -ENOTSUP;
89 91
 		goto err;
90 92
 	}
91 93
 
92
-	/* Save in specified setting */
93
-	if ( ( rc = store_named_setting ( nslookup->setting_name, type,
94
-					  data, len ) ) != 0 )
94
+	/* Parse specified setting name */
95
+	if ( ( rc = parse_setting_name ( nslookup->setting_name,
96
+					 autovivify_child_settings, &settings,
97
+					 &setting ) ) != 0 )
98
+		goto err;
99
+
100
+	/* Apply default type if necessary */
101
+	if ( ! setting.type )
102
+		setting.type = default_type;
103
+
104
+	/* Store in specified setting */
105
+	if ( ( rc = store_setting ( settings, &setting, data, len ) ) != 0 )
95 106
 		goto err;
96 107
 
97 108
  err:

Loading…
İptal
Kaydet