Skip to content

Commit bfe4fd5

Browse files
Fix some warnings produced by different compilers. (#5593)
1 parent 5bb0005 commit bfe4fd5

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

Modules/_decimal/libmpdec/mpdecimal.c

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
#endif
5454

5555

56+
/* Disable warning that is part of -Wextra since gcc 7.0. */
57+
#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && __GNUC__ >= 7
58+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
59+
#endif
60+
61+
5662
#if defined(_MSC_VER)
5763
#define ALWAYS_INLINE __forceinline
5864
#elif defined(LEGACY_COMPILER)

Modules/socketmodule.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -4867,7 +4867,9 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
48674867
if (type == -1) {
48684868
int tmp;
48694869
socklen_t slen = sizeof(tmp);
4870-
if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &tmp, &slen) == 0) {
4870+
if (getsockopt(fd, SOL_SOCKET, SO_TYPE,
4871+
(void *)&tmp, &slen) == 0)
4872+
{
48714873
type = tmp;
48724874
} else {
48734875
#ifdef MS_WINDOWS
@@ -4885,7 +4887,9 @@ sock_initobj(PyObject *self, PyObject *args, PyObject *kwds)
48854887
if (proto == -1) {
48864888
int tmp;
48874889
socklen_t slen = sizeof(tmp);
4888-
if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &tmp, &slen) == 0) {
4890+
if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL,
4891+
(void *)&tmp, &slen) == 0)
4892+
{
48894893
proto = tmp;
48904894
} else {
48914895
#ifdef MS_WINDOWS

Modules/timemodule.c

+2
Original file line numberDiff line numberDiff line change
@@ -1192,11 +1192,13 @@ _PyTime_GetProcessTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
11921192
if (freq != -1) {
11931193
/* check that _PyTime_MulDiv(t, SEC_TO_NS, ticks_per_second)
11941194
cannot overflow below */
1195+
#if LONG_MAX > _PyTime_MAX / SEC_TO_NS
11951196
if ((_PyTime_t)freq > _PyTime_MAX / SEC_TO_NS) {
11961197
PyErr_SetString(PyExc_OverflowError,
11971198
"_SC_CLK_TCK is too large");
11981199
return -1;
11991200
}
1201+
#endif
12001202

12011203
ticks_per_second = freq;
12021204
}

Python/context.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#define CONTEXT_FREELIST_MAXLEN 255
1010
static PyContext *ctx_freelist = NULL;
11-
static Py_ssize_t ctx_freelist_len = 0;
11+
static int ctx_freelist_len = 0;
1212

1313

1414
#include "clinic/context.c.h"
@@ -1177,7 +1177,7 @@ get_token_missing(void)
11771177
int
11781178
PyContext_ClearFreeList(void)
11791179
{
1180-
Py_ssize_t size = ctx_freelist_len;
1180+
int size = ctx_freelist_len;
11811181
while (ctx_freelist_len) {
11821182
PyContext *ctx = ctx_freelist;
11831183
ctx_freelist = (PyContext *)ctx->ctx_weakreflist;

Python/hamt.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ hamt_node_bitmap_assoc(PyHamtNode_Bitmap *self,
729729
uint32_t key_idx = 2 * idx;
730730
uint32_t val_idx = key_idx + 1;
731731

732-
assert(val_idx < Py_SIZE(self));
732+
assert(val_idx < (size_t)Py_SIZE(self));
733733

734734
PyObject *key_or_null = self->b_array[key_idx];
735735
PyObject *val_or_node = self->b_array[val_idx];
@@ -1123,7 +1123,7 @@ hamt_node_bitmap_find(PyHamtNode_Bitmap *self,
11231123
key_idx = idx * 2;
11241124
val_idx = key_idx + 1;
11251125

1126-
assert(val_idx < Py_SIZE(self));
1126+
assert(val_idx < (size_t)Py_SIZE(self));
11271127

11281128
key_or_null = self->b_array[key_idx];
11291129
val_or_node = self->b_array[val_idx];

Python/pyhash.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
extern "C" {
1818
#endif
1919

20-
_Py_HashSecret_t _Py_HashSecret = {0};
20+
_Py_HashSecret_t _Py_HashSecret = {{0}};
2121

2222
#if Py_HASH_ALGORITHM == Py_HASH_EXTERNAL
2323
extern PyHash_FuncDef PyHash_Func;

0 commit comments

Comments
 (0)