[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with er
From: |
Daniel P . Berrangé |
Subject: |
Re: [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with error_report |
Date: |
Tue, 24 Apr 2018 16:18:30 +0100 |
User-agent: |
Mutt/1.9.2 (2017-12-15) |
On Tue, Apr 24, 2018 at 03:53:48PM +0100, Ian Jackson wrote:
> Philippe Mathieu-Daudé writes ("Re: [Qemu-devel] [PATCH 15/16] os-posix:
> cleanup: Replace perror with error_report"):
> > On 04/19/2018 01:45 PM, Ian Jackson wrote:
> > > - perror("mlockall");
> > > + error_report("mlockall: %s", strerror(errno));
> > > }
> > >
> > > return ret;
> >
> > Thinking loudly, maybe we can refactor as error_report_errno(const char
> > *desc)...
>
> git-grep 'error_report.*errno' shows a lot of call sites that do
> something more exciting than const char *desc would support.
>
> I think the right approach would be
>
> - static void vreport(report_type type, const char *fmt, va_list ap)
> + static void vreport(report_type type, int errnoval, const char *fmt,
> va_list ap)
> ...
> + if (errnoval >= 0) {
> + error_printf(": %s", strerror(errnoval);
> + }
>
> and then add both
> error_report_errno
> error_vreport_errno
> with the obvious semantics.
That would be nice, because then we can make these two functions actually
use strerror_r() instead of strerror(), for thread safety on all platforms.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
- Re: [Qemu-devel] [PATCH 14/16] os-posix: cleanup: Replace fprintf with error_report in remaining call sites, (continued)
- [Qemu-devel] [PATCH 10/16] os-posix: Provide new -runas <uid>:<gid> facility, Ian Jackson, 2018/04/19
- [Qemu-devel] [PATCH 11/16] xen: Use newly added dmops for mapping VGA memory, Ian Jackson, 2018/04/19
- [Qemu-devel] [PATCH 02/16] AccelClass: Introduce accel_setup_post, Ian Jackson, 2018/04/19
- [Qemu-devel] [PATCH 12/16] xen: Remove now-obsolete xen_xc_domain_add_to_physmap, Ian Jackson, 2018/04/19
- [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with error_report, Ian Jackson, 2018/04/19
- Re: [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with error_report, Markus Armbruster, 2018/04/24
[Qemu-devel] [PATCH 16/16] configure: do_compiler: Dump some extra info under bash, Ian Jackson, 2018/04/19