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 #17506 (comment)
The whole
php_stdiop_castis a proper mess. It definesphp_socket_t fdbut then it usesPHP_STDIOP_GET_FDwhich is defined aswhich 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 #17506 (comment)