Browse Source

Avoid yet another spurious uninitialized var warning

bel 8 years ago
parent
commit
e1b2c73775
2 changed files with 6 additions and 10 deletions
  1. 4 8
      src/civetweb.c
  2. 2 2
      test/public_server.c

+ 4 - 8
src/civetweb.c

@@ -4695,9 +4695,9 @@ push(struct mg_context *ctx,
 #else
 #else
 	typedef size_t len_t;
 	typedef size_t len_t;
 #endif
 #endif
-    
-	if (timeout > 0) {		
-        start = mg_get_current_time_ns();
+
+	if (timeout > 0) {
+		start = mg_get_current_time_ns();
 		timeout_ns = (uint64_t)(timeout * 1.0E9);
 		timeout_ns = (uint64_t)(timeout * 1.0E9);
 	}
 	}
 
 
@@ -5002,7 +5002,7 @@ pull_all(FILE *fp, struct mg_connection *conn, char *buf, int len)
 {
 {
 	int n, nread = 0;
 	int n, nread = 0;
 	double timeout = -1.0;
 	double timeout = -1.0;
-	uint64_t start_time, now, timeout_ns;
+	uint64_t start_time = 0, now = 0, timeout_ns = 0;
 
 
 	if (conn->ctx->config[REQUEST_TIMEOUT]) {
 	if (conn->ctx->config[REQUEST_TIMEOUT]) {
 		timeout = atoi(conn->ctx->config[REQUEST_TIMEOUT]) / 1000.0;
 		timeout = atoi(conn->ctx->config[REQUEST_TIMEOUT]) / 1000.0;
@@ -5010,10 +5010,6 @@ pull_all(FILE *fp, struct mg_connection *conn, char *buf, int len)
 	if (timeout >= 0.0) {
 	if (timeout >= 0.0) {
 		start_time = mg_get_current_time_ns();
 		start_time = mg_get_current_time_ns();
 		timeout_ns = (uint64_t)(timeout * 1.0E9);
 		timeout_ns = (uint64_t)(timeout * 1.0E9);
-	} else {
-		/* The variable is not used, but if it is left uninitialized,
-		 * we get a spurious warning. */
-		start_time = 0;
 	}
 	}
 
 
 	while (len > 0 && conn->ctx->stop_flag == 0) {
 	while (len > 0 && conn->ctx->stop_flag == 0) {

+ 2 - 2
test/public_server.c

@@ -973,7 +973,7 @@ websocket_client_data_handler(struct mg_connection *conn,
 	struct tclient_data *pclient_data =
 	struct tclient_data *pclient_data =
 	    (struct tclient_data *)mg_get_user_data(ctx);
 	    (struct tclient_data *)mg_get_user_data(ctx);
 
 
-	ck_assert_ptr_eq(user_data, (void*)pclient_data);
+	ck_assert_ptr_eq(user_data, (void *)pclient_data);
 
 
 	ck_assert(pclient_data != NULL);
 	ck_assert(pclient_data != NULL);
 	ck_assert_int_gt(flags, 128);
 	ck_assert_int_gt(flags, 128);
@@ -1011,7 +1011,7 @@ websocket_client_close_handler(const struct mg_connection *conn,
 	struct tclient_data *pclient_data =
 	struct tclient_data *pclient_data =
 	    (struct tclient_data *)mg_get_user_data(ctx);
 	    (struct tclient_data *)mg_get_user_data(ctx);
 
 
-	ck_assert_ptr_eq(user_data, (void*)pclient_data);
+	ck_assert_ptr_eq(user_data, (void *)pclient_data);
 
 
 	ck_assert(pclient_data != NULL);
 	ck_assert(pclient_data != NULL);