[libvirt PATCH 3/4] virParseVersionString: rename to virStringParseVersion

Andrea Bolognani abologna at redhat.com
Wed Feb 2 10:23:59 UTC 2022


On Fri, Jan 28, 2022 at 09:58:45PM +0100, Ján Tomko wrote:
> -int virParseVersionString(const char *str,
> -                          unsigned long *version,
> +int virStringParseVersion(unsigned long *version,
> +                          const char *str,
>                            bool allowMissing);

While I agree with renaming the function and moving it to
util/virstring, I think changing the order of arguments the way you
did goes against existing best practices. Compare with the following
signatures:

  int virStrToLong_i(char const *s,
                     char **end_ptr,
                     int base,
                     int *result);

  int virStringParsePort(const char *str,
                         unsigned int *port);

  int virStringParseYesNo(const char *str,
                          bool *result);

So if anything the new signature should look like

  int virStrinParseVersion(const char *str,
                           bool allowMissing,
                           unsigned long *version);

with all input arguments first and the single output argument last.

-- 
Andrea Bolognani / Red Hat / Virtualization





More information about the libvir-list mailing list