]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
man: recommend strerror_r() over strerror()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Oct 2022 14:24:01 +0000 (16:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 11 Oct 2022 14:59:00 +0000 (16:59 +0200)
Let's nudge people towards the use of an anonymous buffer like we
do internally.

"errno" → "errnum", to match the man page for strerror, and also to avoid
confusion with the global variable. In general, I think that errno is a
terrible interface and we shouldn't encourage people to use it. Those functions
use errno-style error numbers, which are a different thing.

man/sd-bus-errors.xml
man/sd_notify.xml
src/systemd/sd-daemon.h

index a69efe03f01f1bcdafa18058be391400cfb6965f..4b9c2370520a3d9050e706ec748d428887707cf8 100644 (file)
       <citerefentry><refentrytitle>sd_bus_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry><refentrytitle>sd_bus_message_set_allow_interactive_authorization</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
       <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
-      <citerefentry project='die-net'><refentrytitle>strerror</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+      <citerefentry project='die-net'><refentrytitle>strerror_r</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     </para>
   </refsect1>
 
index 31388b9c3da762e6076cdb69c599aa66dfd25d60..de402950bbb73ad87c9b40d1e33fb547b0c2d26a 100644 (file)
 
       <programlisting>sd_notifyf(0, "STATUS=Failed to start up: %s\n"
         "ERRNO=%i",
-        strerror(errno),
-        errno);</programlisting>
+        strerror_r(errnum, (char[1024]){}, 1024),
+        errnum);</programlisting>
     </example>
 
     <example>
index 442b0ac604e41e5948df7a28f969613169be3e3b..53a1d7ccfe9c0f825457d47e718af75e70fdbccf 100644 (file)
@@ -260,8 +260,8 @@ int sd_notify(int unset_environment, const char *state);
 
      sd_notifyf(0, "STATUS=Failed to start up: %s\n"
                    "ERRNO=%i",
-                   strerror(errno),
-                   errno);
+                   strerror_r(errnum, (char[1024]){}, 1024),
+                   errnum);
 
   See sd_notifyf(3) for more information.
 */