From a1887f8b48a8d7d0ccf8ecfa1341ca638c503c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 4 Apr 2024 12:12:25 +0200 Subject: [PATCH 1/3] man: regenerate rules Fixup for dfad86b83807fa8696ca94982a5ba591b6d86a80. --- man/rules/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/rules/meson.build b/man/rules/meson.build index b67daa85fd..1ca5b105b3 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -944,7 +944,7 @@ manpages = [ ['systemd-hibernate-resume-generator', '8', [], 'ENABLE_HIBERNATE'], ['systemd-hibernate-resume.service', '8', - ['systemd-hibernate-resume', 'systemd-hibernate-clear.service'], + ['systemd-hibernate-clear.service', 'systemd-hibernate-resume'], 'ENABLE_HIBERNATE'], ['systemd-homed.service', '8', ['systemd-homed'], 'ENABLE_HOMED'], ['systemd-hostnamed.service', '8', ['systemd-hostnamed'], 'ENABLE_HOSTNAMED'], From 4cbf560edf64569bc6780e3c67b660c20743560d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 4 Apr 2024 10:57:30 +0200 Subject: [PATCH 2/3] man/notify-selfcontained-example: check argument first This is just good style. In this particular case, if the argument is incorrect and the function is not tested with $NOTIFY_SOCKET set, the user could not get the proper error until running for real. Also, remove mention of systemd. The protocol is fully generic on purpose. --- man/notify-selfcontained-example.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/man/notify-selfcontained-example.c b/man/notify-selfcontained-example.c index 90c3861374..6bbe4f2e3b 100644 --- a/man/notify-selfcontained-example.c +++ b/man/notify-selfcontained-example.c @@ -41,10 +41,7 @@ static int notify(const char *message) { _cleanup_(closep) int fd = -1; const char *socket_path; - socket_path = getenv("NOTIFY_SOCKET"); - if (!socket_path) - return 0; /* Not running under systemd? Nothing to do */ - + /* Verify the argument first */ if (!message) return -EINVAL; @@ -52,6 +49,11 @@ static int notify(const char *message) { if (message_length == 0) return -EINVAL; + /* If the variable is not set, the protocol is a noop */ + socket_path = getenv("NOTIFY_SOCKET"); + if (!socket_path) + return 0; /* Not set? Nothing to do */ + /* Only AF_UNIX is supported, with path or abstract sockets */ if (socket_path[0] != '/' && socket_path[0] != '@') return -EAFNOSUPPORT; From 3a9259d93ca8c9556a25b771e9493c8812f72f9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 4 Apr 2024 12:17:43 +0200 Subject: [PATCH 3/3] man: align strings in sd_notify() examples I think this way it's easier to see that they are part of the same argument. --- man/sd_notify.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/sd_notify.xml b/man/sd_notify.xml index 22b351cad3..e1c4073e7f 100644 --- a/man/sd_notify.xml +++ b/man/sd_notify.xml @@ -533,8 +533,8 @@ sd_notifyf(0, "READY=1\n" - "STATUS=Processing requests…\n" - "MAINPID=%lu", + "STATUS=Processing requests…\n" + "MAINPID=%lu", (unsigned long) getpid()); @@ -545,7 +545,7 @@ sd_notifyf(0, "READY=1\n" sd_notifyf(0, "STATUS=Failed to start up: %s\n" - "ERRNO=%i", + "ERRNO=%i", strerror_r(errnum, (char[1024]){}, 1024), errnum);