summaryrefslogtreecommitdiffstats
path: root/Python/tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2025-03-22 09:38:47 (GMT)
committerGitHub <noreply@github.com>2025-03-22 09:38:47 (GMT)
commit996246994341c91308364f3ed018cf9b7fec9bc8 (patch)
treeb43e0f9644444ac8280fc7f0aa77f4d2e53c51af /Python/tracemalloc.c
parent8b7d20d3a9dc53344e3803507deafc26b5c09ca8 (diff)
downloadcpython-996246994341c91308364f3ed018cf9b7fec9bc8.zip
cpython-996246994341c91308364f3ed018cf9b7fec9bc8.tar.gz
cpython-996246994341c91308364f3ed018cf9b7fec9bc8.tar.bz2
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.
Diffstat (limited to 'Python/tracemalloc.c')
-rw-r--r--Python/tracemalloc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/tracemalloc.c b/Python/tracemalloc.c
index 2bdb6c3..7066a21 100644
--- a/Python/tracemalloc.c
+++ b/Python/tracemalloc.c
@@ -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
@@ -791,9 +788,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;
}