Unverified Kaydet (Commit) dedcbee0 authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

[3.6] bpo-30923, bpo-31279: Fix GCC warnings (#4620)

* bpo-30923: Silence fall-through warnings in libexpat build. (#3205)

(cherry picked from commit 9e1e6f52)

* bpo-31279: Silence -Wstringop-overflow warning. (#3207)

(cherry picked from commit dce65020)
üst 06be9daf
...@@ -244,7 +244,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size) ...@@ -244,7 +244,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size)
return -1; return -1;
} }
memcpy(sval, PyByteArray_AS_STRING(self), memcpy(sval, PyByteArray_AS_STRING(self),
Py_MIN(requested_size, Py_SIZE(self))); Py_MIN((size_t)requested_size, (size_t)Py_SIZE(self)));
PyObject_Free(obj->ob_bytes); PyObject_Free(obj->ob_bytes);
} }
else { else {
......
...@@ -1526,6 +1526,7 @@ class PyBuildExt(build_ext): ...@@ -1526,6 +1526,7 @@ class PyBuildExt(build_ext):
if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"): if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
expat_inc = [] expat_inc = []
define_macros = [] define_macros = []
extra_compile_args = []
expat_lib = ['expat'] expat_lib = ['expat']
expat_sources = [] expat_sources = []
expat_depends = [] expat_depends = []
...@@ -1537,6 +1538,7 @@ class PyBuildExt(build_ext): ...@@ -1537,6 +1538,7 @@ class PyBuildExt(build_ext):
# call XML_SetHashSalt(), expat entropy sources are not needed # call XML_SetHashSalt(), expat entropy sources are not needed
('XML_POOR_ENTROPY', '1'), ('XML_POOR_ENTROPY', '1'),
] ]
extra_compile_args = []
expat_lib = [] expat_lib = []
expat_sources = ['expat/xmlparse.c', expat_sources = ['expat/xmlparse.c',
'expat/xmlrole.c', 'expat/xmlrole.c',
...@@ -1554,8 +1556,15 @@ class PyBuildExt(build_ext): ...@@ -1554,8 +1556,15 @@ class PyBuildExt(build_ext):
'expat/xmltok_impl.h' 'expat/xmltok_impl.h'
] ]
cc = sysconfig.get_config_var('CC').split()[0]
ret = os.system(
'"%s" -Werror -Wimplicit-fallthrough -E -xc /dev/null >/dev/null 2>&1' % cc)
if ret >> 8 == 0:
extra_compile_args.append('-Wno-implicit-fallthrough')
exts.append(Extension('pyexpat', exts.append(Extension('pyexpat',
define_macros = define_macros, define_macros = define_macros,
extra_compile_args = extra_compile_args,
include_dirs = expat_inc, include_dirs = expat_inc,
libraries = expat_lib, libraries = expat_lib,
sources = ['pyexpat.c'] + expat_sources, sources = ['pyexpat.c'] + expat_sources,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment