Skip to content

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

Closed

Description

@zikcheng

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

Activity

  1. added
    pending
    on May 22, 2022
  2. erlend-aasland commented on May 22, 2022

    @erlend-aasland
    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.

  3. erlend-aasland commented on May 22, 2022

    @erlend-aasland
    Contributor
  4. added
    interpreter-core
    on May 22, 2022
  5. erlend-aasland commented on May 22, 2022

    @erlend-aasland
    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)

  6. erlend-aasland commented on May 22, 2022

    @erlend-aasland
    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.

  7. added and removed
    pending
    on May 22, 2022
  8. 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`.[/+] on May 22, 2022
  9. zikcheng commented on May 23, 2022

    @zikcheng
    ContributorAuthor

    Why wrapping instead of removing, is it a convention?

  10. vstinner commented on May 23, 2022

    @vstinner
    Member

    Why wrapping instead of removing, is it a convention?

    The ctx parameter is part of PEP 445 API.

  11. added a commit that references this issue on May 25, 2022
  12. kumaraditya303 commented on May 25, 2022

    @kumaraditya303
    Contributor

    Fixed by #93175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    easyinterpreter-core

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions