Re: [PATCH v2 10/14] unix-socket: elimiate static unix_stream_socket() helper function
- From
Jeff King <peff@peff.net>
- Date
- Feb 2, 2021, 09:54 UTC
- Message-ID
- <YBkhTdodhWkW9bF4@coredump.intra.peff.net>
- In-Reply-To
- <f5d5445cf42e2f107c5f137922e9887ea46d730d.1612208747.git.gitgitgadget@gmail.com>
On Mon, Feb 01, 2021 at 07:45:43PM +0000, Jeff Hostetler via GitGitGadget wrote:
Show 6 quoted lines
> From: Jeff Hostetler <jeffhost@microsoft.com> > > The static helper function `unix_stream_socket()` calls `die()`. This is not > appropriate for all callers. Eliminate the wrapper function and move the > existing error handling to the callers in preparation for adapting specific > callers.
Thanks, this looks good.
Show 7 quoted lines
> -static int unix_stream_socket(void)
> -{
> - int fd = socket(AF_UNIX, SOCK_STREAM, 0);
> - if (fd < 0)
> - die_errno("unable to create socket");
> - return fd;
> -}This could become a one-liner:
return socket(AF_UNIX, SOCK_STREAM, 0);
to keep the details abstracted. But it's local to this file, the callers are already necessarily full of bsd-socket arcana, and it's not like the magic words there have ever changed in 30+ years. Putting it inline seems quite reasonable. :)
-Peff