Cleaning up types in php_stdiop_cast
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
The whole php_stdiop_cast is a proper mess. It defines php_socket_t fd but then it uses PHP_STDIOP_GET_FD which is defined as
#define PHP_STDIOP_GET_FD(anfd, data) anfd = (data)->file ? fileno((data)->file) : (data)->fd
which is actually always int. I assume that there are some users (external code) that casting and assume that php_socket_t is returned but I think this is incorrect and they should not assume that and it should be fixed there using proper casting. That would leave plain wrapper operating just on fd which is what I think it should.
Then why does it need to even SOCK_ERR here if it's not for socket in the first place? I think it should be redefined just to -1 or some new macro created (e.g. PHP_FD_ERR).
Originally posted by @bukka in https://github.com/php/php-src/pull/17506#discussion_r1921536084
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at php_stdiop_cast and the PHP_STDIOP_GET_FD definition, then trace callers and uses of SOCK_ERR; the issue names no file or test. Done means the wrapper uses a consistent file-descriptor type and error sentinel without relying on an unsupported external cast assumption, with affected compatibility expectations checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend, operating-systems
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100