*p++ = '*';
if (pos < width-1)
p = mempset(p, ' ', width-1-pos);
- p = stpcpy(p, ANSI_HIGHLIGHT_OFF);
+ strcpy(p, ANSI_HIGHLIGHT_OFF);
}
}
/* m->n_running_jobs must be consistent with the contents of m->jobs,
* so the above loop must have succeeded in finding j. */
assert(counter == print_nr + 1);
+ assert(j);
cylon_pos = m->jobs_in_progress_iteration % 14;
if (cylon_pos >= 8)
int manager_reload(Manager *m) {
int r, q;
- FILE *f;
- FDSet *fds;
+ _cleanup_fclose_ FILE *f = NULL;
+ _cleanup_fdset_free_ FDSet *fds = NULL;
assert(m);
fds = fdset_new();
if (!fds) {
m->n_reloading --;
- r = -ENOMEM;
- goto finish;
+ return -ENOMEM;
}
r = manager_serialize(m, f, fds, false);
if (r < 0) {
m->n_reloading --;
- goto finish;
+ return r;
}
if (fseeko(f, 0, SEEK_SET) < 0) {
m->n_reloading --;
- r = -errno;
- goto finish;
+ return -errno;
}
/* From here on there is no way back. */
m->send_reloading_done = true;
-finish:
- if (f)
- fclose(f);
-
- if (fds)
- fdset_free(fds);
-
return r;
}
bool saved_attr_valid = false;
struct winsize ws;
int kmsg_socket_pair[2] = { -1, -1 };
- FDSet *fds = NULL;
+ _cleanup_fdset_free_ FDSet *fds = NULL;
log_parse_environment();
log_open();
free(arg_directory);
free(arg_machine);
- fdset_free(fds);
-
return r;
}
***/
#include "set.h"
+#include "util.h"
typedef struct FDSet FDSet;
#define FDSET_FOREACH(fd, fds, i) \
for ((i) = ITERATOR_FIRST, (fd) = fdset_iterate((fds), &(i)); (fd) >= 0; (fd) = fdset_iterate((fds), &(i)))
+
+static inline void fdset_freep(FDSet **fds) {
+ if (*fds)
+ fdset_free(*fds);
+}
+#define _cleanup_fdset_free_ _cleanup_(fdset_freep)