From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48FFFC87FCD for ; Fri, 25 Jul 2025 10:00:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ufFDA-0000ap-4r; Fri, 25 Jul 2025 05:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufFD2-0000TY-Se for qemu-devel@nongnu.org; Fri, 25 Jul 2025 05:59:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ufFCx-0001r8-48 for qemu-devel@nongnu.org; Fri, 25 Jul 2025 05:59:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753437555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=07e8GqMSMwUqCTgqlqzBntBEnHTNY1nfJdmK7DnZNqk=; b=ME53YdBktU1EqRP16FZd98lG3+ZVVvB2ShCNvGEQogJ1L7iloKLJPA9v+5sLFu2UZU954v DSjMeKxWLNrQAZTfbixGxwoXYQxJ9sZ2IfQIlwO/RzEr2mDTNpfKavfbTeBnpGCXGk3397 X5Gj2rIUm0hraP+faI6P5HI3dQ1m6vM= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-bImsJrVFM9OQHnIs2cl3cQ-1; Fri, 25 Jul 2025 05:59:13 -0400 X-MC-Unique: bImsJrVFM9OQHnIs2cl3cQ-1 X-Mimecast-MFC-AGG-ID: bImsJrVFM9OQHnIs2cl3cQ_1753437553 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6fab979413fso35520856d6.2 for ; Fri, 25 Jul 2025 02:59:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753437553; x=1754042353; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=07e8GqMSMwUqCTgqlqzBntBEnHTNY1nfJdmK7DnZNqk=; b=aZWN6v8V+Bw5X4CTmHBput1KJeeuhiRopsaxO3oZ5rqH6Loy6BhFzDQS272MVOhZ5S 05VSGY1McXxHsJb7Zziy8puh7zljhLG93KiHnFYU9vhXixG6srIVI6cy1cVWht5X5KoP j92o4kNr52/EJyFzFexDZK+w4xktZgQNGt2YY77juOY4d5T+imehxZ140j7wSKpo9ZtI BQmcMCPyKLrM+F8ynjPYw9AIv167jAER14Iyk2O27+4+qJ8wYsOIZlTgwWFP28nPwp4m 7JlZJ0DJCF+itb4TJ+i41CDECJkxZ/DKetFRWblay1/YkndQG5Dubd/YLE+RXAnnwvN+ d1dg== X-Gm-Message-State: AOJu0YyM8pxUX1secob95PdzGzH34cSYkc894dk/q1NoqRom4vMfpCMO kKu6ufOWquWPFeoXV/Jp1tIeu8q/IuncH7Vc+43MJjv5s3lI1MkKOSoh6SQ1t16CgIy4yl3lrx7 9pQ0963U7q8FiGXOpFHptLsnNhOYf9XDQDHyIJzSwEc9i8LVSTFFjf75+TnKK6rARljEiaSptVM k5NRPfieckZcBozNm613hbd28Pu/TMn5s= X-Gm-Gg: ASbGncuLLUmj4qfWDWLlAVFBZ9dvARXshIbJ3fvCMHi4tAOXL3rV97ns75UYM90JxZu pshXSH27/hPlBkWFfnVZgQfLsjWVw9omawe1+t/lnMuzL8uv9bUdB4YXw1iYxvf02AU9DBSzh5r itOCZP3W8NV2GSTQNsBB04tI8= X-Received: by 2002:ad4:5cec:0:b0:700:c39c:9d12 with SMTP id 6a1803df08f44-707205ea7d6mr12961346d6.43.1753437553093; Fri, 25 Jul 2025 02:59:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxaxOCZ0/Ta1ZD2W+nH3+Z65QNOggZG1+y0BiO/z/AbKu7tXxSZGyyjMoMHUkj7fOouoCVGvxmngVJgcb6BYk= X-Received: by 2002:ad4:5cec:0:b0:700:c39c:9d12 with SMTP id 6a1803df08f44-707205ea7d6mr12961116d6.43.1753437552645; Fri, 25 Jul 2025 02:59:12 -0700 (PDT) MIME-Version: 1.0 References: <20250717145948.77870-1-kkostiuk@redhat.com> <87pldwbspt.fsf@pond.sub.org> <87seipkif5.fsf@pond.sub.org> In-Reply-To: From: Kostiantyn Kostiuk Date: Fri, 25 Jul 2025 12:59:00 +0300 X-Gm-Features: Ac12FXwxlgs9sMv1uVM36RpblRpq_bKnnDtj-orbtlJ3Se2FBXuDpQ99uPIIh-M Message-ID: Subject: Re: [PATCH] util: win32: Write hex value when can't get error message To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , Markus Armbruster Cc: qemu-devel@nongnu.org, Yan Vugenfirer , =?UTF-8?Q?Daniel_Berrang=C3=A9?= Content-Type: multipart/alternative; boundary="000000000000762d08063abdfe9d" Received-SPF: pass client-ip=170.10.133.124; envelope-from=kkostiuk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.45, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --000000000000762d08063abdfe9d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Issue reported to GLib https://gitlab.gnome.org/GNOME/glib/-/issues/3740 PR with fix https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4716 @Markus Armbruster Based on the documentation from this PR, do you have any other objections to this patch? Best Regards, Konstantin Kostiuk. On Mon, Jul 21, 2025 at 2:53=E2=80=AFPM Philippe Mathieu-Daud=C3=A9 wrote: > On 21/7/25 12:12, Kostiantyn Kostiuk wrote: > > > > > > On Mon, Jul 21, 2025 at 12:22=E2=80=AFPM Markus Armbruster > > wrote: > > > > Kostiantyn Kostiuk > > writes: > > > > > On Sat, Jul 19, 2025 at 9:27=E2=80=AFAM Markus Armbruster > > > wrote: > > > > > >> Kostiantyn Kostiuk > > writes: > > >> > > >> > g_win32_error_message - translate a Win32 error code > > >> > (as returned by GetLastError()) into the corresponding messag= e. > > >> > > > >> > In the same time, we call error_setg_win32_internal with > > >> > error codes from different Windows componets like VSS or > > >> > Performance monitor that provides different codes and > > >> > can't be converted with g_win32_error_message. > > >> > > >> Are these error codes from GetLastError()? > > >> > > > > > > No. > > > VSS functions directly return an error code. > > > Section: Return value - > > > https://learn.microsoft.com/en-us/windows/win32/api/vsbackup/nf- > > vsbackup-ivssbackupcomponents-addtosnapshotset > learn.microsoft.com/en-us/windows/win32/api/vsbackup/nf-vsbackup- > > ivssbackupcomponents-addtosnapshotset> > > > > > > Performance Counters API can return a system error code or a PDH > > error code. > > > Section: Return value - > > > https://learn.microsoft.com/en-us/windows/win32/api/pdh/nf-pdh- > > pdhopenqueryw > pdh/nf-pdh-pdhopenqueryw> > > > System error code =3D GetLastError, PDH error code, something el= se. > > > > > > https://learn.microsoft.com/en-us/windows/win32/perfctrs/pdh- > > error-codes > perfctrs/pdh-error-codes> > > > FormatMessage requires LoadLibrary(L"pdh.dll") to work properly. > > > > The error code error_setg_win32() takes is passed to > > g_win32_error_message(). Contract: > > > > g_win32_error_message () > > > > gchar * > > g_win32_error_message (gint error); > > > > Translate a Win32 error code (as returned by GetLastError() or > > WSAGetLastError()) into the corresponding message. The messag= e > is > > either language neutral, or in the thread's language, or the > user's > > language, the system's language, or US English (see docs for > > FormatMessage()). The returned string is in UTF-8. It should > be > > deallocated with g_free(). > > > > Parameters > > > > error error code. > > > > Returns > > > > newly-allocated error message > > > > https://www.manpagez.com/html/glib/glib-2.46.0/glib-Windows- > > Compatibility-Functions.php#g-win32-error-message > www.manpagez.com/html/glib/glib-2.46.0/glib-Windows-Compatibility- > > Functions.php#g-win32-error-message> > > > > Passing error codes from sources other than GetLastError() or > > WSAGetLastError() violates this contract. > > > > Apparently, g_win32_error_message() returns NULL then. This is not > > documented behavior. > > > > > > It returns an empty string, not NULL. > > https://gitlab.gnome.org/GNOME/glib/-/blob/ > > a205d01adc3fbc4f243e0b0fb52a3a0a8a0d9ae7/glib/gwin32.c#L216 > gitlab.gnome.org/GNOME/glib/-/blob/ > > a205d01adc3fbc4f243e0b0fb52a3a0a8a0d9ae7/glib/gwin32.c#L216> > > Worth reporting to GLib IMHO. > > --000000000000762d08063abdfe9d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Based on the documentation from this PR,= do you have any other objections to this patch?

Best Regards,
Konstantin Kostiuk.


On Mon, Jul 21, 2025 at 2:53= =E2=80=AFPM Philippe Mathieu-Daud=C3=A9 <philmd@linaro.org> wrote:
On 21/7/25 12:12, Kostiantyn Kostiuk wrote:
>
>
> On Mon, Jul 21, 2025 at 12:22=E2=80=AFPM Markus Armbruster <armbru@redhat.com
> <mailto:armb= ru@redhat.com>> wrote:
>
>=C2=A0 =C2=A0 =C2=A0Kostiantyn Kostiuk <kkostiuk@redhat.com
>=C2=A0 =C2=A0 =C2=A0<mailto:kkostiuk@redhat.com>> writes:
>
>=C2=A0 =C2=A0 =C2=A0 > On Sat, Jul 19, 2025 at 9:27=E2=80=AFAM Marku= s Armbruster
>=C2=A0 =C2=A0 =C2=A0<armbru@redhat.com <mailto:armbru@redhat.com>> wrote:
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 >> Kostiantyn Kostiuk <kkostiuk@redhat.com
>=C2=A0 =C2=A0 =C2=A0<mailto:kkostiuk@redhat.com>> writes:
>=C2=A0 =C2=A0 =C2=A0 >>
>=C2=A0 =C2=A0 =C2=A0 >> > g_win32_error_message - translate a = Win32 error code
>=C2=A0 =C2=A0 =C2=A0 >> > (as returned by GetLastError()) into= the corresponding message.
>=C2=A0 =C2=A0 =C2=A0 >> >
>=C2=A0 =C2=A0 =C2=A0 >> > In the same time, we call error_setg= _win32_internal with
>=C2=A0 =C2=A0 =C2=A0 >> > error codes from different Windows c= omponets like VSS or
>=C2=A0 =C2=A0 =C2=A0 >> > Performance monitor that provides di= fferent codes and
>=C2=A0 =C2=A0 =C2=A0 >> > can't be converted with g_win32_= error_message.
>=C2=A0 =C2=A0 =C2=A0 >>
>=C2=A0 =C2=A0 =C2=A0 >> Are these error codes from GetLastError()= ?
>=C2=A0 =C2=A0 =C2=A0 >>
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 > No.
>=C2=A0 =C2=A0 =C2=A0 > VSS functions directly return an error code.<= br> >=C2=A0 =C2=A0 =C2=A0 > Section: Return value -
>=C2=A0 =C2=A0 =C2=A0 > https:= //learn.microsoft.com/en-us/windows/win32/api/vsbackup/nf-
>=C2=A0 =C2=A0 =C2=A0vsbackup-ivssbackupcomponents-addtosnapshotset <= https://
>=C2=A0 =C2=A0 =C2=A0lear= n.microsoft.com/en-us/windows/win32/api/vsbackup/nf-vsbackup-
>=C2=A0 =C2=A0 =C2=A0ivssbackupcomponents-addtosnapshotset>
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 > Performance Counters API can return a system = error code or a PDH
>=C2=A0 =C2=A0 =C2=A0error code.
>=C2=A0 =C2=A0 =C2=A0 > Section: Return value -
>=C2=A0 =C2=A0 =C2=A0 > https:/= /learn.microsoft.com/en-us/windows/win32/api/pdh/nf-pdh-
>=C2=A0 =C2=A0 =C2=A0pdhopenqueryw <https:= //learn.microsoft.com/en-us/windows/win32/api/
>=C2=A0 =C2=A0 =C2=A0pdh/nf-pdh-pdhopenqueryw>
>=C2=A0 =C2=A0 =C2=A0 > System error code =3D GetLastError, PDH error= code, something else.
>=C2=A0 =C2=A0 =C2=A0 >
>=C2=A0 =C2=A0 =C2=A0 > https://l= earn.microsoft.com/en-us/windows/win32/perfctrs/pdh-
>=C2=A0 =C2=A0 =C2=A0error-codes <https://lear= n.microsoft.com/en-us/windows/win32/
>=C2=A0 =C2=A0 =C2=A0perfctrs/pdh-error-codes>
>=C2=A0 =C2=A0 =C2=A0 > FormatMessage requires LoadLibrary(L"pdh= .dll") to work properly.
>
>=C2=A0 =C2=A0 =C2=A0The error code error_setg_win32() takes is passed t= o
>=C2=A0 =C2=A0 =C2=A0g_win32_error_message().=C2=A0 Contract:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 g_win32_error_message ()
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 gchar *
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 g_win32_error_message (gint error);<= br> >
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Translate a Win32 error code (as ret= urned by GetLastError() or
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 WSAGetLastError()) into the correspo= nding message.=C2=A0 The message is
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 either language neutral, or in the t= hread's language, or the user's
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 language, the system's language,= or US English (see docs for
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 FormatMessage()).=C2=A0 The returned= string is in UTF-8.=C2=A0 It should be
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 deallocated with g_free().
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Parameters
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 error error code.
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Returns
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 newly-allocated error = message
>
>=C2=A0 =C2=A0 =C2=A0https://www.manp= agez.com/html/glib/glib-2.46.0/glib-Windows-
>=C2=A0 =C2=A0 =C2=A0Compatibility-Functions.php#g-win32-error-message &= lt;https://
>=C2=A0 =C2=A0 =C2=A0www= .manpagez.com/html/glib/glib-2.46.0/glib-Windows-Compatibility-
>=C2=A0 =C2=A0 =C2=A0Functions.php#g-win32-error-message>
>
>=C2=A0 =C2=A0 =C2=A0Passing error codes from sources other than GetLast= Error() or
>=C2=A0 =C2=A0 =C2=A0WSAGetLastError() violates this contract.
>
>=C2=A0 =C2=A0 =C2=A0Apparently, g_win32_error_message() returns NULL th= en.=C2=A0 This is not
>=C2=A0 =C2=A0 =C2=A0documented behavior.
>
>
> It returns an empty string, not NULL.
> https://gitlab.gnome.org/GNOME/glib/-/blob/
> a205d01adc3fbc4f243e0b0fb52a3a0a8a0d9ae7/glib/gwin32.c#L216 <https:= //
> gitlab.gnome.org/GNOME/glib/-/blob/
> a205d01adc3fbc4f243e0b0fb52a3a0a8a0d9ae7/glib/gwin32.c#L216>

Worth reporting to GLib IMHO.

--000000000000762d08063abdfe9d--