diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-09-04 16:41:43 +0200 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2022-09-04 18:36:04 +0200 |
commit | 0d9012585926d6dc0f9bf563b8302c0f2e54876c (patch) | |
tree | 83f66784d3280ba967ba3bf0348304329bbdac33 /python/types.c | |
parent | 71736b4e9a8fb458841c05495c805ddf89027700 (diff) | |
download | libxml2-0d9012585926d6dc0f9bf563b8302c0f2e54876c.tar.gz |
Fix Windows compiler warnings in python/types.c
Diffstat (limited to 'python/types.c')
-rw-r--r-- | python/types.c | 33 |
1 files changed, 18 insertions, 15 deletions
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"). |