Fix some warnings produced by different compilers. (GH-5593) (GH-5600)

(cherry picked from commit bfe4fd5f2e96e72eecb5b8a0c7df0ac1689f3b7e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
index 328ab92..bfa8bb3 100644
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -53,6 +53,12 @@
 #endif
 
 
+/* Disable warning that is part of -Wextra since gcc 7.0. */
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER) && __GNUC__ >= 7
+  #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+
+
 #if defined(_MSC_VER)
   #define ALWAYS_INLINE __forceinline
 #elif defined(LEGACY_COMPILER)
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 474c1c9..7fc3d87 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4867,7 +4867,9 @@
             if (type == -1) {
                 int tmp;
                 socklen_t slen = sizeof(tmp);
-                if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &tmp, &slen) == 0) {
+                if (getsockopt(fd, SOL_SOCKET, SO_TYPE,
+                               (void *)&tmp, &slen) == 0)
+                {
                     type = tmp;
                 } else {
 #ifdef MS_WINDOWS
@@ -4885,7 +4887,9 @@
             if (proto == -1) {
                 int tmp;
                 socklen_t slen = sizeof(tmp);
-                if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL, &tmp, &slen) == 0) {
+                if (getsockopt(fd, SOL_SOCKET, SO_PROTOCOL,
+                               (void *)&tmp, &slen) == 0)
+                {
                     proto = tmp;
                 } else {
 #ifdef MS_WINDOWS
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index b17ab5a..998216c 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -1192,11 +1192,13 @@
             if (freq != -1) {
                 /* check that _PyTime_MulDiv(t, SEC_TO_NS, ticks_per_second)
                    cannot overflow below */
+#if LONG_MAX > _PyTime_MAX / SEC_TO_NS
                 if ((_PyTime_t)freq > _PyTime_MAX / SEC_TO_NS) {
                     PyErr_SetString(PyExc_OverflowError,
                                     "_SC_CLK_TCK is too large");
                     return -1;
                 }
+#endif
 
                 ticks_per_second = freq;
             }
diff --git a/Python/context.c b/Python/context.c
index 2034a20..b727748 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -8,7 +8,7 @@
 
 #define CONTEXT_FREELIST_MAXLEN 255
 static PyContext *ctx_freelist = NULL;
-static Py_ssize_t ctx_freelist_len = 0;
+static int ctx_freelist_len = 0;
 
 
 #include "clinic/context.c.h"
@@ -1177,7 +1177,7 @@
 int
 PyContext_ClearFreeList(void)
 {
-    Py_ssize_t size = ctx_freelist_len;
+    int size = ctx_freelist_len;
     while (ctx_freelist_len) {
         PyContext *ctx = ctx_freelist;
         ctx_freelist = (PyContext *)ctx->ctx_weakreflist;
diff --git a/Python/hamt.c b/Python/hamt.c
index c9acbbc..e54d3a4 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -729,7 +729,7 @@
         uint32_t key_idx = 2 * idx;
         uint32_t val_idx = key_idx + 1;
 
-        assert(val_idx < Py_SIZE(self));
+        assert(val_idx < (size_t)Py_SIZE(self));
 
         PyObject *key_or_null = self->b_array[key_idx];
         PyObject *val_or_node = self->b_array[val_idx];
@@ -1123,7 +1123,7 @@
     key_idx = idx * 2;
     val_idx = key_idx + 1;
 
-    assert(val_idx < Py_SIZE(self));
+    assert(val_idx < (size_t)Py_SIZE(self));
 
     key_or_null = self->b_array[key_idx];
     val_or_node = self->b_array[val_idx];
diff --git a/Python/pyhash.c b/Python/pyhash.c
index a0850d0..9e6e594 100644
--- a/Python/pyhash.c
+++ b/Python/pyhash.c
@@ -17,7 +17,7 @@
 extern "C" {
 #endif
 
-_Py_HashSecret_t _Py_HashSecret = {0};
+_Py_HashSecret_t _Py_HashSecret = {{0}};
 
 #if Py_HASH_ALGORITHM == Py_HASH_EXTERNAL
 extern PyHash_FuncDef PyHash_Func;