changeset 1595:05e490add1fb

* src/iosys.c (cyg_io_lookup): Use union to avoid aliasing problems with compiler.
author jlarmour
date Fri, 16 Apr 2004 03:33:40 +0000
parents edb4ac2e0d6b
children df01feb2f050
files packages/io/common/current/ChangeLog packages/io/common/current/src/iosys.c
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packages/io/common/current/ChangeLog
+++ b/packages/io/common/current/ChangeLog
@@ -1,3 +1,8 @@
+2004-04-16  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/iosys.c (cyg_io_lookup): Use union to avoid aliasing problems
+	with compiler.
+
 2004-01-19  Nick Garnett  <nickg@calivar.com>
 
 	* include/config_keys.h (CYG_IO_GET_CONFIG_DISK_INFO): Added DISK
--- a/packages/io/common/current/src/iosys.c
+++ b/packages/io/common/current/src/iosys.c
@@ -124,25 +124,29 @@ cyg_io_init(void)
 Cyg_ErrNo
 cyg_io_lookup(const char *name, cyg_io_handle_t *handle)
 {
-    cyg_devtab_entry_t *t, *st;
+    union devtab_entry_handle_union {
+        cyg_devtab_entry_t *st;
+        cyg_io_handle_t h;
+    } stunion;
+    cyg_devtab_entry_t *t;
     Cyg_ErrNo res;
     const char *name_ptr;
     for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++) {
         if (cyg_io_compare(name, t->name, &name_ptr)) {
             // FUTURE: Check 'avail'/'online' here
             if (t->dep_name) {
-                res = cyg_io_lookup(t->dep_name, (cyg_io_handle_t *)&st);
+                res = cyg_io_lookup(t->dep_name, &stunion.h);
                 if (res != ENOERR) {
                     return res;
                 }
             } else {
-                st = (cyg_devtab_entry_t *)0;
+                stunion.st = NULL;
             }
             if (t->lookup) {
                 // This indirection + the name pointer allows the lookup routine
                 // to return a different 'devtab' handle.  This will provide for
                 // 'pluggable' devices, file names, etc.
-                res = (t->lookup)(&t, st, name_ptr);
+                res = (t->lookup)(&t, stunion.st, name_ptr);
                 if (res != ENOERR) {
                     return res;
                 }