HomeClusterLabs Projects

Refactor: various: Use -1 consistently for uninitialized/invalid socket

Description

Refactor: various: Use -1 consistently for uninitialized/invalid socket

System calls that create a socket (for example, socket(), accept())
return -1 to indicate error. 0 is technically a valid socket file
descriptor, even if it's unlikely to be encountered in practice because
0 is typically used for stdin. So we want to set socket file descriptor
variables to -1 if they're uninitialized or if we encountered an error,
and to check them accordingly.

We already did this in some places (for example, remoted_tls.c).

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>

Details

Provenance
nrwahl2Authored on Wed, Jan 8, 3:41 AM
Parents
rPc366b706f2e8: Refactor: based: Assert on int allocation for socket
Branches
Unknown
Tags
Unknown