Browse Source

Fix some warnings, fix Lua connect

Fix some warnings. The warnings for the Lua connect functions must have been coding errors.
bel2125 4 years ago
parent
commit
1e2bd5c5a7
3 changed files with 11 additions and 10 deletions
  1. 8 7
      examples/embedded_c/embedded_c.c
  2. 1 1
      src/civetweb.c
  3. 2 2
      src/mod_lua.inl

+ 8 - 7
examples/embedded_c/embedded_c.c

@@ -302,26 +302,27 @@ field_found(const char *key,
 		 * path information present in the filename. Drop all "/" (and "\" for
 		 * Windows).
 		 */
-		char *sep = strrchr(filename, '/');
+		const char *fname = filename;
+		const char *sep = strrchr(fname, '/');
 		if (sep) {
-			memmove(filename, sep + 1, strlen(sep));
+			fname = sep + 1;
 		}
 
 #ifdef _WIN32
-		sep = strrchr(filename, '\\');
+		sep = strrchr(fname, '\\');
 		if (sep) {
-			memmove(filename, sep + 1, strlen(sep));
+			fname = sep + 1;
 		}
 
 		/* For Windows: Find the directory for temporary files */
 		temppathlen = GetTempPathA(sizeof(temppath), temppath);
 		if (temppathlen > 0) {
-			_snprintf(path, pathlen, "%s\\%s", temppath, filename);
+			_snprintf(path, pathlen, "%s\\%s", temppath, fname);
 		} else {
-			_snprintf(path, pathlen, "C:\\tmp\\%s", filename);
+			_snprintf(path, pathlen, "C:\\tmp\\%s", fname);
 		}
 #else
-		snprintf(path, pathlen, "/tmp/%s", filename);
+		snprintf(path, pathlen, "/tmp/%s", fname);
 #endif
 
 		/* According to https://datatracker.ietf.org/doc/html/rfc7578#section-7:

+ 1 - 1
src/civetweb.c

@@ -18121,7 +18121,7 @@ websocket_client_thread(void *data)
 static struct mg_connection *
 mg_connect_websocket_client_impl(const struct mg_client_options *client_options,
                                  int use_ssl,
-                                 const char *error_buffer,
+                                 char *error_buffer,
                                  size_t error_buffer_size,
                                  const char *path,
                                  const char *origin,

+ 2 - 2
src/mod_lua.inl

@@ -368,8 +368,8 @@ lsp_connect(lua_State *L)
 	    && lua_isnumber(L, 3)) {
 
 		const char *host = lua_tostring(L, 1);
-		const int port = lua_tostring(L, 2);
-		const int is_ssl = lua_tostring(L, 3);
+		const int port = lua_tointeger(L, 2);
+		const int is_ssl = lua_tointeger(L, 3);
 
 		ok = connect_socket(
 		    NULL, host, port, is_ssl, ebuf, sizeof(ebuf), &sock, &sa);