Skip to content

gh-131296: fix clang-cl warning in tracemalloc.c #131514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions Python/tracemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ typedef struct tracemalloc_traceback traceback_t;
#define TRACEBACK_SIZE(NFRAME) \
(sizeof(traceback_t) + sizeof(frame_t) * (NFRAME - 1))

/* The maximum number of frames is either:
- The maximum number of frames we can store in `traceback_t.nframe`
- The maximum memory size_t we can allocate */
static const unsigned long MAX_NFRAME = Py_MIN(UINT16_MAX, ((SIZE_MAX - sizeof(traceback_t)) / sizeof(frame_t) + 1));
static const int MAX_NFRAME = UINT16_MAX;


#define tracemalloc_empty_traceback _PyRuntime.tracemalloc.empty_traceback
Expand Down Expand Up @@ -783,9 +780,9 @@ tracemalloc_deinit(void)
int
_PyTraceMalloc_Start(int max_nframe)
{
if (max_nframe < 1 || (unsigned long) max_nframe > MAX_NFRAME) {
if (max_nframe < 1 || max_nframe > MAX_NFRAME) {
PyErr_Format(PyExc_ValueError,
"the number of frames must be in range [1; %lu]",
"the number of frames must be in range [1; %i]",
MAX_NFRAME);
return -1;
}
Expand Down
Loading