- active_len = strlen("ACTIVE");
- sub_len = strlen("SUB");
- job_len = strlen("JOB");
- for (const struct unit_info *u = unit_infos; u < unit_infos + c; u++) {
- if (output_show_job(u)) {
- active_len = MAX(active_len, strlen(u->active_state));
- sub_len = MAX(sub_len, strlen(u->sub_state));
- if (u->job_id != 0)
- job_len = MAX(job_len, strlen(u->job_type));
- }
+ active_len = sizeof("ACTIVE")-1;
+ sub_len = sizeof("SUB")-1;
+ job_len = sizeof("JOB")-1;
+
+ for (u = unit_infos; u < unit_infos + c; u++) {
+ if (!output_show_job(u))
+ continue;
+
+ active_len = MAX(active_len, strlen(u->active_state));
+ sub_len = MAX(sub_len, strlen(u->sub_state));
+ if (u->job_id != 0)
+ job_len = MAX(job_len, strlen(u->job_type));