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

[Libguestfs] [p2v PATCH 3/6] Use g_get_prgname instead of getprogname from gnulib



Since main() calls gtk_init(), then g_get_prgname() returns the name of
the current program, much like getprogname().
---
 conversion.c     |  5 ++---
 cpuid.c          |  1 -
 gui.c            | 11 +++++------
 kernel-cmdline.c |  4 +---
 kernel.c         | 10 ++++------
 main.c           | 11 +++++------
 nbd.c            | 10 ++++------
 physical-xml.c   |  4 +---
 rtc.c            | 13 ++++++-------
 ssh.c            |  9 ++++-----
 10 files changed, 32 insertions(+), 46 deletions(-)

diff --git a/conversion.c b/conversion.c
index d7e91a8..8daa1d9 100644
--- a/conversion.c
+++ b/conversion.c
@@ -50,7 +50,6 @@
 #include <pthread.h>
 
 #include "ignore-value.h"
-#include "getprogname.h"
 
 #include "miniexpect.h"
 #include "p2v.h"
@@ -269,7 +268,7 @@ start_conversion (struct config *config,
 #if DEBUG_STDERR
     fprintf (stderr,
              "%s: data connection for %s: SSH remote port %d, local port %s:%d\n",
-             getprogname (), device,
+             g_get_prgname (), device,
              data_conns[i].nbd_remote_port,
              nbd_local_ipaddr, nbd_local_port);
 #endif
@@ -665,6 +664,6 @@ generate_p2v_version_file (const char *p2v_version_file)
     return;                     /* non-fatal */
   }
   fprintf (fp, "%s %s\n",
-           getprogname (), PACKAGE_VERSION_FULL);
+           g_get_prgname (), PACKAGE_VERSION_FULL);
   fclose (fp);
 }
diff --git a/cpuid.c b/cpuid.c
index ca000e1..84603bb 100644
--- a/cpuid.c
+++ b/cpuid.c
@@ -39,7 +39,6 @@
 #include <error.h>
 #include <libintl.h>
 
-#include "getprogname.h"
 #include "ignore-value.h"
 
 #include "p2v.h"
diff --git a/gui.c b/gui.c
index 3463637..227e41d 100644
--- a/gui.c
+++ b/gui.c
@@ -82,7 +82,6 @@
 #pragma GCC diagnostic pop
 
 #include "ignore-value.h"
-#include "getprogname.h"
 
 #include "p2v.h"
 
@@ -213,7 +212,7 @@ create_connection_dialog (struct config *config)
   char port_str[64];
 
   conn_dlg = gtk_dialog_new ();
-  gtk_window_set_title (GTK_WINDOW (conn_dlg), getprogname ());
+  gtk_window_set_title (GTK_WINDOW (conn_dlg), g_get_prgname ());
   gtk_window_set_resizable (GTK_WINDOW (conn_dlg), FALSE);
 
   /* The main dialog area. */
@@ -638,7 +637,7 @@ about_button_clicked (GtkWidget *w, gpointer data)
   dialog = gtk_about_dialog_new ();
 
   g_object_set (G_OBJECT (dialog),
-                "program-name", getprogname (),
+                "program-name", g_get_prgname (),
                 "version", PACKAGE_VERSION_FULL " (" host_cpu ")",
                 "copyright", "\u00A9 2009-2019 Red Hat Inc.",
                 "comments",
@@ -732,7 +731,7 @@ create_conversion_dialog (struct config *config)
   char memory_str[64];
 
   conv_dlg = gtk_dialog_new ();
-  gtk_window_set_title (GTK_WINDOW (conv_dlg), getprogname ());
+  gtk_window_set_title (GTK_WINDOW (conv_dlg), g_get_prgname ());
   gtk_window_set_resizable (GTK_WINDOW (conv_dlg), FALSE);
   /* XXX It would be nice not to have to set this explicitly, but
    * if we don't then Gtk chooses a very small window.
@@ -1640,7 +1639,7 @@ create_running_dialog (void)
 #endif
 
   run_dlg = gtk_dialog_new ();
-  gtk_window_set_title (GTK_WINDOW (run_dlg), getprogname ());
+  gtk_window_set_title (GTK_WINDOW (run_dlg), g_get_prgname ());
   gtk_window_set_resizable (GTK_WINDOW (run_dlg), FALSE);
 
   /* The main dialog area. */
@@ -2200,7 +2199,7 @@ notify_ui_callback (int type, const char *data)
   default:
     fprintf (stderr,
              "%s: unknown message during conversion: type=%d data=%s\n",
-             getprogname (), type, data);
+             g_get_prgname (), type, data);
     free (copy);
   }
 }
diff --git a/kernel-cmdline.c b/kernel-cmdline.c
index 008f3f6..33b0e2b 100644
--- a/kernel-cmdline.c
+++ b/kernel-cmdline.c
@@ -28,8 +28,6 @@
 #include <errno.h>
 #include <error.h>
 
-#include "getprogname.h"
-
 #include "p2v.h"
 
 static void
@@ -142,7 +140,7 @@ parse_cmdline_string (const char *cmdline)
     break;
   case VALUE_QUOTED:            /* unterminated key="value" */
     fprintf (stderr, "%s: warning: unterminated quoted string on kernel command line\n",
-             getprogname ());
+             g_get_prgname ());
     add_string (&ret, &len, value, p-value);
   }
 
diff --git a/kernel.c b/kernel.c
index 7adf659..6fe3a6f 100644
--- a/kernel.c
+++ b/kernel.c
@@ -34,8 +34,6 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#include "getprogname.h"
-
 #include "p2v.h"
 
 static void notify_ui_callback (int type, const char *data);
@@ -77,7 +75,7 @@ kernel_conversion (struct config *config, char **cmdline, int cmdline_source)
     const char *err = get_conversion_error ();
 
     fprintf (stderr, "%s: error during conversion: %s\n",
-             getprogname (), err);
+             g_get_prgname (), err);
 
     p = get_cmdline_key (cmdline, "p2v.fail");
     if (p)
@@ -106,7 +104,7 @@ notify_ui_callback (int type, const char *data)
   switch (type) {
   case NOTIFY_LOG_DIR:
     ansi_magenta (stdout);
-    printf ("%s: remote log directory location: ", getprogname ());
+    printf ("%s: remote log directory location: ", g_get_prgname ());
     ansi_red (stdout);
     fputs (data, stdout);
     ansi_restore (stdout);
@@ -119,7 +117,7 @@ notify_ui_callback (int type, const char *data)
 
   case NOTIFY_STATUS:
     ansi_magenta (stdout);
-    printf ("%s: %s", getprogname (), data);
+    printf ("%s: %s", g_get_prgname (), data);
     ansi_restore (stdout);
     putchar ('\n');
     break;
@@ -127,7 +125,7 @@ notify_ui_callback (int type, const char *data)
   default:
     ansi_red (stdout);
     printf ("%s: unknown message during conversion: type=%d data=%s",
-            getprogname (), type, data);
+            g_get_prgname (), type, data);
     ansi_restore (stdout);
     putchar ('\n');
   }
diff --git a/main.c b/main.c
index 9039e82..f8d2aa9 100644
--- a/main.c
+++ b/main.c
@@ -49,7 +49,6 @@
 #pragma GCC diagnostic pop
 
 #include "ignore-value.h"
-#include "getprogname.h"
 #include "p2v.h"
 
 char **all_disks;
@@ -89,7 +88,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try ‘%s --help’ for more information.\n"),
-             getprogname ());
+             g_get_prgname ());
   else {
     printf (_("%s: Convert a physical machine to use KVM\n"
               "Copyright (C) 2009-2019 Red Hat Inc.\n"
@@ -105,8 +104,8 @@ usage (int status)
               "  -v|--verbose           Verbose messages\n"
               "  -V|--version           Display version and exit\n"
               "For more information, see the manpage %s(1).\n"),
-            getprogname (), getprogname (),
-            getprogname ());
+            g_get_prgname (), g_get_prgname (),
+            g_get_prgname ());
   }
   exit (status);
 }
@@ -210,7 +209,7 @@ main (int argc, char *argv[])
       break;
 
     case 'V':
-      printf ("%s %s\n", getprogname (), PACKAGE_VERSION_FULL);
+      printf ("%s %s\n", g_get_prgname (), PACKAGE_VERSION_FULL);
       exit (EXIT_SUCCESS);
 
     case HELP_OPTION:
@@ -223,7 +222,7 @@ main (int argc, char *argv[])
 
   if (optind != argc) {
     fprintf (stderr, _("%s: unused arguments on the command line\n"),
-             getprogname ());
+             g_get_prgname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/nbd.c b/nbd.c
index 3bbde1e..db6228a 100644
--- a/nbd.c
+++ b/nbd.c
@@ -37,8 +37,6 @@
 #include <sys/socket.h>
 #include <assert.h>
 
-#include "getprogname.h"
-
 #include "p2v.h"
 
 /* How long to wait for the NBD server to start (seconds). */
@@ -267,7 +265,7 @@ test_nbd_servers (void)
     fprintf (stderr,
              _("%s: no working NBD server was found, cannot continue.\n"
                "Please check the --nbd option in the virt-p2v(1) man page.\n"),
-             getprogname ());
+             g_get_prgname ());
     exit (EXIT_FAILURE);
   }
 
@@ -582,7 +580,7 @@ bind_tcpip_socket (const char *ipaddr, const char *port,
   if (err != 0) {
 #if DEBUG_STDERR
     fprintf (stderr, "%s: getaddrinfo: %s: %s: %s",
-             getprogname (), ipaddr ? ipaddr : "<any>", port,
+             g_get_prgname (), ipaddr ? ipaddr : "<any>", port,
              gai_strerror (err));
 #endif
     return -1;
@@ -637,7 +635,7 @@ bind_tcpip_socket (const char *ipaddr, const char *port,
   if (nr_fds == 0 && addr_in_use) {
 #if DEBUG_STDERR
     fprintf (stderr, "%s: unable to bind to %s:%s: %s\n",
-             getprogname (), ipaddr ? ipaddr : "<any>", port,
+             g_get_prgname (), ipaddr ? ipaddr : "<any>", port,
              strerror (EADDRINUSE));
 #endif
     return -1;
@@ -645,7 +643,7 @@ bind_tcpip_socket (const char *ipaddr, const char *port,
 
 #if DEBUG_STDERR
   fprintf (stderr, "%s: bound to IP address %s:%s (%zu socket(s))\n",
-           getprogname (), ipaddr ? ipaddr : "<any>", port, nr_fds);
+           g_get_prgname (), ipaddr ? ipaddr : "<any>", port, nr_fds);
 #endif
 
   *fds_rtn = fds;
diff --git a/physical-xml.c b/physical-xml.c
index 93cdaa0..4e830ea 100644
--- a/physical-xml.c
+++ b/physical-xml.c
@@ -34,8 +34,6 @@
 
 #include <libxml/xmlwriter.h>
 
-#include "getprogname.h"
-
 #include "libxml2-writer-macros.h"
 
 #include "p2v.h"
@@ -77,7 +75,7 @@ generate_physical_xml (struct config *config, struct data_conn *data_conns,
 
   memkb = config->memory / 1024;
 
-  comment (" %s %s ", getprogname (), PACKAGE_VERSION_FULL);
+  comment (" %s %s ", g_get_prgname (), PACKAGE_VERSION_FULL);
 
   comment
     (" NOTE!\n"
diff --git a/rtc.c b/rtc.c
index 05d0fae..32d32c8 100644
--- a/rtc.c
+++ b/rtc.c
@@ -38,7 +38,6 @@
 #include <linux/rtc.h>
 #endif
 
-#include "getprogname.h"
 #include "ignore-value.h"
 
 #include "p2v.h"
@@ -48,7 +47,7 @@ void
 get_rtc_config (struct rtc_config *rtc)
 {
   fprintf (stderr, "%s: RTC: compiled without support for /dev/rtc\n",
-           getprogname ());
+           g_get_prgname ());
 
   rtc->offset = 0;
   rtc->basis = BASIS_UTC;
@@ -92,7 +91,7 @@ get_rtc_config (struct rtc_config *rtc)
 
 #ifdef DEBUG_STDERR
   fprintf (stderr, "%s: RTC: %04d-%02d-%02d %02d:%02d:%02d\n",
-           getprogname (),
+           g_get_prgname (),
            rtm.tm_year + 1900, rtm.tm_mon + 1, rtm.tm_mday,
            rtm.tm_hour, rtm.tm_min, rtm.tm_sec);
 #endif
@@ -117,7 +116,7 @@ get_rtc_config (struct rtc_config *rtc)
 
 #ifdef DEBUG_STDERR
   fprintf (stderr, "%s: RTC: %ld system time: %ld difference: %g\n",
-           getprogname (),
+           g_get_prgname (),
            (long) rtc_time, (long) system_time, rf);
 #endif
 
@@ -129,7 +128,7 @@ get_rtc_config (struct rtc_config *rtc)
   if (rf < -12*60*60 || rf > 14*60*60) {
     fprintf (stderr,
              "%s: RTC: offset of RTC from UTC is out of range (%g).\n",
-             getprogname (), rf);
+             g_get_prgname (), rf);
     return;
   }
 
@@ -137,7 +136,7 @@ get_rtc_config (struct rtc_config *rtc)
 
 #ifdef DEBUG_STDERR
   fprintf (stderr, "%s: RTC: offset of RTC from UTC = %d secs\n",
-           getprogname (), rtc->offset);
+           g_get_prgname (), rtc->offset);
 #endif
 
   /* Is the hardware clock set to localtime?
@@ -154,7 +153,7 @@ get_rtc_config (struct rtc_config *rtc)
     rtc->basis = BASIS_LOCALTIME;
     rtc->offset = 0;
 #ifdef DEBUG_STDERR
-    fprintf (stderr, "%s: RTC time is localtime\n", getprogname ());
+    fprintf (stderr, "%s: RTC time is localtime\n", g_get_prgname ());
 #endif
   }
 
diff --git a/ssh.c b/ssh.c
index 99eefbd..3cd6c71 100644
--- a/ssh.c
+++ b/ssh.c
@@ -54,7 +54,6 @@
 #include <signal.h>
 
 #include "ignore-value.h"
-#include "getprogname.h"
 
 #include "miniexpect.h"
 #include "p2v.h"
@@ -143,7 +142,7 @@ compile_regexps (void)
     pcre_fullinfo ((re), NULL, PCRE_INFO_OKPARTIAL, &p);		\
     if (p != 1) {							\
       fprintf (stderr, "%s: %s:%d: internal error: pattern '%s' cannot be used for partial matching\n", \
-	       getprogname (),				\
+	       g_get_prgname (),				\
 	       __FILE__, __LINE__, (pattern));				\
       abort ();								\
     }									\
@@ -813,7 +812,7 @@ test_connection (struct config *config)
       v2v_version = strndup (&h->buffer[ovector[2]], ovector[3]-ovector[2]);
 #if DEBUG_STDERR
       fprintf (stderr, "%s: remote virt-v2v version: %s\n",
-               getprogname (), v2v_version);
+               g_get_prgname (), v2v_version);
 #endif
       break;
 
@@ -895,7 +894,7 @@ test_connection (struct config *config)
     case 101:                   /* virt-v2v supports --colours option */
 #if DEBUG_STDERR
   fprintf (stderr, "%s: remote virt-v2v supports --colours option\n",
-           getprogname ());
+           g_get_prgname ());
 #endif
       feature_colours_option = 1;
       break;
@@ -1009,7 +1008,7 @@ add_option (const char *type, char ***drivers, const char *name, size_t len)
 
 #if DEBUG_STDERR
   fprintf (stderr, "%s: remote virt-v2v supports %s driver %s\n",
-           getprogname (), type, (*drivers)[n-1]);
+           g_get_prgname (), type, (*drivers)[n-1]);
 #endif
 }
 
-- 
2.21.0


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