chiark / gitweb /
manager: use more stpcpy()
[elogind.git] / src / core / manager.c
index c261b25fb658ad0f515afde1f309367c026863e5..a3eeb4afc10c9837c238bc4e1c9d739e6b9cda25 100644 (file)
@@ -148,6 +148,9 @@ static int manager_setup_notify(Manager *m) {
 static int manager_jobs_in_progress_mod_timer(Manager *m) {
         struct itimerspec its;
 
+        if (m->jobs_in_progress_watch.type != WATCH_JOBS_IN_PROGRESS)
+                return 0;
+
         zero(its);
 
         its.it_value.tv_sec = JOBS_IN_PROGRESS_WAIT_SEC;
@@ -227,32 +230,26 @@ static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned po
                         memset(p, ' ', pos-2);
                         p += pos-2;
                 }
-                memcpy(p, ANSI_RED_ON, strlen(ANSI_RED_ON));
-                p += strlen(ANSI_RED_ON);
+                p = stpcpy(p, ANSI_RED_ON);
                 *p++ = '*';
         }
 
         if (pos > 0 && pos <= width) {
-                memcpy(p, ANSI_HIGHLIGHT_RED_ON, strlen(ANSI_HIGHLIGHT_RED_ON));
-                p += strlen(ANSI_HIGHLIGHT_RED_ON);
+                p = stpcpy(p, ANSI_HIGHLIGHT_RED_ON);
                 *p++ = '*';
         }
 
-        memcpy(p, ANSI_HIGHLIGHT_OFF, strlen(ANSI_HIGHLIGHT_OFF));
-        p += strlen(ANSI_HIGHLIGHT_OFF);
+        p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
 
         if (pos < width) {
-                memcpy(p, ANSI_RED_ON, strlen(ANSI_RED_ON));
-                p += strlen(ANSI_RED_ON);
+                p = stpcpy(p, ANSI_RED_ON);
                 *p++ = '*';
                 if (pos < width-1) {
                         memset(p, ' ', width-1-pos);
                         p += width-1-pos;
                 }
-                memcpy(p, ANSI_HIGHLIGHT_OFF, strlen(ANSI_HIGHLIGHT_OFF));
-                p += strlen(ANSI_HIGHLIGHT_OFF);
+                p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
         }
-        *p = 0;
 }
 
 static void manager_print_jobs_in_progress(Manager *m) {
@@ -2373,8 +2370,10 @@ void manager_check_finished(Manager *m) {
         if (m->n_running_jobs == 0)
                 manager_unwatch_jobs_in_progress(m);
 
-        if (hashmap_size(m->jobs) > 0)
+        if (hashmap_size(m->jobs) > 0) {
+                manager_jobs_in_progress_mod_timer(m);
                 return;
+        }
 
         /* Notify Type=idle units that we are done now */
         close_pipe(m->idle_pipe);