mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +00:00
Fix warnings
This change fixes Cosmopolitan so it has fewer opinions about compiler warnings. The whole repository had to be cleaned up to be buildable in -Werror -Wall mode. This lets us benefit from things like strict const checking. Some actual bugs might have been caught too.
This commit is contained in:
parent
e2b3c3618e
commit
0d748ad58e
571 changed files with 1306 additions and 1888 deletions
29
third_party/lua/luaencodeurl.c
vendored
29
third_party/lua/luaencodeurl.c
vendored
|
@ -25,23 +25,28 @@
|
|||
#include "third_party/lua/lua.h"
|
||||
|
||||
int LuaEncodeUrl(lua_State *L) {
|
||||
char *data;
|
||||
size_t size;
|
||||
struct Url h;
|
||||
int i, j, n;
|
||||
const char *data;
|
||||
struct Url h;
|
||||
if (!lua_isnil(L, 1)) {
|
||||
i = lua_gettop(L);
|
||||
bzero(&h, sizeof(h));
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
if (lua_getfield(L, 1, "scheme"))
|
||||
h.scheme.p = lua_tolstring(L, -1, &h.scheme.n);
|
||||
h.scheme.p = (char *)lua_tolstring(L, -1, &h.scheme.n);
|
||||
if (lua_getfield(L, 1, "fragment"))
|
||||
h.fragment.p = lua_tolstring(L, -1, &h.fragment.n);
|
||||
if (lua_getfield(L, 1, "user")) h.user.p = lua_tolstring(L, -1, &h.user.n);
|
||||
if (lua_getfield(L, 1, "pass")) h.pass.p = lua_tolstring(L, -1, &h.pass.n);
|
||||
if (lua_getfield(L, 1, "host")) h.host.p = lua_tolstring(L, -1, &h.host.n);
|
||||
if (lua_getfield(L, 1, "port")) h.port.p = lua_tolstring(L, -1, &h.port.n);
|
||||
if (lua_getfield(L, 1, "path")) h.path.p = lua_tolstring(L, -1, &h.path.n);
|
||||
h.fragment.p = (char *)lua_tolstring(L, -1, &h.fragment.n);
|
||||
if (lua_getfield(L, 1, "user"))
|
||||
h.user.p = (char *)lua_tolstring(L, -1, &h.user.n);
|
||||
if (lua_getfield(L, 1, "pass"))
|
||||
h.pass.p = (char *)lua_tolstring(L, -1, &h.pass.n);
|
||||
if (lua_getfield(L, 1, "host"))
|
||||
h.host.p = (char *)lua_tolstring(L, -1, &h.host.n);
|
||||
if (lua_getfield(L, 1, "port"))
|
||||
h.port.p = (char *)lua_tolstring(L, -1, &h.port.n);
|
||||
if (lua_getfield(L, 1, "path"))
|
||||
h.path.p = (char *)lua_tolstring(L, -1, &h.path.n);
|
||||
lua_settop(L, i); // restore stack position
|
||||
if (lua_getfield(L, 1, "params")) {
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
|
@ -55,10 +60,10 @@ int LuaEncodeUrl(lua_State *L) {
|
|||
h.params.p =
|
||||
xrealloc(h.params.p, ++h.params.n * sizeof(*h.params.p));
|
||||
h.params.p[h.params.n - 1].key.p =
|
||||
lua_tolstring(L, -1, &h.params.p[h.params.n - 1].key.n);
|
||||
(char *)lua_tolstring(L, -1, &h.params.p[h.params.n - 1].key.n);
|
||||
if (lua_geti(L, -2, 2)) {
|
||||
h.params.p[h.params.n - 1].val.p =
|
||||
lua_tolstring(L, -1, &h.params.p[h.params.n - 1].val.n);
|
||||
h.params.p[h.params.n - 1].val.p = (char *)lua_tolstring(
|
||||
L, -1, &h.params.p[h.params.n - 1].val.n);
|
||||
} else {
|
||||
h.params.p[h.params.n - 1].val.p = 0;
|
||||
h.params.p[h.params.n - 1].val.n = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue