Re: [PATCH] compat/winansi: fix die_lasterr() argument formatting
From: Johannes Sixt <hidden>
Date: 2026-09-21 04:07:02
Am 21.09.26 um 05:00 schrieb Yongqiang Tian:
3. Remove die_lasterr() and report GetLastError() directly at those call sites. This avoids the va_list forwarding, allocation, and errno conversion altogether. The third direction now seems the simplest to me. It also follows existing Windows-specific code in Git that reports GetLastError() directly, for example: https://github.com/git/git/blob/9a0c4701dcd5725c4184599322b52933ff5005ca/compat/win32/syslog.c#L10-L13 and: https://github.com/git/git/blob/9a0c4701dcd5725c4184599322b52933ff5005ca/compat/fsmonitor/fsm-listen-win32.c#L106-L109
Sounds reasonable to me.
- die_lasterr("DuplicateHandle(%li) failed",
- (long) (intptr_t) hnd);
+ die("DuplicateHandle(%p) failed: Windows error %lu",
+ (void *)hnd, GetLastError());But please leave the conversion to %p for another time. Concerning the text "Windows error", please follow existing practice. -- Hannes