summaryrefslogtreecommitdiff
path: root/xmlIO.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2017-10-09 13:37:42 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2017-10-09 13:47:49 +0200
commitd422b954be178afca1abeded9054ee6e39272904 (patch)
tree77bd0a2732bbdb9fe7939ed4767165b200db1c99 /xmlIO.c
parent41c0a13fe7455bbdd3aa785a67ded91058f81333 (diff)
downloadlibxml2-d422b954be178afca1abeded9054ee6e39272904.tar.gz
Fix pointer/int cast warnings on 64-bit Windows
On 64-bit Windows, `long` is 32 bits wide and can't hold a pointer. Switch to ptrdiff_t instead which should be the same size as a pointer on every somewhat sane platform without requiring C99 types like intptr_t. Fixes bug 788312. Thanks to J. Peter Mugaas for the report and initial patch.
Diffstat (limited to 'xmlIO.c')
-rw-r--r--xmlIO.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/xmlIO.c b/xmlIO.c
index 6891ff9a..5902f627 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -12,6 +12,7 @@
#include "libxml.h"
#include <string.h>
+#include <stddef.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -826,7 +827,7 @@ static int
xmlFdRead (void * context, char * buffer, int len) {
int ret;
- ret = read((int) (long) context, &buffer[0], len);
+ ret = read((int) (ptrdiff_t) context, &buffer[0], len);
if (ret < 0) xmlIOErr(0, "read()");
return(ret);
}
@@ -847,7 +848,7 @@ xmlFdWrite (void * context, const char * buffer, int len) {
int ret = 0;
if (len > 0) {
- ret = write((int) (long) context, &buffer[0], len);
+ ret = write((int) (ptrdiff_t) context, &buffer[0], len);
if (ret < 0) xmlIOErr(0, "write()");
}
return(ret);
@@ -865,7 +866,7 @@ xmlFdWrite (void * context, const char * buffer, int len) {
static int
xmlFdClose (void * context) {
int ret;
- ret = close((int) (long) context);
+ ret = close((int) (ptrdiff_t) context);
if (ret < 0) xmlIOErr(0, "close()");
return(ret);
}
@@ -3008,7 +3009,7 @@ xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc) {
ret = xmlAllocParserInputBuffer(enc);
if (ret != NULL) {
- ret->context = (void *) (long) fd;
+ ret->context = (void *) (ptrdiff_t) fd;
ret->readcallback = xmlFdRead;
ret->closecallback = xmlFdClose;
}
@@ -3114,7 +3115,7 @@ xmlOutputBufferCreateFd(int fd, xmlCharEncodingHandlerPtr encoder) {
ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
- ret->context = (void *) (long) fd;
+ ret->context = (void *) (ptrdiff_t) fd;
ret->writecallback = xmlFdWrite;
ret->closecallback = NULL;
}