From nobody Sat Feb 7 18:16:09 2026 Delivered-To: importer@patchew.org Received-SPF: permerror (zohomail.com: Error in processing SPF Record) client-ip=216.145.221.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=permerror (zohomail.com: Error in processing SPF Record) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687176245; cv=none; d=zohomail.com; s=zohoarc; b=QzAgwZolyzdgyi/l2qsMezLo69ErXnuE8B9vGNDvBWMC4QfkikyV+EWfaR898Cx5FxCIK5ndhNSGCo5HOLCtmao89fGW3p9ugFa46o85tyBqurQp7aTs4Aui7vHXOEo9LA9hokihLyYFYvybwMiaDKjFNJxTDMvx0Sx+ERJtfnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687176245; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kT/F6/Mh23WgFbXL8io+BV2SgXnkhORNs/GPJetfFKQ=; b=lFYdPGBTcjNG2org/G+ezsnx/Kybf54G+5U6jkGZAl3rTra2w0zX+Ye/uJwdEI2E+4/GzVp/ocudD9ZIDW/9ISQ4NQT0lTw3xiRu5fIkSU5G0wYzfokUK53qN0JXrINd5tqn/FizVuF5YzUrEV0snrlSsxYvr3P6mcWFfHoYqZc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=permerror (zohomail.com: Error in processing SPF Record) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.145.221.124]) by mx.zohomail.com with SMTPS id 1687176245277520.915067153066; Mon, 19 Jun 2023 05:04:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-2-Dq8MUexiOgiifW-aOUIskA-1; Mon, 19 Jun 2023 08:03:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B2A71185A794; Mon, 19 Jun 2023 12:03:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DD6F2166B26; Mon, 19 Jun 2023 12:03:53 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 170401946594; Mon, 19 Jun 2023 12:03:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1A3C41946589 for ; Mon, 19 Jun 2023 12:03:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EE64C40C20F6; Mon, 19 Jun 2023 12:03:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 965EA40C20F5 for ; Mon, 19 Jun 2023 12:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687176244; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kT/F6/Mh23WgFbXL8io+BV2SgXnkhORNs/GPJetfFKQ=; b=NZpFcM2ccS5Fzori72UxqFWtmA33BBfk4ZuuuuqYRZxmymTsFUbeEoIrDBpmhAiuyPJwH7 aDtIUPGKIXW9RgFC3nV2zDf4hPQtMnRpDSWLb2pkn/4D820ahhfP3Q4bBF73GV94IQvXp6 zk037kU+sfG+CNfRx90eNgW7kpFMrII= X-MC-Unique: Dq8MUexiOgiifW-aOUIskA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] virstring: Move locale wrappers at the beginning Date: Mon, 19 Jun 2023 14:03:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687176246740100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We will soon need the virLocaleRaw variable. Move it and functions around it at the beginning of the file, so that later code doesn't need to introduce forward declarations. Signed-off-by: Michal Privoznik --- src/util/virstring.c | 157 ++++++++++++++++++++++--------------------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/src/util/virstring.c b/src/util/virstring.c index 6b728ff047..1a13570d30 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -35,6 +35,85 @@ =20 VIR_LOG_INIT("util.string"); =20 +/* In case thread-safe locales are available */ +#if WITH_NEWLOCALE + +typedef locale_t virLocale; +static virLocale virLocaleRaw; + +static int +virLocaleOnceInit(void) +{ + virLocaleRaw =3D newlocale(LC_ALL_MASK, "C", (locale_t)0); + if (!virLocaleRaw) + return -1; + return 0; +} + +VIR_ONCE_GLOBAL_INIT(virLocale); + +/** + * virLocaleSetRaw: + * + * @oldlocale: set to old locale pointer + * + * Sets the locale to 'C' to allow operating on non-localized objects. + * Returns 0 on success -1 on error. + */ +static int +virLocaleSetRaw(virLocale *oldlocale) +{ + if (virLocaleInitialize() < 0) + return -1; + *oldlocale =3D uselocale(virLocaleRaw); + return 0; +} + +static void +virLocaleRevert(virLocale *oldlocale) +{ + uselocale(*oldlocale); +} + +static void +virLocaleFixupRadix(char **strp G_GNUC_UNUSED) +{ +} + +#else /* !WITH_NEWLOCALE */ + +typedef int virLocale; + +static int +virLocaleSetRaw(virLocale *oldlocale G_GNUC_UNUSED) +{ + return 0; +} + +static void +virLocaleRevert(virLocale *oldlocale G_GNUC_UNUSED) +{ +} + +static void +virLocaleFixupRadix(char **strp) +{ + char *radix, *tmp; + struct lconv *lc; + + lc =3D localeconv(); + radix =3D lc->decimal_point; + tmp =3D strstr(*strp, radix); + if (tmp) { + *tmp =3D '.'; + if (strlen(radix) > 1) + memmove(tmp + 1, tmp + strlen(radix), strlen(*strp) - (tmp - *= strp)); + } +} + +#endif /* !WITH_NEWLOCALE */ + + /* Like strtol with C locale, but produce an "int" result, and check more = carefully. Return 0 upon success; return -1 to indicate failure. When END_PTR is NULL, the byte after the final valid digit must be NUL. @@ -233,84 +312,6 @@ virStrToLong_ullp(char const *s, char **end_ptr, int b= ase, return 0; } =20 -/* In case thread-safe locales are available */ -#if WITH_NEWLOCALE - -typedef locale_t virLocale; -static virLocale virLocaleRaw; - -static int -virLocaleOnceInit(void) -{ - virLocaleRaw =3D newlocale(LC_ALL_MASK, "C", (locale_t)0); - if (!virLocaleRaw) - return -1; - return 0; -} - -VIR_ONCE_GLOBAL_INIT(virLocale); - -/** - * virLocaleSetRaw: - * - * @oldlocale: set to old locale pointer - * - * Sets the locale to 'C' to allow operating on non-localized objects. - * Returns 0 on success -1 on error. - */ -static int -virLocaleSetRaw(virLocale *oldlocale) -{ - if (virLocaleInitialize() < 0) - return -1; - *oldlocale =3D uselocale(virLocaleRaw); - return 0; -} - -static void -virLocaleRevert(virLocale *oldlocale) -{ - uselocale(*oldlocale); -} - -static void -virLocaleFixupRadix(char **strp G_GNUC_UNUSED) -{ -} - -#else /* !WITH_NEWLOCALE */ - -typedef int virLocale; - -static int -virLocaleSetRaw(virLocale *oldlocale G_GNUC_UNUSED) -{ - return 0; -} - -static void -virLocaleRevert(virLocale *oldlocale G_GNUC_UNUSED) -{ -} - -static void -virLocaleFixupRadix(char **strp) -{ - char *radix, *tmp; - struct lconv *lc; - - lc =3D localeconv(); - radix =3D lc->decimal_point; - tmp =3D strstr(*strp, radix); - if (tmp) { - *tmp =3D '.'; - if (strlen(radix) > 1) - memmove(tmp + 1, tmp + strlen(radix), strlen(*strp) - (tmp - *= strp)); - } -} - -#endif /* !WITH_NEWLOCALE */ - =20 /** * virStrToDouble --=20 2.39.3 From nobody Sat Feb 7 18:16:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1687176248; cv=none; d=zohomail.com; s=zohoarc; b=Y2BL4SGCNOpvcBsOF4wHTJ1YP6MWB9RsZiQZ1Py1D3vEJ6hOxwWHy7TUHNYV55thhLTahRK9RsL3moxVDwezIQQjYgg0HrCW95eatfFyEdf5j5ZjA7HxvSJyAsqnIrvDuBJVq28KwtZBA1eZZeJZ8vIO20OYRXHOH7IceVF7ENc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687176248; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6/6iKC5fx9lvhVmmmnXTvl92RV5J5SvPPYX3lqvV2as=; b=PZAOK2Q/6T01OWiCfUpOTPIGsQUzw+Z0MpThgBYWcYgDFjRNLrIz/TvK3OueaIxsRTidBQE2vUBynXVPL9k+FVeRXqdCojSFCdIhyw1BkW2pXKx+Vpthmh5vGmeQI+8YZIjew+hkfVpmPWU+QtVc6kQ7pv3bZSRrCkCAgPv3Jvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1687176248369949.9970334174201; Mon, 19 Jun 2023 05:04:08 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-aPGv62dSPKai7sjzk7Zufg-1; Mon, 19 Jun 2023 08:04:03 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE404810BB5; Mon, 19 Jun 2023 12:04:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA2AC48FB05; Mon, 19 Jun 2023 12:04:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4BC6119465B7; Mon, 19 Jun 2023 12:03:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9ACEC1946589 for ; Mon, 19 Jun 2023 12:03:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 8BCF540C20F6; Mon, 19 Jun 2023 12:03:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 316AD40C20F5 for ; Mon, 19 Jun 2023 12:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687176247; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6/6iKC5fx9lvhVmmmnXTvl92RV5J5SvPPYX3lqvV2as=; b=RMV1B1CAqzH8tr4m3oLc8vprjKhla30rw+EvrRSZpZ/ockH+yJWZkltgHTZo02eIkm0hRK 3CcnPyZgLFk08OxEkREX+sGj/zKEgJHxidRLtBaa2vNcRZMQNwpaiBKLy1j306D6o4DtfM zRarAETSdQ9Mje2EvIEFDQsnbj5j2cA= X-MC-Unique: aPGv62dSPKai7sjzk7Zufg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] virstring: Prefer strtoll_l() and strtoull_l() whenever possible Date: Mon, 19 Jun 2023 14:03:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1687176249513100001 Content-Type: text/plain; charset="utf-8"; x-default="true" It's weird that in 2023 there's no reliable and portable way to parse strings, but okay. We started with strtol(). Except, it doesn't work the same on Linux and Windows. On Windows it behaves a bit different when it comes to parsing strings with base =3D 0. So we've switched to g_ascii_strtoll() which promised to solve this. And it did. Except, it introduced another problem. I don't really understand why, but I've seen random test failures and all of them claimed inability to parse a number (specifically from the hard coded domain XML from test driver, which IMO is just a coincidence because it's the first number we parse). Anyway, it's not 100% reproducible and usually occurs when my system is under heavy load, but there's a way to reproduce it: $ meson test -C _build --repeat 2000 virshtest virsh-vcpupin The nature of the problem suggests there's a race condition somewhere. I suspected glib but I don't know their code well to prove it. Anyway, using strtoll_l() directly and taking glib out of the picture solves the issue. Signed-off-by: Michal Privoznik --- meson.build | 1 + src/util/virstring.c | 82 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index aa391e7178..cd713795f5 100644 --- a/meson.build +++ b/meson.build @@ -596,6 +596,7 @@ functions =3D [ 'sched_setscheduler', 'setgroups', 'setrlimit', + 'strtoll_l', 'symlink', 'sysctlbyname', ] diff --git a/src/util/virstring.c b/src/util/virstring.c index 1a13570d30..076e885624 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -127,8 +127,17 @@ virStrToLong_i(char const *s, char **end_ptr, int base= , int *result) char *p; int err; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoll_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoll(s, &p, base); +#endif err =3D (errno || (!end_ptr && *p) || p =3D=3D s || (int) val !=3D val= ); if (end_ptr) *end_ptr =3D p; @@ -148,13 +157,23 @@ virStrToLong_ui(char const *s, char **end_ptr, int ba= se, unsigned int *result) char *p; bool err =3D false; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoull_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoull(s, &p, base); +#endif =20 /* This one's tricky. We _want_ to allow "-1" as shorthand for * UINT_MAX regardless of whether long is 32-bit or 64-bit. But - * g_ascii_strtoull treats "-1" as ULLONG_MAX, and going from ullong b= ack - * to uint differs depending on the size of uint. */ + * strtoull_l/g_ascii_strtoull treats "-1" as ULLONG_MAX, and + * going from ullong back to uint differs depending on the size of + * uint. */ if (memchr(s, '-', p - s)) { if (-val > UINT_MAX) err =3D true; @@ -180,8 +199,17 @@ virStrToLong_uip(char const *s, char **end_ptr, int ba= se, unsigned int *result) char *p; bool err =3D false; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoull_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoull(s, &p, base); +#endif err =3D (memchr(s, '-', p - s) || errno || (!end_ptr && *p) || p =3D=3D s || (unsigned int) val != =3D val); if (end_ptr) @@ -204,13 +232,23 @@ virStrToLong_ul(char const *s, char **end_ptr, int ba= se, unsigned long *result) char *p; bool err =3D false; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoull_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoull(s, &p, base); +#endif =20 /* This one's tricky. We _want_ to allow "-1" as shorthand for * ULONG_MAX regardless of whether long is 32-bit or 64-bit. But - * g_ascii_strtoull treats "-1" as ULLONG_MAX, and going from ullong b= ack - * to ulong differs depending on the size of ulong. */ + * strtoull_l/g_ascii_strtoull treats "-1" as ULLONG_MAX, and + * going from ullong back to ulong differs depending on the size + * of ulong. */ if (memchr(s, '-', p - s)) { if (-val > ULONG_MAX) err =3D true; @@ -237,8 +275,17 @@ virStrToLong_ulp(char const *s, char **end_ptr, int ba= se, char *p; int err; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoull_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoull(s, &p, base); +#endif err =3D (memchr(s, '-', p - s) || errno || (!end_ptr && *p) || p =3D=3D s || (unsigned long) val = !=3D val); if (end_ptr) @@ -257,8 +304,17 @@ virStrToLong_ll(char const *s, char **end_ptr, int bas= e, long long *result) char *p; int err; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoll_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoll(s, &p, base); +#endif err =3D (errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) *end_ptr =3D p; @@ -279,8 +335,17 @@ virStrToLong_ull(char const *s, char **end_ptr, int ba= se, char *p; int err; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoull_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoull(s, &p, base); +#endif err =3D (errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) *end_ptr =3D p; @@ -300,8 +365,17 @@ virStrToLong_ullp(char const *s, char **end_ptr, int b= ase, char *p; int err; =20 +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + if (virLocaleInitialize() < 0) + return -1; +#endif + errno =3D 0; +#if defined(WITH_STRTOLL_L) && defined(WITH_NEWLOCALE) + val =3D strtoull_l(s, &p, base, virLocaleRaw); +#else val =3D g_ascii_strtoull(s, &p, base); +#endif err =3D (memchr(s, '-', p - s) || errno || (!end_ptr && *p) || p =3D=3D s); if (end_ptr) --=20 2.39.3