We're going to use compare() from multiple source files, going forward, so
move it to "utils.c". While at it, rename it to compare_strings(). No
functional changes.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2124538
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 p2v.h   |  1 +
 main.c  | 14 +++-----------
 utils.c |  8 ++++++++
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/p2v.h b/p2v.h
index 32dc55d94de5..e91c47c36428 100644
--- a/p2v.h
+++ b/p2v.h
@@ -128,6 +128,7 @@ extern char *get_blockdev_serial (const char *dev);
 extern char *get_if_addr (const char *if_name);
 extern char *get_if_vendor (const char *if_name, int truncate);
 extern void wait_network_online (const struct config *);
+extern int compare_strings (const void *vp1, const void *vp2);
 
 /* virt-v2v version and features (read from remote). */
 extern char *v2v_version;
diff --git a/main.c b/main.c
index 8a93f9eb402b..ef191e9e34be 100644
--- a/main.c
+++ b/main.c
@@ -372,14 +372,6 @@ set_config_defaults (struct config *config)
   config->output.storage = strdup ("/var/tmp");
 }
 
-static int
-compare (const void *vp1, const void *vp2)
-{
-  char * const *p1 = (char * const *) vp1;
-  char * const *p2 = (char * const *) vp2;
-  return strcmp (*p1, *p2);
-}
-
 /**
  * Get parent device of a partition.
  *
@@ -520,9 +512,9 @@ find_all_disks (void)
     error (EXIT_FAILURE, errno, "closedir: %s", "/sys/block");
 
   if (all_disks)
-    qsort (all_disks, nr_disks, sizeof (char *), compare);
+    qsort (all_disks, nr_disks, sizeof (char *), compare_strings);
   if (all_removable)
-    qsort (all_removable, nr_removable, sizeof (char *), compare);
+    qsort (all_removable, nr_removable, sizeof (char *), compare_strings);
 }
 
 /**
@@ -576,5 +568,5 @@ find_all_interfaces (void)
     error (EXIT_FAILURE, errno, "closedir: %s", "/sys/class/net");
 
   if (all_interfaces)
-    qsort (all_interfaces, nr_interfaces, sizeof (char *), compare);
+    qsort (all_interfaces, nr_interfaces, sizeof (char *), compare_strings);
 }
diff --git a/utils.c b/utils.c
index 932c1c1dd50f..8915871f591e 100644
--- a/utils.c
+++ b/utils.c
@@ -253,3 +253,11 @@ wait_network_online (const struct config *config)
 
   ignore_value (system (NETWORK_ONLINE_COMMAND));
 }
+
+int
+compare_strings (const void *vp1, const void *vp2)
+{
+  char * const *p1 = (char * const *) vp1;
+  char * const *p2 = (char * const *) vp2;
+  return strcmp (*p1, *p2);
+}

_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to