From b4096cecffd13491848b84bc27f00dbee06af52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Oct 2022 16:19:21 +0200 Subject: man: recommend %m over strerror() The need to set errno is very very ugly, but at least it is thread-safe and works correctly. Using strerror() is likely to be wrong, so let's not recommend that. People who do a lot of logging would provide use some wrapper that sets errno like we do, so nudge people towards %m. I tested that all the separate .c files compile cleanly. --- man/sd_bus_new.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'man/sd_bus_new.xml') diff --git a/man/sd_bus_new.xml b/man/sd_bus_new.xml index 41964640b6..b45106168c 100644 --- a/man/sd_bus_new.xml +++ b/man/sd_bus_new.xml @@ -119,8 +119,10 @@ int r; … r = sd_bus_default(&bus); - if (r < 0) - fprintf(stderr, "Failed to allocate bus: %s\n", strerror(-r)); + if (r < 0) { + errno = -r; + fprintf(stderr, "Failed to allocate bus: %m\n"); + } … } -- cgit v1.2.1