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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[...]

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 ?


> +        virReportError(VIR_ERR_INVALID_ARG,
> +                       _("port '%s' out of range"), str);
> +        return -1;
> +    }
> +
> +    *port = p;
> +
> +    return 0;
> +}

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux