From 184525687c73d3d858d599822422d145fa66f7d2 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 2 Jan 2022 06:52:44 +0100 Subject: [PATCH] Follow-up to ec2900e: minor cleanup + signed vs unsigned comparison Minor coding style cleanup. Also, clang complained of a signed vs unsigned comparison in service_retry(), max(timeout, svc->restart_tmo) Signed-off-by: Joachim Wiberg --- src/service.c | 7 +++---- src/svc.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/service.c b/src/service.c index c0d646f7..fc2ea3cc 100644 --- a/src/service.c +++ b/src/service.c @@ -1204,13 +1204,12 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file) else if (!strncasecmp(cmd, "restart:", 8)) restart_max = atoi(&cmd[8]); else if (!strncasecmp(cmd, "restarttmo:", 11)) - restart_tmo = atoi(&cmd[11])*1000; + restart_tmo = atoi(&cmd[11]) * 1000; else if (!strncasecmp(cmd, "norestart", 9)) restart_max = 0; else if (!strncasecmp(cmd, "oncrash:", 8)) { - if (!strncasecmp(&cmd[8], "reboot", 6)) { + if (!strncasecmp(&cmd[8], "reboot", 6)) oncrash_action = SVC_ONCRASH_REBOOT; - } } else if (!strncasecmp(cmd, "respawn", 7)) respawn = 1; @@ -1610,8 +1609,8 @@ static void service_post_script(svc_t *svc) static void service_retry(svc_t *svc) { - int timeout; char *restart_cnt = (char *)&svc->restart_cnt; + int timeout; service_timeout_cancel(svc); if (svc->respawn) { diff --git a/src/svc.h b/src/svc.h index e07b0b99..bf647ba3 100644 --- a/src/svc.h +++ b/src/svc.h @@ -138,8 +138,8 @@ typedef struct svc { /* Counters */ char once; /* run/task, (at least) once per runlevel */ unsigned char restart_max; /* Maximum number of restarts allowed */ - unsigned restart_tmo; /* Time required for the service to start. */ - unsigned oncrash_action; /* Action to perform in crashed state. */ + int restart_tmo; /* Time required for the service to start. */ + unsigned char oncrash_action; /* Action to perform in crashed state. */ char respawn; /* ttys, or services with `respawn`, never increment restart_cnt */ const char restart_cnt; /* Incremented for each restart by service monitor. */