Bug 1256558 - Change MUST_CONVERT to avoid C4311 in VS2015; r=khuey
authorGregory Szorc <gps@mozilla.com>
Mon, 21 Mar 2016 12:00:41 -0700
changeset 289782 4c575b4f5492cadf448bf4e77504bce4ad51957f
parent 289781 f5090987b7c69d35ec7cfbc1829ccf31676947d5
child 289783 22fcb50e9842f1ccd229e689e106e038afafd546
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1256558
milestone48.0a1
Bug 1256558 - Change MUST_CONVERT to avoid C4311 in VS2015; r=khuey This code is cherry picked from the trunk version of expat. MozReview-Commit-ID: 8RDaArq2BwO
parser/expat/lib/xmlparse.c
--- a/parser/expat/lib/xmlparse.c
+++ b/parser/expat/lib/xmlparse.c
@@ -21,17 +21,19 @@
 #include "expat.h"
 
 #ifdef XML_UNICODE
 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
 #define XmlConvert XmlUtf16Convert
 #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
 #define XmlEncode XmlUtf16Encode
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1))
+
+/* Using pointer subtraction to convert to integer type. */
+#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1))
 typedef unsigned short ICHAR;
 #else
 #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
 #define XmlConvert XmlUtf8Convert
 #define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
 #define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
 #define XmlEncode XmlUtf8Encode
 #define MUST_CONVERT(enc, s) (!(enc)->isUtf8)