Răsfoiți Sursa

fix fc5 segfault correctly by removing code that violates strict aliasing
rules.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@983 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 ani în urmă
părinte
comite
758719ea87
20 a modificat fișierele cu 141 adăugiri și 80 ștergeri
  1. 2 1
      Makefile.inc
  2. 2 1
      exec/aisparser.c
  3. 3 2
      exec/amf.c
  4. 9 6
      exec/cfg.c
  5. 20 11
      exec/ckpt.c
  6. 7 6
      exec/clm.c
  7. 8 8
      exec/cpg.c
  8. 9 8
      exec/evs.c
  9. 8 6
      exec/evt.c
  10. 9 6
      exec/lck.c
  11. 8 2
      exec/main.c
  12. 9 6
      exec/msg.c
  13. 3 1
      exec/objdb.c
  14. 4 1
      exec/service.c
  15. 1 0
      include/hdb.h
  16. 5 0
      lcr/lcr_comp.h
  17. 9 6
      lcr/lcr_ifact.c
  18. 4 2
      lcr/libtest_a.c
  19. 5 3
      lcr/libtest_b.c
  20. 16 4
      lcr/test.c

+ 2 - 1
Makefile.inc

@@ -55,7 +55,8 @@ DYFLAGS =
 # build CFLAGS, LDFLAGS
 #
 ifeq (${OPENAIS_BUILD}, RELEASE) 
-	CFLAGS += -O3 -Wall
+	CFLAGS += -O3 -Wall -DDEBUG
+# -Wstrict-aliasing=2 TODO sameday fix all of these
 ifndef OPENAIS_PROFILE
 	CFLAGS += -fomit-frame-pointer
 endif

+ 2 - 1
exec/aisparser.c

@@ -219,7 +219,7 @@ struct lcr_iface openais_aisparser_ver0[1] = {
 		.dependency_count		= 0,
 		.constructor			= NULL,
 		.destructor			= NULL,
-		.interfaces			= (void **)(void *)&aisparser_iface_ver0,
+		.interfaces			= NULL,
 	}
 };
 
@@ -232,6 +232,7 @@ struct lcr_comp aisparser_comp_ver0 = {
 
 
 __attribute__ ((constructor)) static void aisparser_comp_register (void) {
+        lcr_interfaces_set (&openais_aisparser_ver0[0], &aisparser_iface_ver0);
 	lcr_component_register (&aisparser_comp_ver0);
 }
 

+ 3 - 2
exec/amf.c

@@ -409,7 +409,6 @@ struct openais_service_handler amf_service_handler = {
 struct openais_service_handler *amf_get_handler_ver0 (void);
 
 struct openais_service_handler_iface_ver0 amf_service_handler_iface = {
-	.test					= NULL,
 	.openais_get_service_handler_ver0	= amf_get_handler_ver0
 };
 
@@ -423,7 +422,7 @@ struct lcr_iface openais_amf_ver0[1] = {
 		.dependency_count	= 0,
 		.constructor		= NULL,
 		.destructor		= NULL,
-		.interfaces		= (void **)(void *)&amf_service_handler_iface,
+		.interfaces		= NULL
 	}
 };
 
@@ -438,6 +437,8 @@ struct openais_service_handler *amf_get_handler_ver0 (void)
 }
 
 __attribute__ ((constructor)) static void register_this_component (void) {
+        lcr_interfaces_set (&openais_amf_ver0[0], &amf_service_handler_iface);
+
 	lcr_component_register (&amf_comp_ver0);
 }
 

+ 9 - 6
exec/cfg.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005-2006 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -148,13 +149,13 @@ struct openais_service_handler cfg_service_handler = {
 /*
  * Dynamic Loader definition
  */
-struct openais_service_handler *cfg_get_handler_ver0 (void);
+static struct openais_service_handler *cfg_get_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 cfg_service_handler_iface = {
 	.openais_get_service_handler_ver0	= cfg_get_handler_ver0
 };
 
-struct lcr_iface openais_cfg_ver0[1] = {
+static struct lcr_iface openais_cfg_ver0[1] = {
 	{
 		.name				= "openais_cfg",
 		.version			= 0,
@@ -164,21 +165,23 @@ struct lcr_iface openais_cfg_ver0[1] = {
 		.dependency_count		= 0,
 		.constructor			= NULL,
 		.destructor			= NULL,
-		.interfaces			= (void **)(void *)&cfg_service_handler_iface,
+		.interfaces			= NULL
 	}
 };
 
-struct lcr_comp cfg_comp_ver0 = {
+static struct lcr_comp cfg_comp_ver0 = {
 	.iface_count				= 1,
 	.ifaces					= openais_cfg_ver0
 };
 
-struct openais_service_handler *cfg_get_handler_ver0 (void)
+static struct openais_service_handler *cfg_get_handler_ver0 (void)
 {
 	return (&cfg_service_handler);
 }
 
 __attribute__ ((constructor)) static void register_this_component (void) {
+	lcr_interfaces_set (&openais_cfg_ver0[0], &cfg_service_handler_iface);
+
 	lcr_component_register (&cfg_comp_ver0);
 }
 

+ 20 - 11
exec/ckpt.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2003-2006 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -504,13 +505,13 @@ struct openais_service_handler ckpt_service_handler = {
 /*
  * Dynamic loader definition
  */
-struct openais_service_handler *ckpt_get_handler_ver0 (void);
+static struct openais_service_handler *ckpt_get_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 ckpt_service_handler_iface = {
-	.openais_get_service_handler_ver0		= ckpt_get_handler_ver0
+static struct openais_service_handler_iface_ver0 ckpt_service_handler_iface = {
+	.openais_get_service_handler_ver0	= ckpt_get_handler_ver0
 };
 
-struct lcr_iface openais_ckpt_ver0[1] = {
+static struct lcr_iface openais_ckpt_ver0[1] = {
 	{
 		.name				= "openais_ckpt",
 		.version			= 0,
@@ -520,21 +521,23 @@ struct lcr_iface openais_ckpt_ver0[1] = {
 		.dependency_count		= 0,
 		.constructor			= NULL,
 		.destructor			= NULL,
-		.interfaces			= (void **)(void *)&ckpt_service_handler_iface,
+		.interfaces			= NULL
 	}
 };
 
-struct lcr_comp ckpt_comp_ver0 = {
+static struct lcr_comp ckpt_comp_ver0 = {
 	.iface_count			= 1,
 	.ifaces				= openais_ckpt_ver0
 };
 
-struct openais_service_handler *ckpt_get_handler_ver0 (void)
+static struct openais_service_handler *ckpt_get_handler_ver0 (void)
 {
 	return (&ckpt_service_handler);
 }
 
 __attribute__ ((constructor)) static void register_this_component (void) {
+	lcr_interfaces_set (&openais_ckpt_ver0[0], &ckpt_service_handler_iface);
+
 	lcr_component_register (&ckpt_comp_ver0);
 }
 
@@ -3728,6 +3731,7 @@ static void message_handler_req_lib_ckpt_sectioniterationinitialize (
 	struct iteration_entry *iteration_entries;
 	struct list_head *section_list;
 	struct iteration_instance *iteration_instance;
+	void *iteration_instance_p;
 	unsigned int iteration_handle = 0;
 	int res;
 	SaAisErrorT error = SA_AIS_OK;
@@ -3755,11 +3759,12 @@ static void message_handler_req_lib_ckpt_sectioniterationinitialize (
 	}
 
 	res = hdb_handle_get (&ckpt_pd->iteration_hdb, iteration_handle,
-		(void **)(void *)&iteration_instance);
+		&iteration_instance_p);
 	if (res != 0) {
 		hdb_handle_destroy (&ckpt_pd->iteration_hdb, iteration_handle);
 		goto error_exit;
 	}
+	iteration_instance = (struct iteration_instance *)iteration_instance_p;
 
 	iteration_instance->iteration_entries = NULL;
 	iteration_instance->iteration_entries_count = 0;
@@ -3833,17 +3838,19 @@ static void message_handler_req_lib_ckpt_sectioniterationfinalize (
 	struct res_lib_ckpt_sectioniterationfinalize res_lib_ckpt_sectioniterationfinalize;
 	SaAisErrorT error = SA_AIS_OK;
 	struct iteration_instance *iteration_instance;
+	void *iteration_instance_p;
 	unsigned int res;
 
 	struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
 
 	res = hdb_handle_get (&ckpt_pd->iteration_hdb,
 		req_lib_ckpt_sectioniterationfinalize->iteration_handle,
-		(void **)(void *)&iteration_instance);
+		&iteration_instance_p);
 	if (res != 0) {
 		error = SA_AIS_ERR_LIBRARY;
 		goto error_exit;
 	}
+	iteration_instance = (struct iteration_instance *)iteration_instance_p;
 
 	free (iteration_instance->iteration_entries);
 
@@ -3875,19 +3882,21 @@ static void message_handler_req_lib_ckpt_sectioniterationnext (
 	SaAisErrorT error = SA_AIS_OK;
 	int sectionIdSize = 0;
 	unsigned int res;
-	struct iteration_instance *iteration_instance;
+	struct iteration_instance *iteration_instance = NULL; // this assignment to null makes no sense and is only needed with -O2 or greater TODO
+	void *iteration_instance_p;
 
 	struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
 
 	log_printf (LOG_LEVEL_DEBUG, "section iteration next\n");
 	res = hdb_handle_get (&ckpt_pd->iteration_hdb,
 		req_lib_ckpt_sectioniterationnext->iteration_handle,
-		(void **)(void *)&iteration_instance);
+		&iteration_instance_p);
 	if (res != 0) {
 		error = SA_AIS_ERR_LIBRARY;
 		goto error_exit;
 	}
 
+	iteration_instance = (struct iteration_instance *)iteration_instance_p;
 	/*
 	 * Find active iteration entry
 	 */

+ 7 - 6
exec/clm.c

@@ -1,7 +1,6 @@
 /*
- * vi: set autoindent tabstop=4 shiftwidth=4 :
- *
  * Copyright (c) 2002-2006 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -217,11 +216,11 @@ struct openais_service_handler clm_service_handler = {
  */
 static struct openais_service_handler *clm_get_service_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 clm_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 clm_service_handler_iface = {
 	.openais_get_service_handler_ver0		= clm_get_service_handler_ver0
 };
 
-struct lcr_iface openais_clm_ver0[1] = {
+static struct lcr_iface openais_clm_ver0[1] = {
 	{
 		.name					= "openais_clm",
 		.version				= 0,
@@ -231,11 +230,11 @@ struct lcr_iface openais_clm_ver0[1] = {
 		.dependency_count		= 0,
 		.constructor			= NULL,
 		.destructor				= NULL,
-		.interfaces				= (void **)(void *)&clm_service_handler_iface,
+		.interfaces				= NULL
 	}
 };
 
-struct lcr_comp clm_comp_ver0 = {
+static struct lcr_comp clm_comp_ver0 = {
 	.iface_count			= 1,
 	.ifaces					= openais_clm_ver0
 };
@@ -246,6 +245,8 @@ static struct openais_service_handler *clm_get_service_handler_ver0 (void)
 }
 
 __attribute__ ((constructor)) static void clm_comp_register (void) {
+	lcr_interfaces_set (&openais_clm_ver0[0], &clm_service_handler_iface);
+
 	lcr_component_register (&clm_comp_ver0);
 }
 

+ 8 - 8
exec/cpg.c

@@ -1,6 +1,4 @@
 /*
- * vi: set autoindent tabstop=4 shiftwidth=4 :
- *
  * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
@@ -247,13 +245,13 @@ struct openais_service_handler cpg_service_handler = {
 /*
  * Dynamic loader definition
  */
-struct openais_service_handler *cpg_get_service_handler_ver0 (void);
+static struct openais_service_handler *cpg_get_service_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 cpg_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 cpg_service_handler_iface = {
 	.openais_get_service_handler_ver0		= cpg_get_service_handler_ver0
 };
 
-struct lcr_iface openais_cpg_ver0[1] = {
+static struct lcr_iface openais_cpg_ver0[1] = {
 	{
 		.name				= "openais_cpg",
 		.version			= 0,
@@ -263,22 +261,24 @@ struct lcr_iface openais_cpg_ver0[1] = {
 		.dependency_count		= 0,
 		.constructor			= NULL,
 		.destructor			= NULL,
-		.interfaces			= (void **)(void *)&cpg_service_handler_iface,
+		.interfaces			= NULL
 	}
 };
 
-struct lcr_comp cpg_comp_ver0 = {
+static struct lcr_comp cpg_comp_ver0 = {
 	.iface_count			= 1,
 	.ifaces			        = openais_cpg_ver0
 };
 
 
-struct openais_service_handler *cpg_get_service_handler_ver0 (void)
+static struct openais_service_handler *cpg_get_service_handler_ver0 (void)
 {
 	return (&cpg_service_handler);
 }
 
 __attribute__ ((constructor)) static void cpg_comp_register (void) {
+        lcr_interfaces_set (&openais_cpg_ver0[0], &cpg_service_handler_iface);
+
 	lcr_component_register (&cpg_comp_ver0);
 }
 

+ 9 - 8
exec/evs.c

@@ -1,7 +1,6 @@
 /*
- * vi: set autoindent ;
- *
  * Copyright (c) 2004-2006 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -162,13 +161,13 @@ static DECLARE_LIST_INIT (confchg_notify);
  * Dynamic loading descriptor
  */
 
-struct openais_service_handler *evs_get_service_handler_ver0 (void);
+static struct openais_service_handler *evs_get_service_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 evs_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 evs_service_handler_iface = {
 	.openais_get_service_handler_ver0	= evs_get_service_handler_ver0
 };
 
-struct lcr_iface openais_evs_ver0[1] = {
+static struct lcr_iface openais_evs_ver0[1] = {
 	{
 		.name			= "openais_evs",
 		.version		= 0,
@@ -178,21 +177,23 @@ struct lcr_iface openais_evs_ver0[1] = {
 		.dependency_count	= 0,
 		.constructor		= NULL,
 		.destructor		= NULL,
-		.interfaces		= (void **)(void *)&evs_service_handler_iface,
+		.interfaces		= NULL,
 	}
 };
 
-struct lcr_comp evs_comp_ver0 = {
+static struct lcr_comp evs_comp_ver0 = {
 	.iface_count	= 1,
 	.ifaces		= openais_evs_ver0
 };
 
-struct openais_service_handler *evs_get_service_handler_ver0 (void)
+static struct openais_service_handler *evs_get_service_handler_ver0 (void)
 {
 	return (&evs_service_handler);
 }
 
 __attribute__ ((constructor)) static void evs_comp_register (void) {
+	lcr_interfaces_set (&openais_evs_ver0[0], &evs_service_handler_iface);
+
 	lcr_component_register (&evs_comp_ver0);
 }
 

+ 8 - 6
exec/evt.c

@@ -229,13 +229,13 @@ struct openais_service_handler evt_service_handler = {
 	.sync_abort					= evt_sync_abort
 };
 
-struct openais_service_handler *evt_get_handler_ver0(void);
+static struct openais_service_handler *evt_get_handler_ver0(void);
 
-struct openais_service_handler_iface_ver0 evt_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 evt_service_handler_iface = {
 	.openais_get_service_handler_ver0		= evt_get_handler_ver0
 };
 
-struct lcr_iface openais_evt_ver0[1] = {
+static struct lcr_iface openais_evt_ver0[1] = {
 	{
 		.name					= "openais_evt",
 		.version				= 0,
@@ -245,21 +245,23 @@ struct lcr_iface openais_evt_ver0[1] = {
 		.dependency_count		= 0,
 		.constructor			= NULL,
 		.destructor				= NULL,
-		.interfaces				= (void **)(void *)&evt_service_handler_iface,
+		.interfaces				= NULL,
 	}
 };
 
-struct lcr_comp evt_comp_ver0 = {
+static struct lcr_comp evt_comp_ver0 = {
 	.iface_count			= 1,
 	.ifaces					= openais_evt_ver0
 };
 
-struct openais_service_handler *evt_get_handler_ver0(void)
+static struct openais_service_handler *evt_get_handler_ver0(void)
 {
 	return (&evt_service_handler);
 }
 
 __attribute__ ((constructor)) static void evt_comp_register (void) {
+	lcr_interfaces_set (&openais_evt_ver0[0], &evt_service_handler_iface);
+
 	lcr_component_register (&evt_comp_ver0);
 }
 

+ 9 - 6
exec/lck.c

@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
+ * Copyright (c) 2005-2006 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -303,13 +304,13 @@ struct openais_service_handler lck_service_handler = {
 /*
  * Dynamic loader definition
  */
-struct openais_service_handler *lck_get_handler_ver0 (void);
+static struct openais_service_handler *lck_get_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 lck_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 lck_service_handler_iface = {
 	.openais_get_service_handler_ver0	= lck_get_handler_ver0
 };
 
-struct lcr_iface openais_lck_ver0[1] = {
+static struct lcr_iface openais_lck_ver0[1] = {
 	{
 		.name				= "openais_lck",
 		.version			= 0,
@@ -323,17 +324,19 @@ struct lcr_iface openais_lck_ver0[1] = {
 	}
 };
 
-struct lcr_comp lck_comp_ver0 = {
+static struct lcr_comp lck_comp_ver0 = {
 	.iface_count				= 1,
 	.ifaces					= openais_lck_ver0
 };
 
-struct openais_service_handler *lck_get_handler_ver0 (void)
+static struct openais_service_handler *lck_get_handler_ver0 (void)
 {
 	return (&lck_service_handler);
 }
 
 __attribute__ ((constructor)) static void register_this_component (void) {
+	lcr_interfaces_set (&openais_lck_ver0[0], &lck_service_handler_iface);
+
 	lcr_component_register (&lck_comp_ver0);
 }
 

+ 8 - 2
exec/main.c

@@ -1018,6 +1018,7 @@ static void aisexec_mempool_init (void)
 
 static void aisexec_tty_detach (void)
 {
+#define DEBUG
 #ifndef DEBUG
 	/*
 	 * Disconnect from TTY if this is not a debug run
@@ -1160,7 +1161,9 @@ int main (int argc, char **argv)
 	unsigned int config_handle;
 	unsigned int config_version = 0;
 	struct objdb_iface_ver0 *objdb;
+	void *objdb_p;
 	struct config_iface_ver0 *config;
+	void *config_p;
 	char *config_iface;
 	int res;
 
@@ -1179,9 +1182,11 @@ int main (int argc, char **argv)
 		&objdb_handle,
 		"objdb",
 		0,
-		(void **)(void *)&objdb,
+		&objdb_p,
 		0);
 
+	objdb = (struct objdb_iface_ver0 *)objdb_p;
+
 	objdb->objdb_init ();
 
 	/* User's bootstrap config service */
@@ -1194,9 +1199,10 @@ int main (int argc, char **argv)
 		&config_handle,
 		config_iface,
 		config_version,
-		(void **)(void *)&config,
+		&config_p,
 		0);
 
+	config = (struct config_iface_ver0 *)config_p;
 	if (res == -1) {
 		log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service: Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n");
 

+ 9 - 6
exec/msg.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2005-2006 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -452,13 +453,13 @@ struct openais_service_handler msg_service_handler = {
 	.sync_abort			= msg_sync_abort
 };
 
-struct openais_service_handler *msg_get_handler_ver0 (void);
+static struct openais_service_handler *msg_get_handler_ver0 (void);
 
-struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
+static struct openais_service_handler_iface_ver0 msg_service_handler_iface = {
 	.openais_get_service_handler_ver0	= msg_get_handler_ver0
 };
 
-struct lcr_iface openais_msg_ver0[1] = {
+static struct lcr_iface openais_msg_ver0[1] = {
 	{
 		.name			= "openais_msg",
 		.version		= 0,
@@ -468,21 +469,23 @@ struct lcr_iface openais_msg_ver0[1] = {
 		.dependency_count	= 0,
 		.constructor		= NULL,
 		.destructor		= NULL,
-		.interfaces		= (void **)(void *)&msg_service_handler_iface,
+		.interfaces		= NULL
 	}
 };
 
-struct lcr_comp msg_comp_ver0 = {
+static struct lcr_comp msg_comp_ver0 = {
 	.iface_count			= 1,
 	.ifaces				= openais_msg_ver0
 };
 
-struct openais_service_handler *msg_get_handler_ver0 (void)
+static struct openais_service_handler *msg_get_handler_ver0 (void)
 {
 	return (&msg_service_handler);
 }
 
 __attribute__ ((constructor)) static void register_this_component (void) {
+	lcr_interfaces_set (&openais_msg_ver0[0], &msg_service_handler_iface);
+
 	lcr_component_register (&msg_comp_ver0);
 }
 

+ 3 - 1
exec/objdb.c

@@ -522,7 +522,7 @@ struct lcr_iface objdb_iface_ver0[1] = {
 		.dependency_count	= 0,
 		.constructor		= NULL,
 		.destructor		= NULL,
-		.interfaces		= (void **)(void *)&objdb_iface,
+		.interfaces		= NULL,
 	}
 };
 
@@ -534,5 +534,7 @@ struct lcr_comp objdb_comp_ver0 = {
 
 
 __attribute__ ((constructor)) static void objdb_comp_register (void) {
+        lcr_interfaces_set (&objdb_iface_ver0[0], &objdb_iface);
+
 	lcr_component_register (&objdb_comp_ver0);
 }

+ 4 - 1
exec/service.c

@@ -175,6 +175,7 @@ int openais_service_link_all (struct objdb_iface_ver0 *objdb)
 	int ret;
 	unsigned int handle;
 	struct openais_service_handler_iface_ver0 *iface_ver0;
+	void *iface_ver0_p;
 	unsigned int ver_int;
 
 	objdb->object_find_reset (OBJECT_PARENT_HANDLE);
@@ -205,9 +206,11 @@ int openais_service_link_all (struct objdb_iface_ver0 *objdb)
 			&handle,
 			service_name,
 			ver_int,
-			(void **)(void *)&iface_ver0,
+			&iface_ver0_p,
 			(void *)0);
 
+		iface_ver0 = (struct openais_service_handler_iface_ver0 *)iface_ver0_p;
+
 		if (iface_ver0 == 0) {
 			log_printf(LOG_LEVEL_ERROR, "openais component %s did not load.\n", service_name);
 			openais_exit_error (AIS_DONE_DYNAMICLOAD);

+ 1 - 0
include/hdb.h

@@ -122,6 +122,7 @@ static inline int hdb_handle_get (
 	unsigned int handle,
 	void **instance)
 {
+	*instance = NULL;
 	if (handle >= handle_database->handle_count) {
 		return (-1);
 	}

+ 5 - 0
lcr/lcr_comp.h

@@ -56,4 +56,9 @@ struct lcr_comp {
 
 extern void lcr_component_register (struct lcr_comp *comp);
 
+static inline void lcr_interfaces_set (struct lcr_iface *iface, void *iface_list)
+{
+	iface->interfaces = (void **)iface_list;
+}
+
 #endif /* LCR_COMP_H_DEFINED */

+ 9 - 6
lcr/lcr_ifact.c

@@ -83,15 +83,13 @@ static int lcr_select_so (struct dirent *dirent)
 	return (0);
 }
 
-/* TODO
- * FC5 gcc 4.1 optimizer breaks if this code is automatically inlined
- */
-__attribute__((noinline)) static struct lcr_component_instance *lcr_comp_find (
+static inline struct lcr_component_instance *lcr_comp_find (
 	char *iface_name,
 	unsigned int version,
 	int *iface_number)
 {
 	struct lcr_component_instance *instance;
+	void *instance_p;
 	unsigned int component_handle = 0;
 	int i;
 
@@ -100,7 +98,9 @@ __attribute__((noinline)) static struct lcr_component_instance *lcr_comp_find (
 	 */
 	hdb_iterator_reset (&lcr_component_instance_database);
 	while (hdb_iterator_next (&lcr_component_instance_database,
-		(void **)(void *)&instance, &component_handle) == 0) {
+		&instance_p, &component_handle) == 0) {
+
+		instance = (struct lcr_component_instance *)instance_p;
 
 		for (i = 0; i < instance->iface_count; i++) {
 			if ((strcmp (instance->ifaces[i].name, iface_name) == 0) &&
@@ -120,6 +120,7 @@ static inline int lcr_lib_loaded (
 	char *library_name)
 {
 	struct lcr_component_instance *instance;
+	void *instance_p;
 	unsigned int component_handle = 0;
 
 	/*
@@ -127,7 +128,9 @@ static inline int lcr_lib_loaded (
 	 */
 	hdb_iterator_reset (&lcr_component_instance_database);
 	while (hdb_iterator_next (&lcr_component_instance_database,
-		(void **)(void *)&instance, &component_handle) == 0) {
+		(void *)&instance_p, &component_handle) == 0) {
+
+		instance = (struct lcr_component_instance *)instance_p;
 
 		if (strcmp (instance->library_name, library_name) == 0) {
 			return (1);

+ 4 - 2
lcr/libtest_a.c

@@ -91,7 +91,7 @@ static struct lcr_iface iface1[2] = {
 		.dependency_count	= 0,
 		.constructor		= iface1_constructor,
 		.destructor		= iface1_destructor,
-		.interfaces		= (void **)(void *)&iface_list,
+		.interfaces		= NULL
 	},
 	/* version 1 */
 	{
@@ -103,7 +103,7 @@ static struct lcr_iface iface1[2] = {
 		.dependency_count	= 0,
 		.constructor		= iface1_ver1_constructor,
 		.destructor		= iface1_ver1_destructor,
-		.interfaces		= (void **)(void *)&iface_ver1_list
+		.interfaces		= NULL
 	}
 };
 
@@ -157,6 +157,8 @@ static void iface1_ver1_func3 (void) {
 }
 
 __attribute__ ((constructor)) static void register_this_component (void) {
+	lcr_interfaces_set (&iface1[0], &iface_list);
+	lcr_interfaces_set (&iface1[1], &iface_ver1_list);
 	lcr_component_register (&test_comp);
 }
 

+ 5 - 3
lcr/libtest_b.c

@@ -93,7 +93,7 @@ struct lcr_iface iface1[2]= {
 		.dependency_count	= 0,
 		.constructor		= iface1_constructor,
 		.destructor		= iface1_destructor,
-		.interfaces		= (void **)(void *)&iface_list,
+		.interfaces		= NULL
 	},
 	/*
 	 * Version 1
@@ -107,7 +107,7 @@ struct lcr_iface iface1[2]= {
 		.dependency_count	= 0,
 		.constructor		= iface1_ver1_constructor,
 		.destructor		= iface1_ver1_destructor,
-		.interfaces		= (void **)(void *)&iface_ver1_list
+		.interfaces		= NULL
 	}
 };
 
@@ -164,6 +164,8 @@ static void iface1_ver1_func3 (void) {
 
 __attribute__ ((constructor)) static void register_this_component (void)
 {
+        lcr_interfaces_set (&iface1[0], &iface_list);
+        lcr_interfaces_set (&iface1[1], &iface_ver1_list);
+
 	lcr_component_register (&test_comp);
 }
-

+ 16 - 4
lcr/test.c

@@ -41,11 +41,15 @@ int main (void) {
 	unsigned int b_ifact_handle_ver0;
 	struct iface *a_iface_ver0;
 	struct iface *a_iface_ver1;
+	void *a_iface_ver0_p;
+	void *a_iface_ver1_p;
 
 	unsigned int a_ifact_handle_ver1;
 	unsigned int b_ifact_handle_ver1;
 	struct iface *b_iface_ver0;
 	struct iface *b_iface_ver1;
+	void *b_iface_ver0_p;
+	void *b_iface_ver1_p;
 
 	/*
 	 * Reference version 0 and 1 of A and B interfaces
@@ -54,30 +58,38 @@ int main (void) {
 		&a_ifact_handle_ver0,
 		"A_iface1",
 		0, /* version 0 */
-		(void **)(void *)&a_iface_ver0,
+		&a_iface_ver0_p,
 		(void *)0xaaaa0000);
 
+	a_iface_ver0 = (struct iface *)a_iface_ver0_p;
+
 	lcr_ifact_reference (
 		&b_ifact_handle_ver0,
 		"B_iface1",
 		0, /* version 0 */
-		(void **)(void *)&b_iface_ver0,
+		&b_iface_ver0_p,
 		(void *)0xbbbb0000);
 
+	b_iface_ver0 = (struct iface *)b_iface_ver0_p;
+
 	lcr_ifact_reference (
 		&a_ifact_handle_ver1,
 		"A_iface1",
 		1, /* version 1 */
-		(void **)(void *)&a_iface_ver1,
+		&a_iface_ver1_p,
 		(void *)0xaaaa1111);
 
+	a_iface_ver1 = (struct iface *)a_iface_ver0_p;
+
 	lcr_ifact_reference (
 		&b_ifact_handle_ver1,
 		"B_iface1",
 		1, /* version 1 */
-		(void **)(void *)&b_iface_ver1,
+		&b_iface_ver1_p,
 		(void *)0xbbbb1111);
 
+	b_iface_ver1 = (struct iface *)b_iface_ver0_p;
+
 	a_iface_ver0->func1();
 	a_iface_ver0->func2();
 	a_iface_ver0->func3();