Skip to content

Improve C function signatures for const-correctness and type safety#14

Merged
micheloosterhof merged 2 commits intomainfrom
claude/improve-c-function-signatures-0xCOU
Feb 11, 2026
Merged

Improve C function signatures for const-correctness and type safety#14
micheloosterhof merged 2 commits intomainfrom
claude/improve-c-function-signatures-0xCOU

Conversation

@micheloosterhof
Copy link
Member

@micheloosterhof micheloosterhof commented Feb 11, 2026

  • Add const to pointer parameters not modified by callee: bistream_data_add,
    ihandler_new, node_info_set_addr, tempfile_new, tempdownload_new, and all
    processor_io function signatures
  • Return const char* from node_info_get_ip_string/node_info_get_port_string
    to prevent callers from modifying internal buffers
  • Accept const struct node_info* in getter functions that don't mutate state
  • Change IPv6 address check functions (ipv6_addr_linklocal, ipv6_addr_v4mapped,
    ipv6_addr_any, ipv6_addr_loopback) from int to bool return type
  • Fix bistream_new() definition to use (void) parameter list matching its
    header declaration
  • Update processor_io typedef and all implementing functions to use
    const void *data since I/O processors read but don't modify the data
  • Update Cython binding declarations in binding.pyx to match the new C
    signatures

- Add const to pointer parameters not modified by callee: bistream_data_add,
  ihandler_new, node_info_set_addr, tempfile_new, tempdownload_new, and all
  processor_io function signatures
- Return const char* from node_info_get_ip_string/node_info_get_port_string
  to prevent callers from modifying internal buffers
- Accept const struct node_info* in getter functions that don't mutate state
- Change IPv6 address check functions (ipv6_addr_linklocal, ipv6_addr_v4mapped,
  ipv6_addr_any, ipv6_addr_loopback) from int to bool return type
- Fix bistream_new() definition to use (void) parameter list matching its
  header declaration
- Update processor_io typedef and all implementing functions to use
  const void *data since I/O processors read but don't modify the data
- Update Cython binding declarations in binding.pyx to match the new C
  signatures

https://claude.ai/code/session_016apEwLpwZvcWbQBmcLiosm
…(pass 2)

- recvfromto(): Remove incorrect const from fromaddr/toaddr output parameters
  that are written to by recvmsg() and memcpy()
- sendtofrom(): Add const to buf, to, and from parameters (read-only inputs)
- add_ext() in ssl.c: Change value parameter to const char* (passed to
  OpenSSL which accepts const char*)
- pchild_sent_bind(): Add const to sockaddr parameter (only read via memcpy)
- pchild_new(): Fix empty parameter list () to (void) for proper C prototype

https://claude.ai/code/session_016apEwLpwZvcWbQBmcLiosm
@micheloosterhof micheloosterhof merged commit ce91b03 into main Feb 11, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants