From e7832e2ca78e957eb92a231beee5be314d377fa5 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 10 Apr 2016 19:56:13 +0200 Subject: [PATCH 1/4] FTBFS followup issue #24 Add missing return keyword to inline function svc_is_starting() Signed-off-by: Joachim Nilsson --- svc.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/svc.h b/svc.h index 44172de7..0ed161ee 100644 --- a/svc.h +++ b/svc.h @@ -169,9 +169,9 @@ int svc_is_unique (svc_t *svc); static inline int svc_in_runlevel(svc_t *svc, int runlevel) { return svc && ISSET(svc->runlevels, runlevel); } static inline int svc_has_sighup(svc_t *svc) { return svc && 0 != svc->sighup; } -static inline void svc_starting (svc_t *svc) { svc->starting = 1; } -static inline void svc_started (svc_t *svc) { svc->starting = 0; } -static inline int svc_is_starting(svc_t *svc) { 0 != svc->starting; } +static inline void svc_starting (svc_t *svc) { svc->starting = 1; } +static inline void svc_started (svc_t *svc) { svc->starting = 0; } +static inline int svc_is_starting(svc_t *svc) { return 0 != svc->starting; } static inline int svc_is_dynamic(svc_t *svc) { return svc && 0 != svc->mtime; } static inline int svc_is_removed(svc_t *svc) { return svc && -1 == svc->dirty; } From cfa155deae11bdf62efbe88039d56635bb7e6d7f Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 10 Apr 2016 19:57:48 +0200 Subject: [PATCH 2/4] Minor cleanup Signed-off-by: Joachim Nilsson --- plugins/pidfile.c | 2 +- service.c | 2 +- svc.c | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index fee45573..41aa86ea 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -25,7 +25,7 @@ static void pidfile_callback(void *UNUSED(arg), int fd, int UNUSED(events)) sz = read(fd, ev_buf, sizeof(ev_buf)); if (sz <= 0) { - _pe("invalid inotify event\n"); + _pe("invalid inotify event"); return; } diff --git a/service.c b/service.c index 5794b0b2..f37305ab 100644 --- a/service.c +++ b/service.c @@ -779,7 +779,7 @@ restart: enabled = service_enabled(svc); _d("%20s(%4d): %8s %3sabled/%-7s cond:%-4s", svc->cmd, svc->pid, - svc_status(svc), enabled? "en" : "dis", svc_dirtystr(svc), + svc_status(svc), enabled ? "en" : "dis", svc_dirtystr(svc), condstr(cond_get_agg(svc->cond))); switch(svc->state) { diff --git a/svc.c b/svc.c index 3b7ed7d7..fb241b22 100644 --- a/svc.c +++ b/svc.c @@ -429,8 +429,10 @@ char *svc_status(svc_t *svc) case SVC_BLOCK_INETD_BUSY: return "busy"; } + case SVC_DONE_STATE: return "done"; + case SVC_STOPPING_STATE: switch (svc->type) { case SVC_TYPE_INETD_CONN: @@ -440,10 +442,13 @@ char *svc_status(svc_t *svc) default: return "stopping"; } + case SVC_WAITING_STATE: return "waiting"; + case SVC_READY_STATE: return "ready"; + case SVC_RUNNING_STATE: return "running"; @@ -460,8 +465,8 @@ const char *svc_dirtystr(svc_t *svc) return "updated"; else if (svc_is_changed(svc)) return "UNKNOWN"; - else - return "clean"; + + return "clean"; } /* Same base service, return unique ID */ From a2177a8063d3900101331fa8b785d83a0f1134fb Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 10 Apr 2016 19:58:13 +0200 Subject: [PATCH 3/4] Fix GCC warning for signed vs unsigned comparison Signed-off-by: Joachim Nilsson --- plugins/pidfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index 41aa86ea..5966fe2a 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -29,7 +29,7 @@ static void pidfile_callback(void *UNUSED(arg), int fd, int UNUSED(events)) return; } - for (ev = (void *)ev_buf; sz > sizeof(*ev); + for (ev = (void *)ev_buf; sz > (ssize_t)sizeof(*ev); len = sizeof(*ev) + ev->len, ev = (void *)ev + len, sz -= len) { /* ev = (void *)(ev + 1) + ev->len, sz -= sizeof(*ev) + ev->len) { */ if (!ev->mask || !strstr(ev->name, ".pid")) From da76cf4f75c12ea6fe6d39d095136389318e99b4 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 10 Apr 2016 19:58:46 +0200 Subject: [PATCH 4/4] Check return value from strtok(), may be NULL Signed-off-by: Joachim Nilsson --- plugins/pidfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/pidfile.c b/plugins/pidfile.c index 5966fe2a..7fdb4f6e 100644 --- a/plugins/pidfile.c +++ b/plugins/pidfile.c @@ -36,6 +36,9 @@ static void pidfile_callback(void *UNUSED(arg), int fd, int UNUSED(events)) continue; basename = strtok(ev->name, "."); + if (!basename) + continue; + svc = svc_find_by_nameid(basename, 1); if (!svc) continue;