summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2013-04-09 15:49:37 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-04-17 15:34:49 -0500
commit198ccaf1e562c281684e47a2209b7ce29c9c71e6 (patch)
treef75d9769bafb3efb814d0149a7971261ab450dab /src
parent06d989d45066a28d149f15a45301346101eb1006 (diff)
downloadtalos-hostboot-198ccaf1e562c281684e47a2209b7ce29c9c71e6.tar.gz
talos-hostboot-198ccaf1e562c281684e47a2209b7ce29c9c71e6.zip
Fix strict-aliasing violations.
Change-Id: I5f3feae4fb62ed82b52e996d4954d1c638a243b3 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4036 Reviewed-by: Brian H. Horton <brianh@linux.ibm.com> Tested-by: Jenkins Server Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/util/impl/splaytree.H73
-rw-r--r--src/lib/splaytree.C48
-rw-r--r--src/usr/intr/intrrp.H4
-rw-r--r--src/usr/runtime/fakepayload.C8
-rw-r--r--src/usr/testcore/kernel/vmmbasetest.H11
-rw-r--r--src/usr/trace/daemon/daemon.C15
6 files changed, 84 insertions, 75 deletions
diff --git a/src/include/util/impl/splaytree.H b/src/include/util/impl/splaytree.H
index 8b3743b50..1ec8dd487 100644
--- a/src/include/util/impl/splaytree.H
+++ b/src/include/util/impl/splaytree.H
@@ -1,26 +1,25 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/include/util/impl/splaytree.H $
- *
- * IBM CONFIDENTIAL
- *
- * COPYRIGHT International Business Machines Corp. 2012
- *
- * p1
- *
- * Object Code Only (OCO) source materials
- * Licensed Internal Code Source Materials
- * IBM HostBoot Licensed Internal Code
- *
- * The source code for this program is not published or other-
- * wise divested of its trade secrets, irrespective of what has
- * been deposited with the U.S. Copyright Office.
- *
- * Origin: 30
- *
- * IBM_PROLOG_END_TAG
- */
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/util/impl/splaytree.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012,2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
#ifndef __UTIL_IMPL_SPLAYTREE_H
#define __UTIL_IMPL_SPLAYTREE_H
@@ -101,7 +100,7 @@ namespace Util
{
parent = child[LEFT] = child[RIGHT] = NULL;
- new (&data_T()) T();
+ new (&data) T();
};
/** Default destructor.
@@ -110,7 +109,6 @@ namespace Util
*/
~Node()
{
- data_T().~T();
}
/** Copy constructor from a Node.
@@ -124,7 +122,7 @@ namespace Util
// they're from a different tree.
parent = child[LEFT] = child[RIGHT] = NULL;
- new (&data_T()) T(r.data_T());
+ new (&data) T(r.data);
};
/** Copy constructor from a T.
@@ -136,19 +134,18 @@ namespace Util
{
parent = child[LEFT] = child[RIGHT] = NULL;
- new (&data_T()) T(v);
+ new (&data) T(v);
};
-
/** Access the data storage area as a T&. */
T& data_T()
{
- return *(reinterpret_cast<T*>(data));
+ return data;
};
/** Access the data storage area as a const T&. */
const T& data_T() const
{
- return *(reinterpret_cast<const T*>(data));
+ return data;
}
// Allow the SplayTree to use our internals.
@@ -193,7 +190,7 @@ namespace Util
child[LEFT] = r.child[LEFT];
child[RIGHT] = r.child[RIGHT];
- new (&data_T()) T(r.data_T());
+ new (&data) T(r.data);
return *this;
}
@@ -211,14 +208,8 @@ namespace Util
/** Node-link to children nodes. */
mutable Node<T>* child[2];
- /** Data storage area.
- *
- * Uses a compile-time calculation (static_max) to
- * ensure this will be at least the size of a pointer.
- */
- char data[Util::Algorithm::static_max<size_t,
- sizeof(void*),
- sizeof(T)>::value];
+ /** Data storage area. */
+ T data;
};
// Forward declaration of iterator types.
@@ -392,10 +383,10 @@ namespace Util
/** Determine if the tree is empty. */
bool empty() const
- { return (header_n()->data_T() == 0); };
+ { return (header_n()->data == 0); };
/** Determine the size (in nodes) of the tree. */
size_t size() const
- { return (header_n()->data_T()); };
+ { return (header_n()->data); };
/** Get a pointer to the first node (smallest by value). */
node* front()
diff --git a/src/lib/splaytree.C b/src/lib/splaytree.C
index 7505d4164..b5c16b84c 100644
--- a/src/lib/splaytree.C
+++ b/src/lib/splaytree.C
@@ -1,25 +1,25 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/lib/splaytree.C $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2012
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/lib/splaytree.C $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2012,2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
#include <util/impl/splaytree.H>
#include <builtins.h>
@@ -92,7 +92,7 @@ namespace Util
}
// Increment size count.
- (header_n()->data_T())++;
+ (header_n()->data)++;
}
void SplayTree::insert_range(const node* n1, const node* n2)
@@ -118,7 +118,7 @@ namespace Util
}
// Decrement size count.
- (header_n()->data_T())--;
+ (header_n()->data)--;
// Find node to splice out of the tree.
// If n has one or no child, splice itself out, otherwise the
diff --git a/src/usr/intr/intrrp.H b/src/usr/intr/intrrp.H
index b8c2e9d82..b6896ebbc 100644
--- a/src/usr/intr/intrrp.H
+++ b/src/usr/intr/intrrp.H
@@ -61,7 +61,7 @@ namespace INTR
uint32_t threadId:3; //!< Thread number (0-7)
} PACKED;
};
- PIR_t(uint32_t i_word) : word(i_word) {}
+ PIR_t(uint32_t i_word = 0) : word(i_word) {}
PIR_t operator= (uint32_t i_word)
{
@@ -173,7 +173,7 @@ namespace INTR
PE_IRSN_TX = 4, // downstream enable
};
- enum INTR_ROUTING_t
+ enum INTR_ROUTING_t
{
INTR_UPSTREAM,
INTR_DOWNSTREAM,
diff --git a/src/usr/runtime/fakepayload.C b/src/usr/runtime/fakepayload.C
index 0600bfa68..0890ecdcd 100644
--- a/src/usr/runtime/fakepayload.C
+++ b/src/usr/runtime/fakepayload.C
@@ -70,7 +70,13 @@ void FakePayload::load()
// Copy over the fake payload code.
uint8_t* dest = reinterpret_cast<uint8_t*>(memArea) + entry;
- memcpy(dest, *(reinterpret_cast<void**>(&payload)), size);
+ union fn_ptr
+ {
+ void (*opd)();
+ uint64_t** data;
+ };
+ fn_ptr payload_code = { payload };
+ memcpy(dest, *payload_code.data, size);
// Invalidate the icache since this is instructions.
mm_icache_invalidate(memArea, ALIGN_8(safeClearArea) / sizeof(uint64_t));
diff --git a/src/usr/testcore/kernel/vmmbasetest.H b/src/usr/testcore/kernel/vmmbasetest.H
index fbfdddf70..15c853268 100644
--- a/src/usr/testcore/kernel/vmmbasetest.H
+++ b/src/usr/testcore/kernel/vmmbasetest.H
@@ -150,7 +150,16 @@ class VmmBaseTest : public CxxTest::TestSuite
static void* writeToKernelCode(void* unused)
{
- (*(*(uint64_t**)&printk)) = 0x12345678;
+ uint64_t value = 0x12345678;
+
+ union fn_ptr
+ {
+ void (*opd)(const char*, ...);
+ uint64_t** data;
+ };
+ fn_ptr function = { printk };
+
+ memcpy(*function.data, &value, sizeof(value));
return NULL;
}
diff --git a/src/usr/trace/daemon/daemon.C b/src/usr/trace/daemon/daemon.C
index 4e4e8df04..e9062f867 100644
--- a/src/usr/trace/daemon/daemon.C
+++ b/src/usr/trace/daemon/daemon.C
@@ -324,10 +324,12 @@ namespace TRACEDAEMON
iv_curOffset[whichBuffer] = 0;
}
+ trace_bin_entry_t* contEntry =
+ reinterpret_cast<trace_bin_entry_t*>(&whichEntry->data[0]);
+
// Calculate the sizes of the entry.
- size_t contEntryDataLength =
- reinterpret_cast<trace_bin_entry_t*>(&whichEntry->data[0])
- ->head.length + sizeof(trace_bin_entry_t);
+ size_t contEntryDataLength = contEntry->head.length +
+ sizeof(trace_bin_entry_t);
size_t contEntrySize = whichEntry->comp->iv_compNameLen +
contEntryDataLength;
@@ -705,10 +707,11 @@ namespace TRACEDAEMON
if (NULL != entry->comp)
{
+ trace_bin_entry_t* entryBin =
+ reinterpret_cast<trace_bin_entry_t*>(&entry->data[0]);
// Calculate entry size.
- size_t entryDataLength =
- reinterpret_cast<trace_bin_entry_t*>(&entry->data[0])
- ->head.length + sizeof(trace_bin_entry_t);
+ size_t entryDataLength = entryBin->head.length +
+ sizeof(trace_bin_entry_t);
size_t entrySize = entry->comp->iv_compNameLen +
entryDataLength;
OpenPOWER on IntegriCloud