Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wrap unused arguments in Objects/obmalloc.c with Py_UNUSED. #93040

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

Closed
zikcheng opened this issue May 21, 2022 · 7 comments
Closed

Wrap unused arguments in Objects/obmalloc.c with Py_UNUSED. #93040

zikcheng opened this issue May 21, 2022 · 7 comments
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@zikcheng
Copy link
Contributor

As the title says, parameter ctx is not used in body of function pymalloc_alloc and pymalloc_free.

@erlend-aasland erlend-aasland added the pending The issue will be closed if no feedback is provided label May 22, 2022
@erlend-aasland
Copy link
Contributor

You'll find there's a lot of unused arguments in the CPython code base. We could wrap these two in Py_UNUSED, but there would be a lot left, so I don't see a particular reason to just change these two.

Suggesting to close this.

@erlend-aasland
Copy link
Contributor

cc. @vstinner

@erlend-aasland erlend-aasland added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 22, 2022
@erlend-aasland
Copy link
Contributor

FTR:

cpython/Objects/obmalloc.c

Lines 1947 to 1948 in e5d8dbd

static inline void*
pymalloc_alloc(void *ctx, size_t nbytes)

cpython/Objects/obmalloc.c

Lines 2217 to 2218 in e5d8dbd

static inline int
pymalloc_free(void *ctx, void *p)

@erlend-aasland
Copy link
Contributor

The following functions in obmalloc.c have one or more unused arguments:

  • _PyMem_RawMalloc
  • _PyMem_RawCalloc
  • _PyMem_RawRealloc
  • _PyMem_RawFree
  • _PyObject_ArenaVirtualAlloc
  • _PyObject_ArenaVirtualFree
  • _PyObject_ArenaMmap
  • _PyObject_ArenaMunmap
  • _PyObject_ArenaMalloc
  • _PyObject_ArenaFree
  • address_in_range
  • pymalloc_alloc
  • pymalloc_free

Victor says he's +1 on wrapping unused arguments with Py_UNUSED.

@erlend-aasland erlend-aasland added easy and removed pending The issue will be closed if no feedback is provided labels May 22, 2022
@erlend-aasland erlend-aasland changed the title Parameter ctx is not used in function pymalloc_alloc and pymalloc_free Wrap unused arguments in Objects/obmalloc.c with Py_UNUSED. May 22, 2022
@zikcheng
Copy link
Contributor Author

Why wrapping instead of removing, is it a convention?

@vstinner
Copy link
Member

Why wrapping instead of removing, is it a convention?

The ctx parameter is part of PEP 445 API.

@kumaraditya303
Copy link
Contributor

Fixed by #93175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

4 participants