On Fri, Jun 23, 2017 at 11:42:01AM +0200, Martin Kletzander wrote: > On Fri, Jun 23, 2017 at 09:32:07AM +0100, Daniel P. Berrange wrote: > > On Fri, Jun 23, 2017 at 10:21:32AM +0200, Martin Kletzander wrote: > > > On Thu, Jun 22, 2017 at 03:49:03PM +0200, Peter Krempa wrote: > > > > On Thu, Jun 22, 2017 at 14:36:53 +0200, Martin Kletzander wrote: > > > > > Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> > > > > > --- > > > > > src/util/virstring.c | 96 ++++++++++++++++++++++++++++++++-------------------- > > > > > 1 file changed, 60 insertions(+), 36 deletions(-) > > > > > > > > > > diff --git a/src/util/virstring.c b/src/util/virstring.c > > > > > index feea5be05198..6125725364f3 100644 > > > > > --- a/src/util/virstring.c > > > > > +++ b/src/util/virstring.c > > > > > @@ -522,6 +522,7 @@ virStrToLong_ullp(char const *s, char **end_ptr, int base, > > > > > #if HAVE_NEWLOCALE > > > > > > > > > > static locale_t virLocale; > > > > > +static locale_t virLocaleOld; > > > > > > > > This is not a thread local variable ... > > > > > > > > > > Oh. shoot, you're right. So we need to wrap it in our struct that will > > > be defined conditionally as well, or allocate it on the heap, copy it > > > there and set a pointer to it as one additional parameter or make thread > > > local variable, but that one will need to be a pointer to the locale, so > > > we'll need to allocate it on the heap as well. I don't like the way > > > this is going. Anyone else feel free to continue on this if you want to > > > clean this up, but I like the few small conditional blocks better, > > > especially since we have them in only two functions. > > > > Just have virLocaleSet() return the original locale to the caller, and > > it can pass it back in when it reverts, avoiding any global variables. > > > > You cannot do that when you don't have 'locale_t', hence the > complications. Or is the existence of locale_t somehow guaranteed by > gnulib? If it is, then that's solved. Just wrap it in a typedef so we don't directly expose it in headers: #if HAVE_LOCALE_T typedef virLocale locale_t #else typedef virLocale void #endif 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 :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list