This improves self-documentation and readability of the code.
---
 sysklogd/syslogd.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 40644fb97484..22bd76bf5087 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -857,14 +857,16 @@ static char *timestamp_from_time(const time_t *time)
  * that there is no timestamp, short-circuiting the test. */
 static void timestamp_and_log(int pri, char *msg, int len)
 {
+       /* Jan 18 00:11:22 msg... */
+       /* 01234567890123456 */
+       const bool msg_has_timestamp = (len >= 16 &&
+               msg[ 3] == ' ' && msg[ 6] == ' ' &&
+               msg[ 9] == ':' && msg[12] == ':' &&
+               msg[15] == ' ');
        char *timestamp = NULL;
        time_t now;
 
-       /* Jan 18 00:11:22 msg... */
-       /* 01234567890123456 */
-       if (len >= 16 && msg[3] == ' ' && msg[6] == ' '
-        && msg[9] == ':' && msg[12] == ':' && msg[15] == ' '
-       ) {
+       if (msg_has_timestamp) {
                if (!(option_mask32 & OPT_timestamp)) {
                        /* use message timestamp */
 #if ENABLE_FEATURE_SYSLOGD_UTC
-- 
2.45.0

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to