From 9485a0dbddcee014821b41c960133632bb68b33c Mon Sep 17 00:00:00 2001 From: oda-gitso <105083118+oda-gitso@users.noreply.github.com> Date: Wed, 25 May 2022 17:39:06 +0700 Subject: [PATCH] gh-93040 Wrap unused parameters in Objects/obmalloc.c with Py_UNUSED (#93175) --- ...2-05-24-14-35-48.gh-issue-93040.9X6Ofu.rst | 1 + Objects/obmalloc.c | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-05-24-14-35-48.gh-issue-93040.9X6Ofu.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-05-24-14-35-48.gh-issue-93040.9X6Ofu.rst b/Misc/NEWS.d/next/Core and Builtins/2022-05-24-14-35-48.gh-issue-93040.9X6Ofu.rst new file mode 100644 index 00000000000..b2e527446ea --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-05-24-14-35-48.gh-issue-93040.9X6Ofu.rst @@ -0,0 +1 @@ +Wraps unused parameters in ``Objects/obmalloc.c`` with ``Py_UNUSED``. diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c index 823855ca6d8..78a6f01a096 100644 --- a/Objects/obmalloc.c +++ b/Objects/obmalloc.c @@ -90,7 +90,7 @@ struct _PyTraceMalloc_Config _Py_tracemalloc_config = _PyTraceMalloc_Config_INIT static void * -_PyMem_RawMalloc(void *ctx, size_t size) +_PyMem_RawMalloc(void *Py_UNUSED(ctx), size_t size) { /* PyMem_RawMalloc(0) means malloc(1). Some systems would return NULL for malloc(0), which would be treated as an error. Some platforms would @@ -102,7 +102,7 @@ _PyMem_RawMalloc(void *ctx, size_t size) } static void * -_PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize) +_PyMem_RawCalloc(void *Py_UNUSED(ctx), size_t nelem, size_t elsize) { /* PyMem_RawCalloc(0, 0) means calloc(1, 1). Some systems would return NULL for calloc(0, 0), which would be treated as an error. Some platforms @@ -116,7 +116,7 @@ _PyMem_RawCalloc(void *ctx, size_t nelem, size_t elsize) } static void * -_PyMem_RawRealloc(void *ctx, void *ptr, size_t size) +_PyMem_RawRealloc(void *Py_UNUSED(ctx), void *ptr, size_t size) { if (size == 0) size = 1; @@ -124,7 +124,7 @@ _PyMem_RawRealloc(void *ctx, void *ptr, size_t size) } static void -_PyMem_RawFree(void *ctx, void *ptr) +_PyMem_RawFree(void *Py_UNUSED(ctx), void *ptr) { free(ptr); } @@ -132,21 +132,22 @@ _PyMem_RawFree(void *ctx, void *ptr) #ifdef MS_WINDOWS static void * -_PyObject_ArenaVirtualAlloc(void *ctx, size_t size) +_PyObject_ArenaVirtualAlloc(void *Py_UNUSED(ctx), size_t size) { return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); } static void -_PyObject_ArenaVirtualFree(void *ctx, void *ptr, size_t size) +_PyObject_ArenaVirtualFree(void *Py_UNUSED(ctx), void *ptr, + size_t Py_UNUSED(size)) { VirtualFree(ptr, 0, MEM_RELEASE); } #elif defined(ARENAS_USE_MMAP) static void * -_PyObject_ArenaMmap(void *ctx, size_t size) +_PyObject_ArenaMmap(void *Py_UNUSED(ctx), size_t size) { void *ptr; ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, @@ -158,20 +159,20 @@ _PyObject_ArenaMmap(void *ctx, size_t size) } static void -_PyObject_ArenaMunmap(void *ctx, void *ptr, size_t size) +_PyObject_ArenaMunmap(void *Py_UNUSED(ctx), void *ptr, size_t size) { munmap(ptr, size); } #else static void * -_PyObject_ArenaMalloc(void *ctx, size_t size) +_PyObject_ArenaMalloc(void *Py_UNUSED(ctx), size_t size) { return malloc(size); } static void -_PyObject_ArenaFree(void *ctx, void *ptr, size_t size) +_PyObject_ArenaFree(void *Py_UNUSED(ctx), void *ptr, size_t Py_UNUSED(size)) { free(ptr); } @@ -1684,7 +1685,7 @@ new_arena(void) pymalloc. When the radix tree is used, 'poolp' is unused. */ static bool -address_in_range(void *p, poolp pool) +address_in_range(void *p, poolp Py_UNUSED(pool)) { return arena_map_is_used(p); } @@ -1945,7 +1946,7 @@ allocate_from_new_pool(uint size) or when the max memory limit has been reached. */ static inline void* -pymalloc_alloc(void *ctx, size_t nbytes) +pymalloc_alloc(void *Py_UNUSED(ctx), size_t nbytes) { #ifdef WITH_VALGRIND if (UNLIKELY(running_on_valgrind == -1)) { @@ -2215,7 +2216,7 @@ insert_to_freepool(poolp pool) Return 1 if it was freed. Return 0 if the block was not allocated by pymalloc_alloc(). */ static inline int -pymalloc_free(void *ctx, void *p) +pymalloc_free(void *Py_UNUSED(ctx), void *p) { assert(p != NULL);