summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2022-09-04 16:41:43 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2022-09-04 18:36:04 +0200
commit0d9012585926d6dc0f9bf563b8302c0f2e54876c (patch)
tree83f66784d3280ba967ba3bf0348304329bbdac33 /python
parent71736b4e9a8fb458841c05495c805ddf89027700 (diff)
downloadlibxml2-0d9012585926d6dc0f9bf563b8302c0f2e54876c.tar.gz
Fix Windows compiler warnings in python/types.c
Diffstat (limited to 'python')
-rw-r--r--python/libxml_wrap.h5
-rw-r--r--python/types.c33
2 files changed, 19 insertions, 19 deletions
diff --git a/python/libxml_wrap.h b/python/libxml_wrap.h
index 478a20df..2ba7571a 100644
--- a/python/libxml_wrap.h
+++ b/python/libxml_wrap.h
@@ -68,11 +68,8 @@
#define XML_IGNORE_DEPRECATION_WARNINGS \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
-#define XML_POP_WARNINGS \
- _Pragma("GCC diagnostic pop")
#else
-#define XML_IGNORE_PEDANTIC_WARNINGS
-#define XML_POP_WARNINGS
+#define XML_IGNORE_DEPRECATION_WARNINGS
#endif
#define PyxmlNode_Get(v) (((v) == Py_None) ? NULL : \
diff --git a/python/types.c b/python/types.c
index 644752ec..5efeef99 100644
--- a/python/types.c
+++ b/python/types.c
@@ -78,7 +78,6 @@ myInvalidParameterHandler(const wchar_t *expression,
FILE *
libxml_PyFileGet(PyObject *f) {
- int flags;
FILE *res;
const char *mode;
int fd = PyObject_AsFileDescriptor(f);
@@ -112,8 +111,9 @@ libxml_PyFileGet(PyObject *f) {
if (hntdll == NULL)
return(NULL);
-
+XML_IGNORE_FPTR_CAST_WARNINGS
NtQueryInformationFile = (t_NtQueryInformationFile)GetProcAddress(hntdll, "NtQueryInformationFile");
+XML_POP_WARNINGS
if (NtQueryInformationFile != NULL &&
(NtQueryInformationFile((HANDLE)w_fh,
@@ -129,23 +129,24 @@ libxml_PyFileGet(PyObject *f) {
if (ai.AccessFlags & FILE_APPEND_DATA)
is_append = TRUE;
- if (is_write && is_read)
- if (is_append)
- mode = "a+";
- else
- mode = "rw";
-
- if (!is_write && is_read)
+ if (is_write) {
+ if (is_read) {
+ if (is_append)
+ mode = "a+";
+ else
+ mode = "rw";
+ } else {
+ if (is_append)
+ mode = "a";
+ else
+ mode = "w";
+ }
+ } else {
if (is_append)
mode = "r+";
else
mode = "r";
-
- if (is_write && !is_read)
- if (is_append)
- mode = "a";
- else
- mode = "w";
+ }
}
FreeLibrary(hntdll);
@@ -153,6 +154,8 @@ libxml_PyFileGet(PyObject *f) {
if (!is_write && !is_read) /* also happens if we did not load or run NtQueryInformationFile() successfully */
return(NULL);
#else
+ int flags;
+
/*
* macOS returns O_RDWR for standard streams, but fails to write to
* stdout or stderr when opened with fdopen(dup_fd, "rw").