Skip to content

Commit 626d96c

Browse files
authored
Fix compiler warnings, convert them to errors (#1217)
1 parent 50a58d4 commit 626d96c

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

CHANGES/1217.contrib.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix compiler warnings and convert them to errors -- by :user:`asvetlov`.

multidict/_multidict.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ _multidict_extend_parse_args(mod_state *state, PyObject *args, PyObject *kwds,
139139
const char *name, PyObject **parg)
140140
{
141141
Py_ssize_t size = 0;
142-
Py_ssize_t s;
142+
Py_ssize_t s = 0;
143143
if (args) {
144144
s = PyTuple_GET_SIZE(args);
145145
if (s > 1) {

multidict/_multilib/hashtable.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ GROWTH_RATE(MultiDictObject *md)
8686
return md->used * 3;
8787
}
8888

89+
#ifndef NDEBUG
8990
static inline int
9091
_md_check_consistency(MultiDictObject *md, bool update);
9192
static inline int
9293
_md_dump(MultiDictObject *md);
9394

94-
#ifndef NDEBUG
9595
#define ASSERT_CONSISTENT(md, update) assert(_md_check_consistency(md, update))
9696
#else
9797
#define ASSERT_CONSISTENT(md, update) assert(1)
@@ -873,6 +873,8 @@ md_get_one(MultiDictObject *md, PyObject *key, PyObject **ret)
873873
static inline int
874874
md_get_all(MultiDictObject *md, PyObject *key, PyObject **ret)
875875
{
876+
int tmp;
877+
PyObject *value = NULL;
876878
*ret = NULL;
877879

878880
md_finder_t finder = {0};
@@ -887,9 +889,6 @@ md_get_all(MultiDictObject *md, PyObject *key, PyObject **ret)
887889
goto fail;
888890
}
889891

890-
int tmp;
891-
PyObject *value = NULL;
892-
893892
while ((tmp = md_find_next(&finder, NULL, &value)) > 0) {
894893
if (*ret == NULL) {
895894
*ret = PyList_New(1);
@@ -1900,6 +1899,8 @@ md_clear(MultiDictObject *md)
19001899
return 0;
19011900
}
19021901

1902+
#ifndef NDEBUG
1903+
19031904
static inline int
19041905
_md_check_consistency(MultiDictObject *md, bool update)
19051906
{
@@ -1992,6 +1993,7 @@ _md_dump(MultiDictObject *md)
19921993
printf("\n");
19931994
return 1;
19941995
}
1996+
#endif // NDEBUG
19951997

19961998
#ifdef __cplusplus
19971999
}

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
if platform.system() != "Windows":
1616
CFLAGS.extend(
1717
[
18-
"-std=c99",
18+
"-std=c11",
1919
"-Wall",
2020
"-Wsign-compare",
2121
"-Wconversion",
2222
"-fno-strict-aliasing",
23-
"-pedantic",
23+
"-Wno-conversion",
24+
"-Werror",
2425
]
2526
)
2627

0 commit comments

Comments
 (0)