]> granicus.if.org Git - python/commitdiff
Issue #19418 Fix some warnings on Win64
authorTim Golden <mail@timgolden.me.uk>
Thu, 31 Oct 2013 17:38:24 +0000 (17:38 +0000)
committerTim Golden <mail@timgolden.me.uk>
Thu, 31 Oct 2013 17:38:24 +0000 (17:38 +0000)
Modules/audioop.c

index 7e40bbddc6ddec21d339ffd26e8463cc3b781c30..3f047623ebb25a851568b3df3a60545732cf85e3 100644 (file)
@@ -27,7 +27,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
@@ -385,7 +386,9 @@ audioop_minmax(PyObject *self, PyObject *args)
     signed char *cp;
     Py_ssize_t len, i;
     int size, val = 0;
-    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;