summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-06-06 17:51:07 +0200
committerGitHub <noreply@github.com>2018-06-06 17:51:07 +0200
commite5b79c546370521764457ea2ec809303e580f5ea (patch)
treecc32e014e7946c6d93c75d880c0ba42e3633adb2 /Modules
parentb17d409bc0458e3981987c2358da661f228f5891 (diff)
downloadcpython-git-e5b79c546370521764457ea2ec809303e580f5ea.tar.gz
bpo-19418: audioop.c: Fix warnings on -0x80000000 (GH-7453)
bpo-19418, bpo-33781: Fix the following warnings on Windows: Modules\audioop.c(28): warning C4146: unary minus operator applied to unsigned type, result still unsigned Modules\audioop.c(396): warning C4146: unary minus operator applied to unsigned type, result still unsigned
Diffstat (limited to 'Modules')
-rw-r--r--Modules/audioop.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/audioop.c b/Modules/audioop.c
index 4229038494..91f585c8f0 100644
--- a/Modules/audioop.c
+++ b/Modules/audioop.c
@@ -25,7 +25,8 @@ typedef short PyInt16;
#endif
static const int maxvals[] = {0, 0x7F, 0x7FFF, 0x7FFFFF, 0x7FFFFFFF};
-static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x80000000};
+/* -1 trick is needed on Windows to support -0x80000000 without a warning */
+static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x7FFFFFFF-1};
static const unsigned int masks[] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF};
static int
@@ -393,7 +394,9 @@ audioop_minmax(PyObject *self, PyObject *args)
signed char *cp;
int len, size, val = 0;
int i;
- int min = 0x7fffffff, max = -0x80000000;
+ /* -1 trick below is needed on Windows to support -0x80000000 without
+ a warning */
+ int min = 0x7fffffff, max = -0x7FFFFFFF-1;
if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size))
return NULL;