From d95b6887f6ae7e974fa7ba586457d1246fffdc91 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Thu, 24 Oct 2024 20:04:57 +0200 Subject: [PATCH] docs/CODING_STYLE: beef up docs regarding period and "ignoring" in errors Prompted by https://github.com/systemd/systemd/pull/34799#discussion_r1807924665 --- docs/CODING_STYLE.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md index 48fa4b093d0..32e22f331fc 100644 --- a/docs/CODING_STYLE.md +++ b/docs/CODING_STYLE.md @@ -519,6 +519,21 @@ SPDX-License-Identifier: LGPL-2.1-or-later return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to read ..."); ``` +- If the error shall be ignored rather than propagated, insert ", ignoring" + at the end: + + ```c + r = parse(...); + if (r < 0) + log_debug_errno(r, "Failed to parse ..., ignoring: %m"); + else + parsed = r; + ``` + +- Insert a period at the end of the log message if no errno shall be logged. + Bus errors however should not end with a period, because they are passed to + the client where the message could be embedded within other texts. + ## Memory Allocation - Always check OOM. There is no excuse. In program code, you can use