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>
This commit is contained in:
parent
45297887dc
commit
336d354ba7
|
@ -72,8 +72,6 @@ void error_init(const char *argv0);
|
||||||
fmt, ##__VA_ARGS__); \
|
fmt, ##__VA_ARGS__); \
|
||||||
})
|
})
|
||||||
|
|
||||||
const char *error_get_progname(void);
|
|
||||||
|
|
||||||
extern bool message_with_timestamp;
|
extern bool message_with_timestamp;
|
||||||
extern bool error_with_guestname;
|
extern bool error_with_guestname;
|
||||||
extern const char *error_guest_name;
|
extern const char *error_guest_name;
|
||||||
|
|
10
qemu-io.c
10
qemu-io.c
|
@ -323,7 +323,7 @@ static char *get_prompt(void)
|
||||||
static char prompt[FILENAME_MAX + 2 /*"> "*/ + 1 /*"\0"*/ ];
|
static char prompt[FILENAME_MAX + 2 /*"> "*/ + 1 /*"\0"*/ ];
|
||||||
|
|
||||||
if (!prompt[0]) {
|
if (!prompt[0]) {
|
||||||
snprintf(prompt, sizeof(prompt), "%s> ", error_get_progname());
|
snprintf(prompt, sizeof(prompt), "%s> ", g_get_prgname());
|
||||||
}
|
}
|
||||||
|
|
||||||
return prompt;
|
return prompt;
|
||||||
|
@ -598,10 +598,10 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case 'V':
|
case 'V':
|
||||||
printf("%s version " QEMU_FULL_VERSION "\n"
|
printf("%s version " QEMU_FULL_VERSION "\n"
|
||||||
QEMU_COPYRIGHT "\n", error_get_progname());
|
QEMU_COPYRIGHT "\n", g_get_prgname());
|
||||||
exit(0);
|
exit(0);
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(error_get_progname());
|
usage(g_get_prgname());
|
||||||
exit(0);
|
exit(0);
|
||||||
case 'U':
|
case 'U':
|
||||||
force_share = true;
|
force_share = true;
|
||||||
|
@ -613,13 +613,13 @@ int main(int argc, char **argv)
|
||||||
imageOpts = true;
|
imageOpts = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(error_get_progname());
|
usage(g_get_prgname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((argc - optind) > 1) {
|
if ((argc - optind) > 1) {
|
||||||
usage(error_get_progname());
|
usage(g_get_prgname());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -836,7 +836,7 @@ static void help(int exitcode)
|
||||||
version();
|
version();
|
||||||
printf("usage: %s [options] [disk_image]\n\n"
|
printf("usage: %s [options] [disk_image]\n\n"
|
||||||
"'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
|
"'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
|
||||||
error_get_progname());
|
g_get_prgname());
|
||||||
|
|
||||||
#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
|
#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
|
||||||
if ((arch_mask) & arch_type) \
|
if ((arch_mask) & arch_type) \
|
||||||
|
|
|
@ -141,7 +141,7 @@ static void help(void)
|
||||||
" --pidfile <path> write process ID to a file after startup\n"
|
" --pidfile <path> write process ID to a file after startup\n"
|
||||||
"\n"
|
"\n"
|
||||||
QEMU_HELP_BOTTOM "\n",
|
QEMU_HELP_BOTTOM "\n",
|
||||||
error_get_progname());
|
g_get_prgname());
|
||||||
}
|
}
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
|
@ -161,7 +161,7 @@ void trace_list_events(FILE *f)
|
||||||
fprintf(f, "This list of names of trace points may be incomplete "
|
fprintf(f, "This list of names of trace points may be incomplete "
|
||||||
"when using the DTrace/SystemTap backends.\n"
|
"when using the DTrace/SystemTap backends.\n"
|
||||||
"Run 'qemu-trace-stap list %s' to print the full list.\n",
|
"Run 'qemu-trace-stap list %s' to print the full list.\n",
|
||||||
error_get_progname());
|
g_get_prgname());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
* Print current location to current monitor if we have one, else to stderr.
|
||||||
*/
|
*/
|
||||||
|
@ -171,8 +155,8 @@ static void print_loc(void)
|
||||||
int i;
|
int i;
|
||||||
const char *const *argp;
|
const char *const *argp;
|
||||||
|
|
||||||
if (!monitor_cur() && progname) {
|
if (!monitor_cur() && g_get_prgname()) {
|
||||||
fprintf(stderr, "%s:", progname);
|
fprintf(stderr, "%s:", g_get_prgname());
|
||||||
sep = " ";
|
sep = " ";
|
||||||
}
|
}
|
||||||
switch (cur_loc->kind) {
|
switch (cur_loc->kind) {
|
||||||
|
@ -400,8 +384,10 @@ static void qemu_log_func(const gchar *log_domain,
|
||||||
|
|
||||||
void error_init(const char *argv0)
|
void error_init(const char *argv0)
|
||||||
{
|
{
|
||||||
|
const char *p = strrchr(argv0, '/');
|
||||||
|
|
||||||
/* Set the program name for error_print_loc(). */
|
/* 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
|
* This sets up glib logging so libraries using it also print their logs
|
||||||
|
|
Loading…
Reference in New Issue