Kaynağa Gözat

Fix some warnings

bel2125 4 yıl önce
ebeveyn
işleme
42dcb51bac
4 değiştirilmiş dosya ile 39 ekleme ve 29 silme
  1. 6 7
      src/civetweb.c
  2. 12 5
      src/mod_http2.inl
  3. 1 1
      src/mod_lua.inl
  4. 20 16
      src/third_party/LuaXML_lib.c

+ 6 - 7
src/civetweb.c

@@ -12619,8 +12619,8 @@ read_websocket(struct mg_connection *conn,
 									mg_cry_internal(
 									    conn,
 									    "Out of memory: Cannot allocate "
-									    "inflate buffer of %i bytes",
-									    inflate_buf_size);
+									    "inflate buffer of %lu bytes",
+									    (unsigned long)inflate_buf_size);
 									exit_by_callback = 1;
 									break;
 								}
@@ -12630,9 +12630,8 @@ read_websocket(struct mg_connection *conn,
 								           - inflate_buf_size_old);
 								conn->websocket_inflate_state.next_out =
 								    inflated + inflate_buf_size_old;
-								int ret =
-								    inflate(&conn->websocket_inflate_state,
-								            Z_SYNC_FLUSH);
+								ret = inflate(&conn->websocket_inflate_state,
+								              Z_SYNC_FLUSH);
 								if (ret == Z_NEED_DICT || ret == Z_DATA_ERROR
 								    || ret == Z_MEM_ERROR) {
 									mg_cry_internal(
@@ -12807,8 +12806,8 @@ mg_websocket_write_exec(struct mg_connection *conn,
 		if (deflated == NULL) {
 			mg_cry_internal(
 			    conn,
-			    "Out of memory: Cannot allocate deflate buffer of %i bytes",
-			    deflated_size);
+			    "Out of memory: Cannot allocate deflate buffer of %lu bytes",
+			    (unsigned long)deflated_size);
 			mg_unlock_connection(conn);
 			return -1;
 		}

+ 12 - 5
src/mod_http2.inl

@@ -948,7 +948,7 @@ http2_send_response_headers(struct mg_connection *conn)
 	uint8_t header_bin[1024];
 	uint16_t header_len = 0;
 	int has_date = 0;
-	int has_connection = 0;
+	int has_connection_header = 0;
 	int i;
 
 	if ((conn->status_code < 100) || (conn->status_code > 999)) {
@@ -995,7 +995,7 @@ http2_send_response_headers(struct mg_connection *conn)
 		/* Filter headers not valid in HTTP/2 */
 		if (!mg_strcasecmp("Connection",
 		                   conn->response_info.http_headers[i].name)) {
-			has_connection = 1;
+			has_connection_header = 1;
 			continue; /* do not send */
 		}
 
@@ -1063,6 +1063,10 @@ http2_send_response_headers(struct mg_connection *conn)
 
 	DEBUG_TRACE("HTTP2 response header sent: stream %u", conn->http2.stream_id);
 
+
+	(void)has_connection_header; /* ignore for the moment */
+
+
 	return 42; /* TODO */
 }
 
@@ -1238,7 +1242,6 @@ handle_http2(struct mg_connection *conn)
 	int bytes_read;
 	uint8_t *buf;
 	int my_settings_accepted = 0;
-	int my_settings_sent;
 	const char *my_hpack_headers[128];
 
 	struct http2_settings client_settings = http2_default_settings;
@@ -1246,7 +1249,6 @@ handle_http2(struct mg_connection *conn)
 
 	/* Send own settings */
 	http2_send_settings(conn, &http2_civetweb_server_settings);
-	my_settings_sent = 1;
 	// http2_send_window(conn, 0, /* 0x3fff0001 */ 1024*1024);
 
 	/* initialize hpack header table with predefined header fields */
@@ -1319,7 +1321,7 @@ handle_http2(struct mg_connection *conn)
 
 		case 0: /* DATA */
 		{
-			int i = 0; /* TODO */
+			/* TODO */
 			DEBUG_TRACE("%s", "HTTP2 DATA frame?");
 		} break;
 
@@ -1716,6 +1718,11 @@ handle_http2(struct mg_connection *conn)
 			DEBUG_TRACE("%s", "Unknown frame type");
 			goto clean_http2;
 		}
+
+		/* not used in the moment */
+		(void)frame_is_end_stream;
+		(void)frame_is_end_headers;
+		(void)client_settings;
 	}
 
 clean_http2:

+ 1 - 1
src/mod_lua.inl

@@ -104,7 +104,7 @@ reg_llstring(struct lua_State *L,
 
 
 #define reg_string(L, name, val)                                               \
-	reg_lstring(L, name, val, val ? strlen(val) : 0)
+	reg_lstring(L, name, val, (val != NULL) ? strlen(val) : 0)
 
 
 static void

+ 20 - 16
src/third_party/LuaXML_lib.c

@@ -53,14 +53,18 @@ THE SOFTWARE.
 #if LUA_VERSION_NUM >= 502
 
 // lua_compare() has replaced lua_equal()
+#if !defined(lua_equal)
 #define lua_equal(L, index1, index2) lua_compare(L, index1, index2, LUA_OPEQ)
+#endif
 
 #endif
 /* API changes for 5.3+ */
 #if LUA_VERSION_NUM >= 503
 
 // luaL_optinteger() has replaced luaL_optint()
+#if !defined(luaL_optint)
 #define luaL_optint(L, arg, d) luaL_optinteger(L, arg, d)
+#endif
 
 #endif
 
@@ -253,7 +257,7 @@ typedef struct Tokenizer_s {
 	enum whitespace_mode mode;
 } Tokenizer;
 
-Tokenizer *
+static Tokenizer *
 Tokenizer_new(const char *str, size_t str_size, enum whitespace_mode mode)
 {
 	Tokenizer *tok = calloc(1, sizeof(Tokenizer));
@@ -263,7 +267,7 @@ Tokenizer_new(const char *str, size_t str_size, enum whitespace_mode mode)
 	return tok;
 }
 
-void
+static void
 Tokenizer_delete(Tokenizer *tok)
 {
 	free(tok->m_token);
@@ -271,7 +275,7 @@ Tokenizer_delete(Tokenizer *tok)
 }
 
 #if LUAXML_DEBUG
-void
+static void
 Tokenizer_print(Tokenizer *tok)
 {
 	printf("  @%u %s\n",
@@ -315,7 +319,7 @@ Tokenizer_append(Tokenizer *tok, char ch)
 	tok->m_token[++tok->m_token_size] = 0;
 }
 
-const char *
+static const char *
 Tokenizer_next(Tokenizer *tok)
 {
 	// NUL-terminated strings for the special tokens
@@ -475,7 +479,7 @@ should ever change).
 its tag changed); otherwise the result will be the current tag of `var`
 (normally a string).
 */
-int
+static int
 Xml_tag(lua_State *L)
 {
 	// the function will only operate on tables
@@ -520,7 +524,7 @@ or _(2)_ the tag of the new LuaXML object
 @return  LuaXML object, either newly created or the conversion of `arg`;
 optionally tagged as requested
 */
-int
+static int
 Xml_new(lua_State *L)
 {
 	if (!lua_istable(L, 1)) {
@@ -550,7 +554,7 @@ optionally sets tag
 @tparam ?string tag  the tag of the appended LuaXML object
 @return  appended LuaXML object, or `nil` in case of errors
 */
-int
+static int
 Xml_append(lua_State *L)
 {
 	if (lua_type(L, 1) == LUA_TTABLE) {
@@ -684,7 +688,7 @@ defaults to `WS_TRIM` (compatible to previous LuaXML versions)
 
 @return  a LuaXML object containing the XML data, or `nil` in case of errors
 */
-int
+static int
 Xml_eval(lua_State *L)
 {
 	enum whitespace_mode mode = luaL_optint(L, 2, WHITESPACE_TRIM);
@@ -783,7 +787,7 @@ Basically, this is just calling `eval` on the given file's content.
 @tparam ?number mode  whitespace handling mode, defaults to `WS_TRIM`
 @return  a Lua table representing the XML data, or `nil` in case of errors
 */
-int
+static int
 Xml_load(lua_State *L)
 {
 	const char *filename = luaL_checkstring(L, 1);
@@ -828,7 +832,7 @@ by explictly registering a `nil` value: `registerCode(decoded, nil)`.
 @tparam string encoded  the character entity to be used in XML
 @see encode, decode
 */
-int
+static int
 Xml_registerCode(lua_State *L)
 {
 	// We require the "decoded" string, but allow `nil` as argument #2.
@@ -856,7 +860,7 @@ print(xml.encode("<->")) -- "&lt;-&gt;"
 @treturn string  the XML-encoded string
 @see decode, registerCode
 */
-int
+static int
 Xml_encode(lua_State *L)
 {
 	luaL_checkstring(L, 1); // make sure arg #1 is a string
@@ -876,7 +880,7 @@ print((xml.decode("&lt;-&gt;")) -- "<->"
 @treturn string  the decoded string
 @see encode, registerCode
 */
-int
+static int
 Xml_decode(lua_State *L)
 {
 	size_t size;
@@ -904,7 +908,7 @@ Mainly for internal use.
 @treturn string
 an XML string, or `nil` in case of errors.
 */
-int
+static int
 Xml_str(lua_State *L)
 {
 	// Note:
@@ -1108,7 +1112,7 @@ This allows you to either make direct use of the matched LuaXML object, or to
 use the return value in a boolean test (`if xml.match(...)`), which is a common
 Lua idiom.
 */
-int
+static int
 Xml_match(lua_State *L)
 {
 	if (lua_type(L, 1) == LUA_TTABLE) {
@@ -1174,7 +1178,7 @@ from the callback.
 
 @see match
 */
-int
+static int
 Xml_iterate(lua_State *L)
 {
 	lua_settop(L, 8);
@@ -1246,7 +1250,7 @@ the logic involved with testing for` tag`, `key` and `value`.
 @return  the first (sub-)table that satisfies the search condition,
 or `nil` for no match
 */
-int
+static int
 Xml_find(lua_State *L)
 {
 	lua_settop(L, 4); // accept at most four parameters for this function