
Hi Dan I haven't used getnameinfo much, so looked it up and found this: In order to assist the programmer in choosing reasonable sizes for the supplied buffers, <netdb.h> defines the constants # define NI_MAXHOST 1025 # define NI_MAXSERV 32 "Daniel P. Berrange" <berrange@redhat.com> wrote: ...
diff -r 1c3780349e89 qemud/remote.c --- a/qemud/remote.c Wed Nov 28 12:02:28 2007 -0500 +++ b/qemud/remote.c Thu Nov 29 09:24:10 2007 -0500 ... +static char *addrToString(struct qemud_client *client, + remote_message_header *req, + struct sockaddr_storage *sa, socklen_t salen) { + char host[1024], port[20]; + char *addr; + int err; + + if ((err = getnameinfo((struct sockaddr *)sa, salen, + host, sizeof(host), + port, sizeof(port), + NI_NUMERICHOST | NI_NUMERICSERV)) != 0) {
Since it's always good to avoid such literals, how about declaring those locals like this: char host[NI_MAXHOST]; port[NI_MAXSERV]; I see that qemud/remote.c already includes <netdb.h>, but if you're extra cautious, maybe you'd want this: (though NI_MAXHOST is already used in qemud.c, so maybe not): #ifndef NI_MAXHOST # define NI_MAXHOST 1025 #endif #ifndef NI_MAXSERV # define NI_MAXSERV 32 #endif