Browse Source

[settings] Apply settings block name in register_settings()

Pass the settings block name as a parameter to register_settings(),
rather than defining it with settings_init() (and then possibly
changing it by directly manipulating settings->name).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
67b45186a5

+ 2
- 3
src/core/nvo.c View File

204
 		struct nvo_fragment *fragments, struct refcnt *refcnt ) {
204
 		struct nvo_fragment *fragments, struct refcnt *refcnt ) {
205
 	nvo->nvs = nvs;
205
 	nvo->nvs = nvs;
206
 	nvo->fragments = fragments;
206
 	nvo->fragments = fragments;
207
-	settings_init ( &nvo->settings, &nvo_settings_operations, refcnt,
208
-			"nvo", 0 );
207
+	settings_init ( &nvo->settings, &nvo_settings_operations, refcnt, 0 );
209
 }
208
 }
210
 
209
 
211
 /**
210
 /**
250
 
249
 
251
 	/* Verify and register options */
250
 	/* Verify and register options */
252
 	nvo_init_dhcpopts ( nvo );
251
 	nvo_init_dhcpopts ( nvo );
253
-	if ( ( rc = register_settings ( &nvo->settings, parent ) ) != 0 )
252
+	if ( ( rc = register_settings ( &nvo->settings, parent, "nvo" ) ) != 0 )
254
 		goto err_register;
253
 		goto err_register;
255
 
254
 
256
 	DBGC ( nvo, "NVO %p registered\n", nvo );
255
 	DBGC ( nvo, "NVO %p registered\n", nvo );

+ 8
- 3
src/core/settings.c View File

281
 		return NULL;
281
 		return NULL;
282
 	}
282
 	}
283
 	memcpy ( new_child->name, name, sizeof ( new_child->name ) );
283
 	memcpy ( new_child->name, name, sizeof ( new_child->name ) );
284
-	generic_settings_init ( &new_child->generic, NULL, new_child->name );
284
+	generic_settings_init ( &new_child->generic, NULL );
285
 	settings = &new_child->generic.settings;
285
 	settings = &new_child->generic.settings;
286
-	register_settings ( settings, parent );
286
+	register_settings ( settings, parent, new_child->name );
287
 	return settings;
287
 	return settings;
288
 }
288
 }
289
 
289
 
422
  *
422
  *
423
  * @v settings		Settings block
423
  * @v settings		Settings block
424
  * @v parent		Parent settings block, or NULL
424
  * @v parent		Parent settings block, or NULL
425
+ * @v name		Settings block name
425
  * @ret rc		Return status code
426
  * @ret rc		Return status code
426
  */
427
  */
427
-int register_settings ( struct settings *settings, struct settings *parent ) {
428
+int register_settings ( struct settings *settings, struct settings *parent,
429
+			const char *name ) {
428
 	struct settings *old_settings;
430
 	struct settings *old_settings;
429
 
431
 
430
 	/* NULL parent => add to settings root */
432
 	/* NULL parent => add to settings root */
432
 	if ( parent == NULL )
434
 	if ( parent == NULL )
433
 		parent = &settings_root;
435
 		parent = &settings_root;
434
 
436
 
437
+	/* Apply settings block name */
438
+	settings->name = name;
439
+
435
 	/* Remove any existing settings with the same name */
440
 	/* Remove any existing settings with the same name */
436
 	if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
441
 	if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
437
 		unregister_settings ( old_settings );
442
 		unregister_settings ( old_settings );

+ 2
- 2
src/drivers/net/phantom/phantom.c View File

2061
 	assert ( phantom->port < PHN_MAX_NUM_PORTS );
2061
 	assert ( phantom->port < PHN_MAX_NUM_PORTS );
2062
 	settings_init ( &phantom->settings,
2062
 	settings_init ( &phantom->settings,
2063
 			&phantom_settings_operations,
2063
 			&phantom_settings_operations,
2064
-			&netdev->refcnt, "clp", PHN_CLP_TAG_MAGIC );
2064
+			&netdev->refcnt, PHN_CLP_TAG_MAGIC );
2065
 
2065
 
2066
 	/* Fix up PCI device */
2066
 	/* Fix up PCI device */
2067
 	adjust_pci_device ( pci );
2067
 	adjust_pci_device ( pci );
2111
 	/* Register settings blocks */
2111
 	/* Register settings blocks */
2112
 	parent_settings = netdev_settings ( netdev );
2112
 	parent_settings = netdev_settings ( netdev );
2113
 	if ( ( rc = register_settings ( &phantom->settings,
2113
 	if ( ( rc = register_settings ( &phantom->settings,
2114
-					parent_settings ) ) != 0 ) {
2114
+					parent_settings, "clp" ) ) != 0 ) {
2115
 		DBGC ( phantom, "Phantom %p could not register settings: "
2115
 		DBGC ( phantom, "Phantom %p could not register settings: "
2116
 		       "%s\n", phantom, strerror ( rc ) );
2116
 		       "%s\n", phantom, strerror ( rc ) );
2117
 		goto err_register_settings;
2117
 		goto err_register_settings;

+ 1
- 2
src/include/ipxe/netdevice.h View File

489
  */
489
  */
490
 static inline __attribute__ (( always_inline )) void
490
 static inline __attribute__ (( always_inline )) void
491
 netdev_settings_init ( struct net_device *netdev ) {
491
 netdev_settings_init ( struct net_device *netdev ) {
492
-	generic_settings_init ( &netdev->settings,
493
-				&netdev->refcnt, netdev->name );
492
+	generic_settings_init ( &netdev->settings, &netdev->refcnt );
494
 	netdev->settings.settings.op = &netdev_settings_operations;
493
 	netdev->settings.settings.op = &netdev_settings_operations;
495
 }
494
 }
496
 
495
 

+ 3
- 8
src/include/ipxe/settings.h View File

178
 extern void generic_settings_clear ( struct settings *settings );
178
 extern void generic_settings_clear ( struct settings *settings );
179
 
179
 
180
 extern int register_settings ( struct settings *settings,
180
 extern int register_settings ( struct settings *settings,
181
-			       struct settings *parent );
181
+			       struct settings *parent, const char *name );
182
 extern void unregister_settings ( struct settings *settings );
182
 extern void unregister_settings ( struct settings *settings );
183
 
183
 
184
 extern int store_setting ( struct settings *settings, struct setting *setting,
184
 extern int store_setting ( struct settings *settings, struct setting *setting,
252
  * @v settings		Settings block
252
  * @v settings		Settings block
253
  * @v op		Settings block operations
253
  * @v op		Settings block operations
254
  * @v refcnt		Containing object reference counter, or NULL
254
  * @v refcnt		Containing object reference counter, or NULL
255
- * @v name		Settings block name
256
  * @v tag_magic		Tag magic
255
  * @v tag_magic		Tag magic
257
  */
256
  */
258
 static inline void settings_init ( struct settings *settings,
257
 static inline void settings_init ( struct settings *settings,
259
 				   struct settings_operations *op,
258
 				   struct settings_operations *op,
260
 				   struct refcnt *refcnt,
259
 				   struct refcnt *refcnt,
261
-				   const char *name,
262
 				   unsigned int tag_magic ) {
260
 				   unsigned int tag_magic ) {
263
 	INIT_LIST_HEAD ( &settings->siblings );
261
 	INIT_LIST_HEAD ( &settings->siblings );
264
 	INIT_LIST_HEAD ( &settings->children );
262
 	INIT_LIST_HEAD ( &settings->children );
265
 	settings->op = op;
263
 	settings->op = op;
266
 	settings->refcnt = refcnt;
264
 	settings->refcnt = refcnt;
267
-	settings->name = name;
268
 	settings->tag_magic = tag_magic;
265
 	settings->tag_magic = tag_magic;
269
 }
266
 }
270
 
267
 
273
  *
270
  *
274
  * @v generics		Generic settings block
271
  * @v generics		Generic settings block
275
  * @v refcnt		Containing object reference counter, or NULL
272
  * @v refcnt		Containing object reference counter, or NULL
276
- * @v name		Settings block name
277
  */
273
  */
278
 static inline void generic_settings_init ( struct generic_settings *generics,
274
 static inline void generic_settings_init ( struct generic_settings *generics,
279
-					   struct refcnt *refcnt,
280
-					   const char *name ) {
275
+					   struct refcnt *refcnt ) {
281
 	settings_init ( &generics->settings, &generic_settings_operations,
276
 	settings_init ( &generics->settings, &generic_settings_operations,
282
-			refcnt, name, 0 );
277
+			refcnt, 0 );
283
 	INIT_LIST_HEAD ( &generics->list );
278
 	INIT_LIST_HEAD ( &generics->list );
284
 }
279
 }
285
 
280
 

+ 2
- 2
src/interface/smbios/smbios_settings.c View File

125
 /** SMBIOS settings */
125
 /** SMBIOS settings */
126
 static struct settings smbios_settings = {
126
 static struct settings smbios_settings = {
127
 	.refcnt = NULL,
127
 	.refcnt = NULL,
128
-	.name = "smbios",
129
 	.tag_magic = SMBIOS_EMPTY_TAG,
128
 	.tag_magic = SMBIOS_EMPTY_TAG,
130
 	.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
129
 	.siblings = LIST_HEAD_INIT ( smbios_settings.siblings ),
131
 	.children = LIST_HEAD_INIT ( smbios_settings.children ),
130
 	.children = LIST_HEAD_INIT ( smbios_settings.children ),
136
 static void smbios_init ( void ) {
135
 static void smbios_init ( void ) {
137
 	int rc;
136
 	int rc;
138
 
137
 
139
-	if ( ( rc = register_settings ( &smbios_settings, NULL ) ) != 0 ) {
138
+	if ( ( rc = register_settings ( &smbios_settings, NULL,
139
+					"smbios" ) ) != 0 ) {
140
 		DBG ( "SMBIOS could not register settings: %s\n",
140
 		DBG ( "SMBIOS could not register settings: %s\n",
141
 		      strerror ( rc ) );
141
 		      strerror ( rc ) );
142
 		return;
142
 		return;

+ 2
- 1
src/net/cachedhcp.c View File

66
 	 * device, which is usually what we want.
66
 	 * device, which is usually what we want.
67
 	 */
67
 	 */
68
 	parent = netdev_settings ( last_opened_netdev() );
68
 	parent = netdev_settings ( last_opened_netdev() );
69
-	if ( ( rc = register_settings ( &dhcppkt->settings, parent ) ) != 0 )
69
+	if ( ( rc = register_settings ( &dhcppkt->settings, parent,
70
+					DHCP_SETTINGS_NAME ) ) != 0 )
70
 		DBG ( "DHCP could not register cached settings: %s\n",
71
 		DBG ( "DHCP could not register cached settings: %s\n",
71
 		      strerror ( rc ) );
72
 		      strerror ( rc ) );
72
 
73
 

+ 1
- 2
src/net/dhcppkt.c View File

279
 	dhcppkt->len = ( offsetof ( struct dhcphdr, options ) +
279
 	dhcppkt->len = ( offsetof ( struct dhcphdr, options ) +
280
 			 dhcppkt->options.len );
280
 			 dhcppkt->options.len );
281
 	settings_init ( &dhcppkt->settings,
281
 	settings_init ( &dhcppkt->settings,
282
-			&dhcppkt_settings_operations, &dhcppkt->refcnt,
283
-			DHCP_SETTINGS_NAME, 0 );
282
+			&dhcppkt_settings_operations, &dhcppkt->refcnt, 0 );
284
 }
283
 }

+ 1
- 1
src/net/netdevice.c View File

422
 
422
 
423
 	/* Register per-netdev configuration settings */
423
 	/* Register per-netdev configuration settings */
424
 	if ( ( rc = register_settings ( netdev_settings ( netdev ),
424
 	if ( ( rc = register_settings ( netdev_settings ( netdev ),
425
-					NULL ) ) != 0 ) {
425
+					NULL, netdev->name ) ) != 0 ) {
426
 		DBGC ( netdev, "NETDEV %s could not register settings: %s\n",
426
 		DBGC ( netdev, "NETDEV %s could not register settings: %s\n",
427
 		       netdev->name, strerror ( rc ) );
427
 		       netdev->name, strerror ( rc ) );
428
 		goto err_register_settings;
428
 		goto err_register_settings;

+ 8
- 8
src/net/udp/dhcp.c View File

553
 	/* Register settings */
553
 	/* Register settings */
554
 	parent = netdev_settings ( dhcp->netdev );
554
 	parent = netdev_settings ( dhcp->netdev );
555
 	settings = &dhcppkt->settings;
555
 	settings = &dhcppkt->settings;
556
-	if ( ( rc = register_settings ( settings, parent ) ) != 0 ) {
556
+	if ( ( rc = register_settings ( settings, parent,
557
+					DHCP_SETTINGS_NAME ) ) != 0 ) {
557
 		DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
558
 		DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
558
 		       dhcp, strerror ( rc ) );
559
 		       dhcp, strerror ( rc ) );
559
 		dhcp_finished ( dhcp, rc );
560
 		dhcp_finished ( dhcp, rc );
568
 			 * without performing a ProxyDHCPREQUEST
569
 			 * without performing a ProxyDHCPREQUEST
569
 			 */
570
 			 */
570
 			settings = &dhcp->proxy_offer->settings;
571
 			settings = &dhcp->proxy_offer->settings;
571
-			settings->name = PROXYDHCP_SETTINGS_NAME;
572
-			if ( ( rc = register_settings ( settings,
573
-							NULL ) ) != 0 ) {
572
+			if ( ( rc = register_settings ( settings, NULL,
573
+					   PROXYDHCP_SETTINGS_NAME ) ) != 0 ) {
574
 				DBGC ( dhcp, "DHCP %p could not register "
574
 				DBGC ( dhcp, "DHCP %p could not register "
575
 				       "proxy settings: %s\n",
575
 				       "proxy settings: %s\n",
576
 				       dhcp, strerror ( rc ) );
576
 				       dhcp, strerror ( rc ) );
670
 		return;
670
 		return;
671
 
671
 
672
 	/* Register settings */
672
 	/* Register settings */
673
-	settings->name = PROXYDHCP_SETTINGS_NAME;
674
-	if ( ( rc = register_settings ( settings, NULL ) ) != 0 ) {
673
+	if ( ( rc = register_settings ( settings, NULL,
674
+					PROXYDHCP_SETTINGS_NAME ) ) != 0 ) {
675
 		DBGC ( dhcp, "DHCP %p could not register proxy settings: %s\n",
675
 		DBGC ( dhcp, "DHCP %p could not register proxy settings: %s\n",
676
 		       dhcp, strerror ( rc ) );
676
 		       dhcp, strerror ( rc ) );
677
 		dhcp_finished ( dhcp, rc );
677
 		dhcp_finished ( dhcp, rc );
809
 		return;
809
 		return;
810
 
810
 
811
 	/* Register settings */
811
 	/* Register settings */
812
-	dhcppkt->settings.name = PXEBS_SETTINGS_NAME;
813
-	if ( ( rc = register_settings ( &dhcppkt->settings, NULL ) ) != 0 ) {
812
+	if ( ( rc = register_settings ( &dhcppkt->settings, NULL,
813
+					PXEBS_SETTINGS_NAME ) ) != 0 ) {
814
 		DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
814
 		DBGC ( dhcp, "DHCP %p could not register settings: %s\n",
815
 		       dhcp, strerror ( rc ) );
815
 		       dhcp, strerror ( rc ) );
816
 		dhcp_finished ( dhcp, rc );
816
 		dhcp_finished ( dhcp, rc );

Loading…
Cancel
Save