diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-02-21 14:11:47 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-03-22 14:46:18 +0400 |
commit | 336d354ba73f62099b1a931662694b23cb3d2b65 (patch) | |
tree | 22487bb6c811aae73d2c81b17d7ff0d6ce046006 /util/qemu-error.c | |
parent | 45297887dc88e2ea6d1001064a407e713b2d6ebb (diff) | |
download | qemu-336d354ba73f62099b1a931662694b23cb3d2b65.zip qemu-336d354ba73f62099b1a931662694b23cb3d2b65.tar.gz qemu-336d354ba73f62099b1a931662694b23cb3d2b65.tar.bz2 |
error: use GLib to remember the program name
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'util/qemu-error.c')
-rw-r--r-- | util/qemu-error.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/util/qemu-error.c b/util/qemu-error.c index 52a9e01..7769aee 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -146,22 +146,6 @@ void loc_set_file(const char *fname, int lno) } } -static const char *progname; - -/* - * Set the program name for error_print_loc(). - */ -static void error_set_progname(const char *argv0) -{ - const char *p = strrchr(argv0, '/'); - progname = p ? p + 1 : argv0; -} - -const char *error_get_progname(void) -{ - return progname; -} - /* * Print current location to current monitor if we have one, else to stderr. */ @@ -171,8 +155,8 @@ static void print_loc(void) int i; const char *const *argp; - if (!monitor_cur() && progname) { - fprintf(stderr, "%s:", progname); + if (!monitor_cur() && g_get_prgname()) { + fprintf(stderr, "%s:", g_get_prgname()); sep = " "; } switch (cur_loc->kind) { @@ -400,8 +384,10 @@ static void qemu_log_func(const gchar *log_domain, void error_init(const char *argv0) { + const char *p = strrchr(argv0, '/'); + /* Set the program name for error_print_loc(). */ - error_set_progname(argv0); + g_set_prgname(p ? p + 1 : argv0); /* * This sets up glib logging so libraries using it also print their logs |