|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [Qemu-devel] [PATCH 15/16] os-posix: cleanup: Replace perror with error_report
On Tue, Apr 24, 2018 at 10:43:09AM -0500, Eric Blake wrote:
> On 04/24/2018 10:40 AM, Eric Blake wrote:
> > On 04/24/2018 10:18 AM, Daniel P. Berrangé wrote:
> >
> >>> - 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.
> >
> > Except that strerror_r() is a bear to use portably, given that glibc's
> > default declaration differs from the POSIX requirement (you can force
> > glibc to give you the POSIX version, but doing so causes you to lose
> > access to many other useful extensions). It's rather telling that 'git
> > grep strerror_r' currently comes up empty.
>
> That said, glib's g_strerror() may be suitable for this purpose,
> although we are currently using it only in tests/ivshmem-test.c.
Yes, that uses strerror_r internally, or strerror_s on Windows:
https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gstrfuncs.c#L1236
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 :|
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |