[libxml2] Fix cast-align warnings



commit 1a595cd17347e0475ab57038ba4a11f1bf41b40f
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Sat Jun 17 14:13:51 2017 +0200

    Fix cast-align warnings
    
    - Suppress warnings in xmlmemory.c by casting to 'void *'.
    - Remove unneeded cast in xmlschemas.c that caused a macro precedence
      error.
    - Add dummy fields to short structs in xmlschemas.c. This increases the
      size of the structs, but I can't see a better solution without using
      C11's _Alignof operator.
    
    There are still a couple of cast-align warnings in encoding.c. These
    are legitimate portability issues that can't be fixed without reworking
    the conversion functions.

 xmlmemory.c  |    2 +-
 xmlschemas.c |    4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/xmlmemory.c b/xmlmemory.c
index 58de2ed..6400395 100644
--- a/xmlmemory.c
+++ b/xmlmemory.c
@@ -111,7 +111,7 @@ typedef struct memnod {
 
 #define MAX_SIZE_T ((size_t)-1)
 
-#define CLIENT_2_HDR(a) ((MEMHDR *) (((char *) (a)) - RESERVE_SIZE))
+#define CLIENT_2_HDR(a) ((void *) (((char *) (a)) - RESERVE_SIZE))
 #define HDR_2_CLIENT(a)    ((void *) (((char *) (a)) + RESERVE_SIZE))
 
 
diff --git a/xmlschemas.c b/xmlschemas.c
index d42afb7..479167d 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -166,7 +166,7 @@ static const xmlChar *xmlNamespaceNs = (const xmlChar *)
 /*
 * Macros for attribute uses.
 */
-#define WXS_ATTRUSE_DECL(au) WXS_ATTR_CAST (WXS_ATTR_USE_CAST (au))->attrDecl
+#define WXS_ATTRUSE_DECL(au) (WXS_ATTR_USE_CAST (au))->attrDecl
 
 #define WXS_ATTRUSE_TYPEDEF(au) WXS_ATTR_TYPEDEF(WXS_ATTRUSE_DECL( WXS_ATTR_USE_CAST au))
 
@@ -363,6 +363,7 @@ typedef struct _xmlSchemaAbstractCtxt xmlSchemaAbstractCtxt;
 typedef xmlSchemaAbstractCtxt *xmlSchemaAbstractCtxtPtr;
 struct _xmlSchemaAbstractCtxt {
     int type; /* E.g. XML_SCHEMA_CTXT_VALIDATOR */
+    void *dummy; /* Fix alignment issues */
 };
 
 typedef struct _xmlSchemaBucket xmlSchemaBucket;
@@ -473,6 +474,7 @@ typedef struct _xmlSchemaBasicItem xmlSchemaBasicItem;
 typedef xmlSchemaBasicItem *xmlSchemaBasicItemPtr;
 struct _xmlSchemaBasicItem {
     xmlSchemaTypeType type;
+    void *dummy; /* Fix alignment issues */
 };
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]