On Thu, May 26, 2016 at 05:40:09PM +0200, Pino Toscano wrote:
 Make use of the common version code, and avoid a separate regexp.
 ---
  src/qemu.c | 22 ++--------------------
  1 file changed, 2 insertions(+), 20 deletions(-)
 
 diff --git a/src/qemu.c b/src/qemu.c
 index 11bf5cf..844c3f0 100644
 --- a/src/qemu.c
 +++ b/src/qemu.c
 @@ -37,16 +37,12 @@
  
  #include <libxml/uri.h>
  
 -#include <pcre.h>
 -
  #include "ignore-value.h"
  
  #include "guestfs.h"
  #include "guestfs-internal.h"
  #include "guestfs_protocol.h"
  
 -COMPILE_REGEXP (re_major_minor, "(\\d+)\\.(\\d+)", 0)
 -
  struct qemu_data {
    char *qemu_help;              /* Output of qemu -help. */
    char *qemu_devices;           /* Output of qemu -device ? */
 @@ -265,29 +261,15 @@ static void
  parse_qemu_version (guestfs_h *g, const char *qemu_help,
                      struct version *qemu_version)
  {
 -  CLEANUP_FREE char *major_s = NULL, *minor_s = NULL;
 -  int major_i, minor_i;
 -
    version_init_null (qemu_version);
  
 -  if (!match2 (g, qemu_help, re_major_minor, &major_s, &minor_s)) {
 -  parse_failed:
 +  if (guestfs_int_version_from_x_y (g, qemu_version, qemu_help) < 1) {
      debug (g, "%s: failed to parse qemu version string from the first line of the
output of '%s -help'.  When reporting this bug please include the -help
output.",
             __func__, g->hv);
      return;
    }
  
 -  major_i = guestfs_int_parse_unsigned_int (g, major_s);
 -  if (major_i == -1)
 -    goto parse_failed;
 -
 -  minor_i = guestfs_int_parse_unsigned_int (g, minor_s);
 -  if (minor_i == -1)
 -    goto parse_failed;
 -
 -  guestfs_int_version_from_values (qemu_version, major_i, minor_i, 0);
 -
 -  debug (g, "qemu version %d.%d", major_i, minor_i);
 +  debug (g, "qemu version %d.%d", qemu_version->v_major,
qemu_version->v_minor);
  }
  
  static void
 -- 
 2.5.5 
ACK.
Rich.
-- 
Richard Jones, Virtualization Group, Red Hat 
http://people.redhat.com/~rjones
Read my programming and virtualization blog: 
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html