Message ID | 20240410160614.90627-1-philmd@linaro.org |
---|---|
Headers | show |
Series | misc: Remove sprintf() due to macOS deprecation | expand |
On 4/10/24 06:06, Philippe Mathieu-Daudé wrote: > Hi, > > sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, > resulting in painful developper experience. Is snprintf also deprecated? It might be easier to convert some of these fixed buffer cases that way, if allowed. r~
On Wed, 10 Apr 2024, Richard Henderson wrote: > On 4/10/24 06:06, Philippe Mathieu-Daudé wrote: >> Hi, >> >> sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, >> resulting in painful developper experience. > > Is snprintf also deprecated? > It might be easier to convert some of these fixed buffer cases that way, if > allowed. I had the same thought as some of these might also have performance implications (although most of them are in rarely called places). Regards, BALATON Zoltan
On 11/4/24 00:27, BALATON Zoltan wrote: > On Wed, 10 Apr 2024, Richard Henderson wrote: >> On 4/10/24 06:06, Philippe Mathieu-Daudé wrote: >>> Hi, >>> >>> sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, >>> resulting in painful developper experience. >> >> Is snprintf also deprecated? >> It might be easier to convert some of these fixed buffer cases that >> way, if allowed. > > I had the same thought as some of these might also have performance > implications (although most of them are in rarely called places). I thought GLib/GString was recommended for formatting (IIRC some previous discussion with Alex / Daniel), so I switched to this API for style, rather than thinking of performance. Anyway, I'll respin using sprintf() when the buffer size maths are already done. > > Regards, > BALATON Zoltan
On Thu, Apr 11, 2024 at 11:38:41AM +0200, Philippe Mathieu-Daudé wrote: > On 11/4/24 00:27, BALATON Zoltan wrote: > > On Wed, 10 Apr 2024, Richard Henderson wrote: > > > On 4/10/24 06:06, Philippe Mathieu-Daudé wrote: > > > > Hi, > > > > > > > > sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1, > > > > resulting in painful developper experience. > > > > > > Is snprintf also deprecated? > > > It might be easier to convert some of these fixed buffer cases that > > > way, if allowed. > > > > I had the same thought as some of these might also have performance > > implications (although most of them are in rarely called places). > > I thought GLib/GString was recommended for formatting (IIRC some > previous discussion with Alex / Daniel), so I switched to this > API for style, rather than thinking of performance. Anyway, I'll > respin using sprintf() when the buffer size maths are already done. There are places in QEMU where the strings end up living in a fixed size struct fields, and those would be candidates for sticking with snprint(). For stack allocated string buffers, it is preferrable to switch to g_autofree + g_strdup_printf(), unless there's a compelling performance reason to avoid allocation in a hot path IMHO. With regards, Daniel