diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-04-17 11:58:46 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-04-17 12:01:47 -0400 |
commit | 6d5c51fa0ae84a98f4200d39de4eb2b75e369753 (patch) | |
tree | 1be36067799d6e710cdf43cb0e2e52daebbbc73e | |
parent | 0e71f86251307a37161cf3de2704a59882e25258 (diff) |
Fix compile failure related to aliasing (gcc 4.4.5)
My version of gcc would complain about "dereferencing pointer does
break strict-aliasing rules" because of a (harmless) pointer cast.
This patch adds a helper void pointer to make the assignment explicit,
which avoids the cast and hence silences the warning.
-rw-r--r-- | src/kernel_iface.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/kernel_iface.c b/src/kernel_iface.c index e446102..98449b0 100644 --- a/src/kernel_iface.c +++ b/src/kernel_iface.c | |||
@@ -86,6 +86,7 @@ int init_kernel_iface(void) | |||
86 | { | 86 | { |
87 | int err = 0; | 87 | int err = 0; |
88 | long page_size = sysconf(_SC_PAGESIZE); | 88 | long page_size = sysconf(_SC_PAGESIZE); |
89 | void* mapped_at = NULL; | ||
89 | 90 | ||
90 | BUILD_BUG_ON(sizeof(union np_flag) != sizeof(uint64_t)); | 91 | BUILD_BUG_ON(sizeof(union np_flag) != sizeof(uint64_t)); |
91 | 92 | ||
@@ -98,7 +99,13 @@ int init_kernel_iface(void) | |||
98 | BUILD_BUG_ON(offsetof(struct control_page, irq_syscall_start) | 99 | BUILD_BUG_ON(offsetof(struct control_page, irq_syscall_start) |
99 | != LITMUS_CP_OFFSET_IRQ_SC_START); | 100 | != LITMUS_CP_OFFSET_IRQ_SC_START); |
100 | 101 | ||
101 | err = map_file(LITMUS_CTRL_DEVICE, (void**) &ctrl_page, CTRL_PAGES * page_size); | 102 | err = map_file(LITMUS_CTRL_DEVICE, &mapped_at, CTRL_PAGES * page_size); |
103 | |||
104 | /* Assign ctrl_page indirectly to avoid GCC warnings about aliasing | ||
105 | * related to type pruning. | ||
106 | */ | ||
107 | ctrl_page = mapped_at; | ||
108 | |||
102 | if (err) { | 109 | if (err) { |
103 | fprintf(stderr, "%s: cannot open LITMUS^RT control page (%m)\n", | 110 | fprintf(stderr, "%s: cannot open LITMUS^RT control page (%m)\n", |
104 | __FUNCTION__); | 111 | __FUNCTION__); |