@@ -126,26 +126,22 @@ compare_child_info(gconstpointer p1, gconstpointer p2)
126
126
}
127
127
128
128
static const char *
129
- get_child_status (struct child_info_s * ci , gboolean * faulty )
129
+ get_child_status (struct child_info_s * ci )
130
130
{
131
131
struct keyword_set_s * kw ;
132
132
133
133
kw = flag_color ? & KEYWORDS_COLOR : & KEYWORDS_NORMAL ;
134
134
135
135
if (ci -> broken ) {
136
- * faulty = TRUE;
137
136
return kw -> broken ;
138
137
}
139
138
if (!ci -> enabled ) {
140
- * faulty = FALSE;
141
139
return kw -> disabled ;
142
140
}
143
141
if (ci -> pid <= 0 ) {
144
- * faulty = TRUE;
145
142
return kw -> down ;
146
143
}
147
144
148
- * faulty = FALSE;
149
145
return kw -> up ;
150
146
}
151
147
@@ -421,27 +417,30 @@ command_status(int lvl, int argc, char **args)
421
417
break ;
422
418
}
423
419
424
- int count_faulty = 0 , count_all = 0 , count_misses = 0 ;
420
+ count_misses = 0 , count_broken = 0 , count_down = 0 ;
421
+ struct keyword_set_s * kw ;
422
+ kw = flag_color ? & KEYWORDS_COLOR : & KEYWORDS_NORMAL ;
425
423
426
424
/* iterate on the lines */
427
425
for (GList * l = jobs ; l ;l = l -> next ) {
428
426
char str_time [20 ] = "---------- --------" ;
429
427
const char * str_status = "-" ;
430
428
struct child_info_s * ci = NULL ;
431
- gboolean faulty = FALSE;
432
429
433
430
ci = l -> data ;
434
431
435
432
/* Prepare some fields */
436
433
if (ci -> pid > 0 )
437
434
strftime (str_time , sizeof (str_time ), "%Y-%m-%d %H:%M:%S" ,
438
435
gmtime (& (ci -> last_start_attempt )));
439
- str_status = get_child_status (ci , & faulty );
436
+ str_status = get_child_status (ci );
440
437
441
438
/* Manage counters */
442
- if (faulty )
443
- count_faulty ++ ;
444
- count_all ++ ;
439
+
440
+ if (str_status == kw -> down )
441
+ count_down ++ ;
442
+ if (str_status == kw -> broken )
443
+ count_broken ++ ;
445
444
446
445
/* Print now! */
447
446
switch (lvl ) {
@@ -475,7 +474,16 @@ command_status(int lvl, int argc, char **args)
475
474
g_list_free_full (all_jobs , (GDestroyNotify )child_info_free );
476
475
g_list_free (jobs );
477
476
478
- return !(!count_misses && !count_faulty && (!argc || count_all > 0 ));
477
+ int rc = 0 ;
478
+
479
+ if (count_down )
480
+ rc |= 1 ;
481
+ if (count_misses )
482
+ rc |= 2 ;
483
+ if (count_broken )
484
+ rc |= 4 ;
485
+
486
+ return rc ;
479
487
}
480
488
481
489
static int
0 commit comments