Selaa lähdekoodia

Sort all options using clang-format

Minimum required version: clang-format-6.0
bel2125 5 vuotta sitten
vanhempi
commit
a704b966e5
3 muutettua tiedostoa jossa 61 lisäystä ja 54 poistoa
  1. 42 43
      src/civetweb.c
  2. 2 2
      unittest/private.c
  3. 17 9
      unittest/public_server.c

+ 42 - 43
src/civetweb.c

@@ -2692,7 +2692,7 @@ struct mg_context {
 	unsigned int
 	    cfg_worker_threads;      /* The number of configured worker threads. */
 	pthread_t *worker_threadids; /* The worker thread IDs */
-    unsigned long starter_thread_idx; /* thread index which called mg_start */
+	unsigned long starter_thread_idx; /* thread index which called mg_start */
 
 /* Connection to thread dispatching */
 #if defined(ALTERNATIVE_QUEUE)
@@ -13468,8 +13468,8 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 {
 	struct mg_handler_info *tmp_rh, **lastref;
 	size_t urilen = strlen(uri);
-    struct mg_workerTLS tls;
-    int is_tls_set = 0;
+	struct mg_workerTLS tls;
+	int is_tls_set = 0;
 
 	if (handler_type == WEBSOCKET_HANDLER) {
 		DEBUG_ASSERT(handler == NULL);
@@ -13526,22 +13526,21 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 		return;
 	}
 
-    /* Internal callbacks have their contexts set 
-     * if called from non-related thread, context must be set
-     * since internal function assumes it exists.
-     * For an example see how handler_info_wait_unused()
-     * waits for reference to become zero
-     */
-    if (NULL == pthread_getspecific(sTlsKey))
-    {
-        is_tls_set = 1;
-        tls.is_master = -1;
-        tls.thread_idx = phys_ctx->starter_thread_idx;
+	/* Internal callbacks have their contexts set
+	 * if called from non-related thread, context must be set
+	 * since internal function assumes it exists.
+	 * For an example see how handler_info_wait_unused()
+	 * waits for reference to become zero
+	 */
+	if (NULL == pthread_getspecific(sTlsKey)) {
+		is_tls_set = 1;
+		tls.is_master = -1;
+		tls.thread_idx = phys_ctx->starter_thread_idx;
 #if defined(_WIN32)
-        tls.pthread_cond_helper_mutex = NULL;
+		tls.pthread_cond_helper_mutex = NULL;
 #endif
-        pthread_setspecific(sTlsKey, &tls);
-    }
+		pthread_setspecific(sTlsKey, &tls);
+	}
 
 	mg_lock_context(phys_ctx);
 
@@ -13584,9 +13583,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 					mg_free(tmp_rh);
 				}
 				mg_unlock_context(phys_ctx);
-                if (is_tls_set) {
-                    pthread_setspecific(sTlsKey, NULL);
-                }
+				if (is_tls_set) {
+					pthread_setspecific(sTlsKey, NULL);
+				}
 				return;
 			}
 		}
@@ -13597,9 +13596,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 		/* no handler to set, this was a remove request to a non-existing
 		 * handler */
 		mg_unlock_context(phys_ctx);
-        if (is_tls_set) {
-            pthread_setspecific(sTlsKey, NULL);
-        }
+		if (is_tls_set) {
+			pthread_setspecific(sTlsKey, NULL);
+		}
 		return;
 	}
 
@@ -13612,9 +13611,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 		mg_cry_ctx_internal(phys_ctx,
 		                    "%s",
 		                    "Cannot create new request handler struct, OOM");
-        if (is_tls_set) {
-            pthread_setspecific(sTlsKey, NULL);
-        }
+		if (is_tls_set) {
+			pthread_setspecific(sTlsKey, NULL);
+		}
 		return;
 	}
 	tmp_rh->uri = mg_strdup_ctx(uri, phys_ctx);
@@ -13624,9 +13623,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 		mg_cry_ctx_internal(phys_ctx,
 		                    "%s",
 		                    "Cannot create new request handler struct, OOM");
-        if (is_tls_set) {
-            pthread_setspecific(sTlsKey, NULL);
-        }
+		if (is_tls_set) {
+			pthread_setspecific(sTlsKey, NULL);
+		}
 		return;
 	}
 	tmp_rh->uri_len = urilen;
@@ -13636,9 +13635,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 			mg_unlock_context(phys_ctx);
 			mg_free(tmp_rh);
 			mg_cry_ctx_internal(phys_ctx, "%s", "Cannot init refcount mutex");
-            if (is_tls_set) {
-                pthread_setspecific(sTlsKey, NULL);
-            }
+			if (is_tls_set) {
+				pthread_setspecific(sTlsKey, NULL);
+			}
 			return;
 		}
 		if (0 != pthread_cond_init(&tmp_rh->refcount_cond, NULL)) {
@@ -13646,9 +13645,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 			pthread_mutex_destroy(&tmp_rh->refcount_mutex);
 			mg_free(tmp_rh);
 			mg_cry_ctx_internal(phys_ctx, "%s", "Cannot init refcount cond");
-            if (is_tls_set) {
-                pthread_setspecific(sTlsKey, NULL);
-            }
+			if (is_tls_set) {
+				pthread_setspecific(sTlsKey, NULL);
+			}
 			return;
 		}
 		tmp_rh->refcount = 0;
@@ -13668,9 +13667,9 @@ mg_set_handler_type(struct mg_context *phys_ctx,
 
 	*lastref = tmp_rh;
 	mg_unlock_context(phys_ctx);
-    if (is_tls_set) {
-        pthread_setspecific(sTlsKey, NULL);
-    }
+	if (is_tls_set) {
+		pthread_setspecific(sTlsKey, NULL);
+	}
 }
 
 
@@ -18956,12 +18955,12 @@ static
 	ctx->dd.auth_nonce_mask =
 	    (uint64_t)get_random() ^ (uint64_t)(ptrdiff_t)(options);
 
-    /* Save started thread index to reuse in other external API calls
-     * For the sake of thread synchronization all non-civetweb threads 
-     * can be considered as single external thread */
-    ctx->starter_thread_idx = (unsigned)mg_atomic_inc(&thread_idx_max);
+	/* Save started thread index to reuse in other external API calls
+	 * For the sake of thread synchronization all non-civetweb threads
+	 * can be considered as single external thread */
+	ctx->starter_thread_idx = (unsigned)mg_atomic_inc(&thread_idx_max);
 	tls.is_master = -1; /* Thread calling mg_start */
-    tls.thread_idx = ctx->starter_thread_idx;
+	tls.thread_idx = ctx->starter_thread_idx;
 #if defined(_WIN32)
 	tls.pthread_cond_helper_mutex = NULL;
 #endif

+ 2 - 2
unittest/private.c

@@ -675,10 +675,10 @@ START_TEST(test_parse_port_string)
 			             ip_family);
 		}
 		if (ip_family == 4) {
-			ck_assert_int_eq((int)so.lsa.sin.sin_family,(int)AF_INET);
+			ck_assert_int_eq((int)so.lsa.sin.sin_family, (int)AF_INET);
 		}
 		if (ip_family == 6) {
-			ck_assert_int_eq((int)so.lsa.sin.sin_family,(int)AF_INET6);
+			ck_assert_int_eq((int)so.lsa.sin.sin_family, (int)AF_INET6);
 		}
 		if (ret) {
 			/* Test valid strings only */

+ 17 - 9
unittest/public_server.c

@@ -274,7 +274,7 @@ static struct mg_context *
 test_mg_start(const struct mg_callbacks *callbacks,
               void *user_data,
               const char **configuration_options,
-			  unsigned line)
+              unsigned line)
 {
 	struct mg_context *ctx;
 	struct mg_callbacks cb;
@@ -298,12 +298,12 @@ test_mg_start(const struct mg_callbacks *callbacks,
 		/* Give the server some time to start in the test VM. */
 		/* Don't need to do this if mg_start failed. */
 		test_sleep(SLEEP_AFTER_MG_START);
-	} else if (line>0) {
+	} else if (line > 0) {
 		/* mg_start is not supposed to fail anywhere, except for
 		 * special tests (for them, line is 0). */
 		ck_abort_msg("mg_start failed in line %u, message %s",
 		             line,
-					 (lastMessage ? lastMessage : "<NULL>"));
+		             (lastMessage ? lastMessage : "<NULL>"));
 	}
 	mark_point();
 
@@ -886,7 +886,7 @@ request_test_handler(struct mg_connection *conn, void *cbdata)
 	return 1;
 }
 
-static char request_handler2_url_expected[128]={0};
+static char request_handler2_url_expected[128] = {0};
 
 /* Return the same as request_test_handler using new interfaces */
 static int
@@ -910,9 +910,12 @@ request_test_handler2(struct mg_connection *conn, void *cbdata)
 	ck_assert(ud == &g_ctx);
 	ck_assert(ud == ud2);
 
-	err_ret = mg_get_request_link(NULL, url_buffer, sizeof(url_buffer)); /* param error */
+	err_ret = mg_get_request_link(NULL,
+	                              url_buffer,
+	                              sizeof(url_buffer)); /* param error */
 	ck_assert(err_ret < 0);
-	err_ret = mg_get_request_link(conn, NULL, sizeof(url_buffer)); /* param error */
+	err_ret =
+	    mg_get_request_link(conn, NULL, sizeof(url_buffer)); /* param error */
 	ck_assert(err_ret < 0);
 	err_ret = mg_get_request_link(conn, url_buffer, 0); /* param error */
 	ck_assert(err_ret < 0);
@@ -1337,7 +1340,10 @@ START_TEST(test_request_handlers)
 		                       (void *)(ptrdiff_t)i);
 	}
 
-	sprintf(request_handler2_url_expected, "http://%s:%u/handler2", server_host, ipv4_port);
+	sprintf(request_handler2_url_expected,
+	        "http://%s:%u/handler2",
+	        server_host,
+	        ipv4_port);
 	mg_set_request_handler(ctx, "/handler2", request_test_handler2, NULL);
 
 #ifdef USE_WEBSOCKET
@@ -1594,8 +1600,10 @@ START_TEST(test_request_handlers)
 		        "e.g. by gcc test/cgi_test.c -o output/cgi_test.cgi\n\n");
 
 		/* Abort test with diagnostic message */
-		ck_abort_msg("Mandatory file %s must be built before starting the test (cwd: %s)",
-		             ebuf, cwd);
+		ck_abort_msg("Mandatory file %s must be built before starting the test "
+		             "(cwd: %s)",
+		             ebuf,
+		             cwd);
 	}
 #endif