[libvirt] [PATCH v2 1/6] qemu: command: Rename and move qemuNetworkDriveGetPort

Peter Krempa pkrempa at redhat.com
Mon Jul 24 08:43:29 UTC 2017


On Fri, Jul 21, 2017 at 07:58:52 -0400, John Ferlan wrote:
> [...]
> 
> Before it's too late...
> 
> > +
> > +/**
> > + * virStringParsePort:
> > + * @str: port number to parse
> > + * @port: pointer to parse port into
> > + *
> > + * Parses a string representation of a network port and validates it. Returns
> > + * 0 on success and -1 on error.
> > + */
> > +int
> > +virStringParsePort(const char *str,
> > +                   int *port)
> > +{
> > +    unsigned int p = 0;
> > +
> > +    *port = 0;
> > +
> > +    if (!str)
> > +        return 0;
> > +
> > +    if (virStrToLong_uip(str, NULL, 10, &p) < 0) {
> > +        virReportError(VIR_ERR_INVALID_ARG,
> > +                       _("failed to parse port number '%s'"), str);
> > +        return -1;
> > +    }
> > +
> > +    if (p > 65535) {
> 
> Should this be UINT16_MAX ?

Yup. RFC 791 describes it as 16 bits.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170724/90a15f72/attachment-0001.sig>


More information about the libvir-list mailing list