chiark / gitweb /
Unify GREEDY_REALLOC and GREEDY_REALLOC_T
[elogind.git] / src / journal / journal-remote.c
index 6d7ba6caa06e137ee0aae58d16b016702d9a24c5..794298fe6f76a1c09431ed5f1e24ee0fbff479b5 100644 (file)
@@ -89,7 +89,7 @@ static int spawn_child(const char* child, char** argv) {
         if (child_pid < 0) {
                 r = -errno;
                 log_error("Failed to fork: %m");
-                close_pipe(fd);
+                safe_close_pair(fd);
                 return r;
         }
 
@@ -101,9 +101,7 @@ static int spawn_child(const char* child, char** argv) {
                         _exit(EXIT_FAILURE);
                 }
 
-                r = close_pipe(fd);
-                if (r < 0)
-                        log_warning("Failed to close pipe fds: %m");
+                safe_close_pair(fd);
 
                 /* Make sure the child goes away when the parent dies */
                 if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)
@@ -142,7 +140,7 @@ static int spawn_curl(char* url) {
 
 static int spawn_getter(char *getter, char *url) {
         int r;
-        char _cleanup_strv_free_ **words = NULL, **words2 = NULL;
+        char _cleanup_strv_free_ **words = NULL;
 
         assert(getter);
         words = strv_split_quoted(getter);
@@ -228,8 +226,8 @@ typedef struct MHDDaemonWrapper {
 
 typedef struct RemoteServer {
         RemoteSource **sources;
-        ssize_t sources_size;
-        ssize_t active;
+        size_t sources_size;
+        size_t active;
 
         sd_event *events;
         sd_event_source *sigterm_event, *sigint_event, *listen_event;
@@ -259,7 +257,7 @@ static int get_source_for_fd(RemoteServer *s, int fd, RemoteSource **source) {
         assert(fd >= 0);
         assert(source);
 
-        if (!GREEDY_REALLOC0_T(s->sources, s->sources_size, fd + 1))
+        if (!GREEDY_REALLOC0(s->sources, s->sources_size, fd + 1))
                 return log_oom();
 
         if (s->sources[fd] == NULL) {
@@ -278,8 +276,7 @@ static int remove_source(RemoteServer *s, int fd) {
         RemoteSource *source;
 
         assert(s);
-        assert(fd >= 0);
-        assert(fd < s->sources_size);
+        assert(fd >= 0 && fd < (ssize_t) s->sources_size);
 
         source = s->sources[fd];
         if (source) {
@@ -839,7 +836,7 @@ static int remoteserver_init(RemoteServer *s) {
 
 static int server_destroy(RemoteServer *s) {
         int r;
-        ssize_t i;
+        size_t i;
         MHDDaemonWrapper *d;
 
         r = writer_close(&s->writer);
@@ -881,7 +878,7 @@ static int dispatch_raw_source_event(sd_event_source *event,
         RemoteSource *source;
         int r;
 
-        assert(fd < s->sources_size);
+        assert(fd >= 0 && fd < (ssize_t) s->sources_size);
         source = s->sources[fd];
         assert(source->fd == fd);