8000 gh-131296: fix clang-cl warning in tracemalloc.c (#131514) · python/cpython@9962469 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9962469

Browse files
authored
gh-131296: fix clang-cl warning in tracemalloc.c (#131514)
Always set MAX_NFRAME to UINT16_MAX. Avoid the complicated code which emitted a compiler warning.
1 parent 8b7d20d commit 9962469

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Python/tracemalloc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ typedef struct tracemalloc_traceback traceback_t;
4848
#define TRACEBACK_SIZE(NFRAME) \
4949
(sizeof(traceback_t) + sizeof(frame_t) * (NFRAME - 1))
5050

51-
/* The maximum number of frames is either:
52-
- The maximum number of frames we can store in `traceback_t.nframe`
53-
- 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));
51+
static const int MAX_NFRAME = UINT16_MAX;
5552

5653

5754
#define tracemalloc_empty_traceback _PyRuntime.tracemalloc.empty_traceback
@@ -791,9 +788,9 @@ tracemalloc_deinit(void)
791788
int
792789
_PyTraceMalloc_Start(int max_nframe)
793790
{
794-
if (max_nframe < 1 || (unsigned long) max_nframe > MAX_NFRAME) {
791+
if (max_nframe < 1 || max_nframe > MAX_NFRAME) {
795792
PyErr_Format(PyExc_ValueError,
796-
"the number of frames must be in range [1; %lu]",
793+
"the number of frames must be in range [1; %i]",
797794
MAX_NFRAME);
798795
return -1;
799796
}

0 commit comments

Comments
 (0)
0