# HG changeset patch # User jlarmour # Date 1082086420 0 # Node ID 05e490add1fbd504fe0db6da570dfecedde8fee3 # Parent edb4ac2e0d6bb2e2fec52645c8fabeacf6ab73c5 * src/iosys.c (cyg_io_lookup): Use union to avoid aliasing problems with compiler. diff --git a/packages/io/common/current/ChangeLog b/packages/io/common/current/ChangeLog --- a/packages/io/common/current/ChangeLog +++ b/packages/io/common/current/ChangeLog @@ -1,3 +1,8 @@ +2004-04-16 Jonathan Larmour + + * src/iosys.c (cyg_io_lookup): Use union to avoid aliasing problems + with compiler. + 2004-01-19 Nick Garnett * include/config_keys.h (CYG_IO_GET_CONFIG_DISK_INFO): Added DISK diff --git a/packages/io/common/current/src/iosys.c b/packages/io/common/current/src/iosys.c --- 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; }