Skip to content

Commit e5b79c5

Browse files
authored
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
1 parent b17d409 commit e5b79c5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Modules/audioop.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ typedef short PyInt16;
2525
#endif
2626

2727
static const int maxvals[] = {0, 0x7F, 0x7FFF, 0x7FFFFF, 0x7FFFFFFF};
28-
static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x80000000};
28+
/* -1 trick is needed on Windows to support -0x80000000 without a warning */
29+
static const int minvals[] = {0, -0x80, -0x8000, -0x800000, -0x7FFFFFFF-1};
2930
static const unsigned int masks[] = {0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF};
3031

3132
static int
@@ -393,7 +394,9 @@ audioop_minmax(PyObject *self, PyObject *args)
393394
signed char *cp;
394395
int len, size, val = 0;
395396
int i;
396-
int min = 0x7fffffff, max = -0x80000000;
397+
/* -1 trick below is needed on Windows to support -0x80000000 without
398+
a warning */
399+
int min = 0x7fffffff, max = -0x7FFFFFFF-1;
397400

398401
if (!PyArg_ParseTuple(args, "s#i:minmax", &cp, &len, &size))
399402
return NULL;

0 commit comments

Comments
 (0)