mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tools: fix double error reporting in virt-login-shell
The public API entry points will call virDispatchError which will print to stderr by default. We then jump to a cleanup path which calls virDispatchError again. We tried to stop the entry points printing to stderr, but incorrectly called virSetErrorFunc. It needs a real function that is a no-op, not a NULL function. Once we fix virSetErrorFunc, then we need to use fprintf in the cleanup path instead of virDispatchError. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
275bcbebab
commit
cd1f25a9d4
@ -143,6 +143,12 @@ show_version(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
hideErrorFunc(void *opaque ATTRIBUTE_UNUSED,
|
||||||
|
virErrorPtr err ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@ -186,7 +192,7 @@ main(int argc, char **argv)
|
|||||||
return EXIT_CANCELED;
|
return EXIT_CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
virSetErrorFunc(NULL, NULL);
|
virSetErrorFunc(NULL, hideErrorFunc);
|
||||||
virSetErrorLogPriorityFunc(NULL);
|
virSetErrorLogPriorityFunc(NULL);
|
||||||
|
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
@ -403,7 +409,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (saved_err) {
|
if (saved_err) {
|
||||||
virSetError(saved_err);
|
virSetError(saved_err);
|
||||||
virDispatchError(NULL);
|
fprintf(stderr, "%s: %s\n", argv[0], virGetLastErrorMessage());
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user