diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-07 16:19:21 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-10-11 16:59:00 +0200 |
commit | b4096cecffd13491848b84bc27f00dbee06af52e (patch) | |
tree | f77ff3d40d693e8bd396848179ca09a5af9184be /man/sd_device_ref.xml | |
parent | 29c45dc4348e7db61aa80ba1657cbc2d8b1a19ee (diff) | |
download | systemd-b4096cecffd13491848b84bc27f00dbee06af52e.tar.gz |
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.
Diffstat (limited to 'man/sd_device_ref.xml')
-rw-r--r-- | man/sd_device_ref.xml | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/man/sd_device_ref.xml b/man/sd_device_ref.xml index c2ba6b1571..2b8512a572 100644 --- a/man/sd_device_ref.xml +++ b/man/sd_device_ref.xml @@ -62,8 +62,10 @@ int r; … r = sd_device_new_from_syspath(&device, "…"); - if (r < 0) - fprintf(stderr, "Failed to allocate device: %s\n", strerror(-r)); + if (r < 0) { + errno = -r; + fprintf(stderr, "Failed to allocate device: %m\n"); + } … }</programlisting> |