[Libvir] PATCH: 1/10: SASL authentication support

Daniel P. Berrange berrange at redhat.com
Thu Nov 29 20:49:38 UTC 2007


On Thu, Nov 29, 2007 at 09:31:50PM +0100, Jim Meyering wrote:
> 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 at 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];

Yep, looks like a good idea.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 




More information about the libvir-list mailing list