Closed gperciva closed 2 years ago
Ok, but:
Yes it's the right file. Anything uses asprintf (or relies on code in any other .c
file aside from warnp.c
) should be in sock_util.c
rather than sock.c
.
Function name... hmm. Everything here is sock_addr_
so maybe sock_addr_add_port0
? Or sock_addr_ensure_port
, either works for me.
Everything here is sockaddr so maybe sock_addr_add_port0?
Yes, but everything else acts on struct sock_addr *
; whereas this function only acts on strings.
Everything here is sockaddr so maybe sock_addr_add_port0?
Yes, but everything else acts on
struct sock_addr *
; whereas this function only acts on strings.
Meh. Sure, we're taking a string and returning a string, but it's a string which is going to be passed to other sock_addr_*
functions.
I extracted this from #353, and made a few style fixes and minor code fixes.
I'm not certain about the name. I think it makes sense to be in
sock_util.h
, since we'll need this for both spiped and spipe. I opted forsock_util_
instead ofsock_addr_
since this operates on strings rather thanstruct sock_addr
. However, I kind-of drew a blank for the rest of the name. I ended up with_ensure_port()
, but that was more because I had to name it something.