Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/acpica/dist use a union cast to assert alig...



details:   https://anonhg.NetBSD.org/src/rev/efceab0edae9
branches:  trunk
changeset: 451359:efceab0edae9
user:      christos <christos%NetBSD.org@localhost>
date:      Fri May 17 20:27:48 2019 +0000

description:
use a union cast to assert alignment of string constant.

diffstat:

 sys/external/bsd/acpica/dist/events/evregion.c |  2 +-
 sys/external/bsd/acpica/dist/include/actypes.h |  4 ++++
 2 files changed, 5 insertions(+), 1 deletions(-)

diffs (26 lines):

diff -r c6194b9c1643 -r efceab0edae9 sys/external/bsd/acpica/dist/events/evregion.c
--- a/sys/external/bsd/acpica/dist/events/evregion.c    Fri May 17 18:50:40 2019 +0000
+++ b/sys/external/bsd/acpica/dist/events/evregion.c    Fri May 17 20:27:48 2019 +0000
@@ -581,7 +581,7 @@
     ACPI_EVALUATE_INFO      *Info;
     ACPI_OPERAND_OBJECT     *Args[3];
     ACPI_OPERAND_OBJECT     *RegionObj2;
-    const ACPI_NAME         *RegNamePtr = ACPI_CAST_PTR (ACPI_NAME, METHOD_NAME__REG);
+    const ACPI_NAME         *RegNamePtr = ACPI_ALIGNED_STR_UNION (ACPI_NAME, METHOD_NAME__REG);
     ACPI_NAMESPACE_NODE     *MethodNode;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
diff -r c6194b9c1643 -r efceab0edae9 sys/external/bsd/acpica/dist/include/actypes.h
--- a/sys/external/bsd/acpica/dist/include/actypes.h    Fri May 17 18:50:40 2019 +0000
+++ b/sys/external/bsd/acpica/dist/include/actypes.h    Fri May 17 20:27:48 2019 +0000
@@ -540,6 +540,10 @@
 
 #define ACPI_ARRAY_LENGTH(x)            (sizeof(x) / sizeof((x)[0]))
 
+/* Use a union to align  string s to type t */
+#define ACPI_ALIGNED_STR_UNION(t, s)   \
+    (&((const union { char _s[sizeof(t)]; t _t; }){ s }._t))
+
 /* Pointer manipulation */
 
 #define ACPI_CAST_PTR(t, p)             ((t *) (ACPI_UINTPTR_T) (p))



Home | Main Index | Thread Index | Old Index