Skip to content

Commit dc2567a

Browse files
committed
gh-131296: fix clang-cl warning in tracemalloc.c
Change MAX_NFRAME type from 'unsigned long' to size_t. On Windows 64-bit, 'unsigned long' is only 32-bit, whereas size_t is 64-bit.
1 parent 486d537 commit dc2567a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Python/tracemalloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef struct tracemalloc_traceback traceback_t;
5151
/* The maximum number of frames is either:
5252
- The maximum number of frames we can store in `traceback_t.nframe`
5353
- The maximum memory size_t we can allocate */
54-
static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1));
54+
static const size_t MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1));
5555

5656

5757
#define tracemalloc_empty_traceback _PyRuntime.tracemalloc.empty_traceback
@@ -783,9 +783,9 @@ tracemalloc_deinit(void)
783783
int
784784
_PyTraceMalloc_Start(int max_nframe)
785785
{
786-
if (max_nframe < 1 || (unsigned long) max_nframe > MAX_NFRAME) {
786+
if (max_nframe < 1 || (size_t)max_nframe > MAX_NFRAME) {
787787
PyErr_Format(PyExc_ValueError,
788-
"the number of frames must be in range [1; %lu]",
788+
"the number of frames must be in range [1; %zu]",
789789
MAX_NFRAME);
790790
return -1;
791791
}

0 commit comments

Comments
 (0)