瀏覽代碼

Move static_assert from inside a function to the definition

bel 10 年之前
父節點
當前提交
82ee8b5cca
共有 1 個文件被更改,包括 10 次插入6 次删除
  1. 10 6
      src/civetweb.c

+ 10 - 6
src/civetweb.c

@@ -893,6 +893,14 @@ static struct mg_option config_options[] = {
 
     {NULL, CONFIG_TYPE_UNKNOWN, NULL}};
 
+
+/* Check if the config_options and the corresponding enum have compatible
+ * sizes. */
+mg_static_assert((sizeof(config_options) / sizeof(config_options[0])) ==
+                 (NUM_OPTIONS + 1),
+                "config_options and enum not sync");
+
+
 struct mg_request_handler_info {
 	/* Name/Pattern of the URI. */
 	char *uri;
@@ -1069,8 +1077,10 @@ typedef struct tagTHREADNAME_INFO {
 void mg_set_thread_name(const char *name) {
 	char threadName[16]; /* Max. thread length in Linux/OSX/.. */
 
+    /* TODO: use strcpy and strcat instad of snprintf, use server name, don't return */
 	if (snprintf(threadName, sizeof(threadName), "civetweb-%s", name) < 0)
 		return;
+
 	threadName[sizeof(threadName) - 1] = 0;
 
 #if defined(_WIN32)
@@ -8862,12 +8872,6 @@ struct mg_context *mg_start(const struct mg_callbacks *callbacks,
 		InitializeCriticalSection(&global_log_file_lock);
 #endif /* _WIN32 && !__SYMBIAN32__ */
 
-	/* Check if the config_options and the corresponding enum have compatible
-	 * sizes. */
-	mg_static_assert((sizeof(config_options) / sizeof(config_options[0])) ==
-	                     (NUM_OPTIONS + 1),
-	                 "config_options and enum not sync");
-
 	/* Allocate context and initialize reasonable general case defaults.
 	 * TODO(lsm): do proper error handling here. */
 	if ((ctx = (struct mg_context *)mg_calloc(1, sizeof(*ctx))) == NULL) {