فهرست منبع

Corosync: Fix build when done with --enable-fatal-warnings

Signed-off-by: Jerome Flesch <jerome.flesch@netasq.com>
Reviewed-by: Jan Friesse<jfriesse@redhat.com>
Jerome Flesch 14 سال پیش
والد
کامیت
fe51e70367
7فایلهای تغییر یافته به همراه30 افزوده شده و 8 حذف شده
  1. 1 1
      exec/coroipcs.c
  2. 6 2
      exec/coropoll.c
  3. 14 3
      exec/main.c
  4. 1 1
      exec/totemconfig.c
  5. 2 0
      exec/tsafe.c
  6. 1 0
      exec/util.h
  7. 5 1
      tools/corosync-notifyd.c

+ 1 - 1
exec/coroipcs.c

@@ -1241,7 +1241,7 @@ static void memcpy_dwrap (struct conn_info *conn_info, void *msg, unsigned int l
 	write_idx = conn_info->control_buffer->write;
 
 	memcpy (&conn_info->dispatch_buffer[write_idx], msg, len);
-	conn_info->control_buffer->write = ((write_idx + len + 7) & 0xFFFFFFFF8) % conn_info->dispatch_size;
+	conn_info->control_buffer->write = ((write_idx + len + 7) & 0xFFFFFFF8) % conn_info->dispatch_size;
 }
 
 static void msg_send (void *conn, const struct iovec *iov, unsigned int iov_len,

+ 6 - 2
exec/coropoll.c

@@ -258,7 +258,9 @@ int poll_dispatch_modify (
 			poll_instance->poll_entries[i].dispatch_fn = dispatch_fn;
 			if (change_notify) {
 				char buf = 1;
-				write (poll_instance->pipefds[1], &buf, 1);
+retry_write:
+				if (write (poll_instance->pipefds[1], &buf, 1) < 0 && errno == EINTR )
+					goto retry_write;
 			}
 
 			goto error_put;
@@ -499,7 +501,9 @@ retry_poll:
 
 		if (poll_instance->ufds[0].revents) {
 			char buf;
-			read (poll_instance->ufds[0].fd, &buf, 1);
+retry_read:
+			if (read (poll_instance->ufds[0].fd, &buf, 1) < 0 && errno == EINTR)
+				goto retry_read;
 			goto rebuild_poll;
 		}
 		poll_entry_count = poll_instance->poll_entry_count;

+ 14 - 3
exec/main.c

@@ -526,6 +526,8 @@ static void priv_drop (void)
 
 static void corosync_tty_detach (void)
 {
+	FILE *r;
+
 	/*
 	 * Disconnect from TTY if this is not a debug run
 	 */
@@ -550,9 +552,18 @@ static void corosync_tty_detach (void)
 	/*
 	 * Map stdin/out/err to /dev/null.
 	 */
-	freopen("/dev/null", "r", stdin);
-	freopen("/dev/null", "a", stderr);
-	freopen("/dev/null", "a", stdout);
+	r = freopen("/dev/null", "r", stdin);
+	if (r == NULL) {
+		corosync_exit_error (AIS_DONE_STD_TO_NULL_REDIR);
+	}
+	r = freopen("/dev/null", "a", stderr);
+	if (r == NULL) {
+		corosync_exit_error (AIS_DONE_STD_TO_NULL_REDIR);
+	}
+	r = freopen("/dev/null", "a", stdout);
+	if (r == NULL) {
+		corosync_exit_error (AIS_DONE_STD_TO_NULL_REDIR);
+	}
 }
 
 static void corosync_mlockall (void)

+ 1 - 1
exec/totemconfig.c

@@ -473,7 +473,7 @@ int totem_config_validate (
 			goto parse_error;
 		}
 
-		if (totem_config->interfaces[i].ttl > 255 || totem_config->interfaces[i].ttl < 0) {
+		if (totem_config->interfaces[i].ttl > 255) {
 			error_reason = "Invalid TTL (should be 0..255)";
 			goto parse_error;
 		}

+ 2 - 0
exec/tsafe.c

@@ -978,6 +978,7 @@ void setpwent(void)
 	assert(0);
 }
 
+#ifdef HAVE_UTMPX_H
 void setutxent(void)
 {
 	static void (*real_setutxent)(void) = NULL;
@@ -989,6 +990,7 @@ void setutxent(void)
 	}
 	assert(0);
 }
+#endif
 
 char *strerror(int errnum)
 {

+ 1 - 0
exec/util.h

@@ -63,6 +63,7 @@ enum e_ais_done {
 	AIS_DONE_DIR_NOT_PRESENT = 16,
 	AIS_DONE_AQUIRE_LOCK = 17,
 	AIS_DONE_ALREADY_RUNNING = 18,
+	AIS_DONE_STD_TO_NULL_REDIR = 19,
 };
 
 static inline cs_error_t hdb_error_to_cs (int res)		\

+ 5 - 1
tools/corosync-notifyd.c

@@ -1033,7 +1033,11 @@ main(int argc, char *argv[])
 	_cs_check_config();
 
 	if (!conf[CS_NTF_FG]) {
-		daemon(0, 0);
+		if (daemon(0, 0) < 0)
+		{
+			perror("daemon() failed");
+			return EXIT_FAILURE;
+		}
 	}
 
 	num_notifiers = 0;