Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13f1410

Browse files
committed
try to work around maybe-uninitialized warning
1 parent 6b67546 commit 13f1410

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tests/test_pythoncapi_compat_cext.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,15 +1428,15 @@ test_long_api(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
14281428

14291429
#if defined(PYTHON3) && !defined(PYPY_VERSION)
14301430
// test import/export API
1431-
digit *digits;
1431+
void *digits;
14321432
PyLongWriter *writer;
14331433
static PyLongExport long_export;
14341434

1435-
writer = PyLongWriter_Create(1, 1, (void**)&digits);
1435+
writer = PyLongWriter_Create(1, 1, &digits);
14361436
PyLongWriter_Discard(writer);
14371437

1438-
writer = PyLongWriter_Create(1, 1, (void**)&digits);
1439-
digits[0] = 123;
1438+
writer = PyLongWriter_Create(1, 1, &digits);
1439+
((digit *)digits)[0] = 123;
14401440
obj = PyLongWriter_Finish(writer);
14411441

14421442
check_int(obj, -123);
@@ -1447,21 +1447,21 @@ test_long_api(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
14471447
Py_DECREF(obj);
14481448

14491449
writer = PyLongWriter_Create(0, 5, (void**)&digits);
1450-
digits[0] = 1;
1451-
digits[1] = 0;
1452-
digits[2] = 0;
1453-
digits[3] = 0;
1454-
digits[4] = 1;
1450+
((digit *)digits)[0] = 1;
1451+
((digit *)digits)[1] = 0;
1452+
((digit *)digits)[2] = 0;
1453+
((digit *)digits)[3] = 0;
1454+
((digit *)digits)[4] = 1;
14551455
obj = PyLongWriter_Finish(writer);
14561456

14571457
PyLong_Export(obj, &long_export);
14581458
assert(long_export.value == 0);
1459-
digits = (digit*)long_export.digits;
1460-
assert(digits[0] == 1);
1461-
assert(digits[1] == 0);
1462-
assert(digits[2] == 0);
1463-
assert(digits[3] == 0);
1464-
assert(digits[4] == 1);
1459+
digits = (void*)long_export.digits;
1460+
assert(((digit *)digits)[0] == 1);
1461+
assert(((digit *)digits)[1] == 0);
1462+
assert(((digit *)digits)[2] == 0);
1463+
assert(((digit *)digits)[3] == 0);
1464+
assert(((digit *)digits)[4] == 1);
14651465
PyLong_FreeExport(&long_export);
14661466
Py_DECREF(obj);
14671467

0 commit comments

Comments
 (0)