Skip to content

Commit dedcbee

Browse files
authored
[3.6] bpo-30923, bpo-31279: Fix GCC warnings (#4620)
* bpo-30923: Silence fall-through warnings in libexpat build. (#3205) (cherry picked from commit 9e1e6f5) * bpo-31279: Silence -Wstringop-overflow warning. (#3207) (cherry picked from commit dce6502)
1 parent 06be9da commit dedcbee

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Objects/bytearrayobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ PyByteArray_Resize(PyObject *self, Py_ssize_t requested_size)
244244
return -1;
245245
}
246246
memcpy(sval, PyByteArray_AS_STRING(self),
247-
Py_MIN(requested_size, Py_SIZE(self)));
247+
Py_MIN((size_t)requested_size, (size_t)Py_SIZE(self)));
248248
PyObject_Free(obj->ob_bytes);
249249
}
250250
else {

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ class db_found(Exception): pass
15261526
if '--with-system-expat' in sysconfig.get_config_var("CONFIG_ARGS"):
15271527
expat_inc = []
15281528
define_macros = []
1529+
extra_compile_args = []
15291530
expat_lib = ['expat']
15301531
expat_sources = []
15311532
expat_depends = []
@@ -1537,6 +1538,7 @@ class db_found(Exception): pass
15371538
# call XML_SetHashSalt(), expat entropy sources are not needed
15381539
('XML_POOR_ENTROPY', '1'),
15391540
]
1541+
extra_compile_args = []
15401542
expat_lib = []
15411543
expat_sources = ['expat/xmlparse.c',
15421544
'expat/xmlrole.c',
@@ -1554,8 +1556,15 @@ class db_found(Exception): pass
15541556
'expat/xmltok_impl.h'
15551557
]
15561558

1559+
cc = sysconfig.get_config_var('CC').split()[0]
1560+
ret = os.system(
1561+
'"%s" -Werror -Wimplicit-fallthrough -E -xc /dev/null >/dev/null 2>&1' % cc)
1562+
if ret >> 8 == 0:
1563+
extra_compile_args.append('-Wno-implicit-fallthrough')
1564+
15571565
exts.append(Extension('pyexpat',
15581566
define_macros = define_macros,
1567+
extra_compile_args = extra_compile_args,
15591568
include_dirs = expat_inc,
15601569
libraries = expat_lib,
15611570
sources = ['pyexpat.c'] + expat_sources,

0 commit comments

Comments
 (0)