diff options
| -rw-r--r-- | makefile | 2 | ||||
| -rw-r--r-- | src/crypto.h | 1 | ||||
| -rw-r--r-- | src/hash/blake.c | 8 | ||||
| -rw-r--r-- | src/hash/buzhash.c | 1 | ||||
| -rw-r--r-- | src/hash/pearson.c | 1 | ||||
| -rw-r--r-- | src/hash/sha01.c | 2 | ||||
| -rw-r--r-- | src/hash/sha2-256.c | 2 | ||||
| -rw-r--r-- | src/io.c | 42 | ||||
| -rw-r--r-- | src/io.h | 2 | ||||
| -rw-r--r-- | src/lua.c | 6 | ||||
| -rw-r--r-- | src/net.c | 9 | ||||
| -rw-r--r-- | src/net/lua.c | 2 | ||||
| -rw-r--r-- | src/net/luai.c | 1 | ||||
| -rw-r--r-- | src/net/util.c | 9 | ||||
| -rw-r--r-- | src/table.c | 6 | ||||
| -rw-r--r-- | src/thread.c | 4 | ||||
| -rw-r--r-- | src/types/map.c | 19 | ||||
| -rw-r--r-- | tests/hash.lua | 2 |
18 files changed, 18 insertions, 101 deletions
@@ -9,7 +9,7 @@ ifeq ($(version),jit) install_version = 5.1
endif
-CFLAGS := -fPIC -DGIT_COMMIT='$(GIT_COMMIT)' `pkg-config --cflags lua$(version)`
+CFLAGS := -Wall -Werror -fPIC -DGIT_COMMIT='$(GIT_COMMIT)' `pkg-config --cflags lua$(version)`
LFLAGS := -lm -shared -lcrypto -lssl
LINKER := $(CC)
diff --git a/src/crypto.h b/src/crypto.h index 27adf6f..78c8d4f 100644 --- a/src/crypto.h +++ b/src/crypto.h @@ -89,7 +89,6 @@ int _##luaname##_common_hash(lua_State* L){\ struct hashname##_hash* a = (struct hashname##_hash*)lua_newuserdata(L, sizeof * a);\
int ud = lua_gettop(L);\
*a = initf;\
- int ini = lua_gettop(L);\
lua_common_hash_meta_def(luaname, exitf);\
lua_pushvalue(L, ud);\
return 1;\
diff --git a/src/hash/blake.c b/src/hash/blake.c index e5e9b16..38d7da2 100644 --- a/src/hash/blake.c +++ b/src/hash/blake.c @@ -54,7 +54,7 @@ const uint64_t blake_u512[16] = { v[b] = rotr32( v[b] ^ v[c], 7);
void compress256(uint32_t* hash, char *block, uint64_t compressed){
- uint32_t v[16], m[16], i;
+ uint32_t v[16], m[16];
for(int i = 0; i < 16; i++) m[i] = wtf((block + i * 4));
@@ -203,7 +203,6 @@ void _blake256_final(struct blake256_hash* hash, char* out_stream){ memset(hash->buffer, 0, 64);
}
- size_t lhhh = 8*hash->total;
U32TO8_BIG(hash->buffer + bs - 8, 0x0);
U32TO8_BIG(hash->buffer + bs - 4, hash->total << 3);
/*for(int i = 0; i != bs; i++) printf("%x ", hash->buffer[i]);
@@ -434,7 +433,6 @@ void _blake512_final(struct blake512_hash* hash, char* out_stream){ memset(hash->buffer, 0, 64);
}
- size_t lhhh = 8*hash->total;
U64TO8_BIG(hash->buffer + bs_2 - 8, hash->total << 3);
blake512_round(hash);
@@ -533,7 +531,6 @@ int l_blake256(lua_State* L){ if(lua_gettop(L) == 0) return l_blake256_init(L);
size_t len = 0;
uint8_t* a = (uint8_t*)luaL_checklstring(L, 1, &len);
- int argv = lua_gettop(L);
char digest[257] = {0};
@@ -575,7 +572,6 @@ int l_blake224(lua_State* L){ if(lua_gettop(L) == 0) return l_blake224_init(L);
size_t len = 0;
char* a = (char*)luaL_checklstring(L, 1, &len);
- int argv = lua_gettop(L);
char digest[257] = {0};
@@ -617,7 +613,6 @@ int l_blake512(lua_State* L){ if(lua_gettop(L) == 0) return l_blake512_init(L);
size_t len = 0;
uint8_t* a = (uint8_t*)luaL_checklstring(L, 1, &len);
- int argv = lua_gettop(L);
char digest[513] = {0};
//memset(digest, 0, 513);
@@ -660,7 +655,6 @@ int l_blake384(lua_State* L){ if(lua_gettop(L) == 0) return l_blake384_init(L);
size_t len = 0;
uint8_t* a = (uint8_t*)luaL_checklstring(L, 1, &len);
- int argv = lua_gettop(L);
char digest[513] = {0};
diff --git a/src/hash/buzhash.c b/src/hash/buzhash.c index ec2705d..4016110 100644 --- a/src/hash/buzhash.c +++ b/src/hash/buzhash.c @@ -47,7 +47,6 @@ int l_setbuzhash(lua_State* L){ exit(0); } - double s = 0; for(int i = 0; i <= len-1; i++){ lua_pushinteger(L,i+1); diff --git a/src/hash/pearson.c b/src/hash/pearson.c index a544515..d6a5d1b 100644 --- a/src/hash/pearson.c +++ b/src/hash/pearson.c @@ -51,7 +51,6 @@ int l_setpearson(lua_State* L){ exit(0);
}
- double s = 0;
for(int i = 0; i <= len-1; i++){
lua_pushinteger(L,i+1);
diff --git a/src/hash/sha01.c b/src/hash/sha01.c index f5478dd..4d05e7e 100644 --- a/src/hash/sha01.c +++ b/src/hash/sha01.c @@ -43,7 +43,7 @@ void sha01_round(struct sha01_hash* hash){ for(int i = 0; i != 16; i++){
int t = 24;
- for(int x = 0;t>=0; x++){
+ for(;t>=0;){
W[i] += (((uint32_t)hash->buffer[hat]) << t);
hat++;
t-=8;
diff --git a/src/hash/sha2-256.c b/src/hash/sha2-256.c index de79d3f..3c33948 100644 --- a/src/hash/sha2-256.c +++ b/src/hash/sha2-256.c @@ -243,7 +243,6 @@ struct iv sha_iv_gen(int i){ .h3 = sha512_iv.h3 ^ 0xa5a5a5a5a5a5a5a5, .h4 = sha512_iv.h4 ^ 0xa5a5a5a5a5a5a5a5, .h5 = sha512_iv.h5 ^ 0xa5a5a5a5a5a5a5a5,
.h6 = sha512_iv.h6 ^ 0xa5a5a5a5a5a5a5a5, .h7 = sha512_iv.h7 ^ 0xa5a5a5a5a5a5a5a5};
- uint8_t nh[512] = {0};
uint8_t in[12];
sprintf((char*)in, "SHA-512/%i", i);
struct sha512_hash a = sha512_t_init(oh);
@@ -310,7 +309,6 @@ lua_common_hash_meta(sha512_t); int l_sha512_t_init(lua_State* L){
int tt = luaL_checkinteger(L, -1);
lua_newtable(L);
- int t = lua_gettop(L);
struct sha512_hash* a = (struct sha512_hash*)lua_newuserdata(L, sizeof * a);\
int ud = lua_gettop(L);
@@ -15,37 +15,6 @@ int _print_meta = 0; int _file_malloc_chunk = 512; -int l_readfile(lua_State* L){ - size_t len; - char* a = (char*)luaL_checklstring(L, 1, &len); - - FILE *fp; - const uint64_t chunk_iter = _file_malloc_chunk; - uint64_t chunk = chunk_iter; - uint64_t count = 0; - - if(access(a, F_OK)) { - p_fatal("file not found"); - } - if(access(a, R_OK)){ - p_fatal("missing permissions"); - } - - fp = fopen(a, "rb"); - fseek(fp, 0L, SEEK_END); - size_t sz = ftell(fp); - fseek(fp, 0L, SEEK_SET); - char* out = calloc(sz + 1, sizeof * out); - - fread(out, sizeof * out, sz, fp); - - lua_pushlstring(L, out, sz); - - fclose(fp); - free(out); - return 1; -}; - lua_Debug i_get_debug(lua_State* L){ lua_Debug ar; lua_getstack(L, 1, &ar); @@ -92,7 +61,7 @@ void print_indentation(int i){ void i_pprint(lua_State* L, int indent, int skip_indent){ int last_idx = lua_gettop(L); const char* type = lua_typename(L,lua_type(L,-1)); - int t = lua_type(L,-1); + switch(lua_type(L,-1)){ case LUA_TTABLE: printf(" "); @@ -243,10 +212,10 @@ void json_parse(lua_State* L, str* raw){ case '{': case '}': case '[': case ']': - if(last == '{' && topush[0] == '}' || last == '[' && topush[0] == ']') token_depth--; + if((last == '{' && topush[0] == '}') || (last == '[' && topush[0] == ']')) token_depth--; - if((last == '\0' || last == '"' && topush[0] == '"' - || last == '{' && topush[0] == '}' || last == '[' && topush[0] == ']')){ + if((last == '\0' || (last == '"' && topush[0] == '"') + || (last == '{' && topush[0] == '}') || (last == '[' && topush[0] == ']'))){ if(token_depth == 0){ if(last == '\0'){ last = topush[0]; @@ -277,7 +246,7 @@ void json_parse(lua_State* L, str* raw){ break; } //if(escape_next == 2) continue; - if(last == '{' && topush[0] == '{' || last == '[' && topush[0] == '[') token_depth++; + if((last == '{' && topush[0] == '{') || (last == '[' && topush[0] == '[')) token_depth++; if(count == 0 && !is_array) str_push(key, topush); else str_push(value, topush); @@ -296,4 +265,5 @@ int l_json_parse(lua_State* L){ } int resolve_path(lua_State* L){ + return 0; } @@ -19,7 +19,6 @@ #define color_white "\e[97m" #define color_reset "\e[0m" -int l_readfile(lua_State*); int l_debug(lua_State*); int l_log(lua_State*); int l_warn(lua_State*); @@ -50,7 +49,6 @@ static struct config io_config[] = { }; static const luaL_Reg io_function_list [] = { - {"readfile",l_readfile}, {"debug",l_debug}, {"log",l_log}, {"warn",l_warn}, @@ -7,7 +7,6 @@ #include <stdint.h>
#include "types/parray.h"
-static int ii = 0;
static int malloc_count = 0;
int luaI_nothing(lua_State* L){
@@ -163,13 +162,10 @@ int writer(lua_State *L, const void* p, size_t sz, void* ud){ * @param {int} whether or not to skip meta data
*/
void luaI_deepcopy(lua_State* src, lua_State* dest, enum deep_copy_flags flags){
- size_t len;
//printf("%i\n",seen->len);
int at, at2;
//int *sp = malloc(1);
//int *sp;
- char* s;
- void* whar;
double n;
int old_top = lua_gettop(src);
int modi = 0;
@@ -276,7 +272,6 @@ void luaI_deepcopy(lua_State* src, lua_State* dest, enum deep_copy_flags flags){ break;
}
int tidx = lua_gettop(dest);
- int aa = lua_gettop(src);
if(modi && !(flags & SKIP_META) && lua_getmetatable(src, -1)){
luaI_deepcopy(src, dest, flags | IS_META | SKIP_META);
@@ -432,7 +427,6 @@ void lua_upvalue_key_table(lua_State* L, int fidx){ char* name;
for(int i = 1; (name = (char*)lua_getupvalue(L, fidx, i)) != NULL; i++){
- int idx = lua_gettop(L);
lua_pushinteger(L, lua_rawlen(L, tidx) + 1);
lua_pushstring(L, name);
lua_settable(L, tidx);
@@ -218,7 +218,7 @@ int i_ws_read(lua_State* L){ if(len < 0) luaI_error(L, len, "SSL_read error");
- payload = (buffer[0] & 0xff) << 8 | buffer[1] & 0xff;
+ payload = (buffer[0] & 0xff) << 8 | (buffer[1] & 0xff);
} else {
for(; (len = SSL_read(data->ssl, buffer + total_len, 8 - total_len)) > 0;){
total_len += len;
@@ -321,7 +321,6 @@ int l_wss(lua_State* L){ char* port = awa.port == NULL ? "443" : awa.port->c;
char* path = awa.path == NULL ? "/" : awa.path->c;
int sock = get_host(awa.domain->c, port);
- int set = 1;
signal(SIGPIPE, SIG_IGN);
ssl_init();
@@ -341,13 +340,12 @@ int l_wss(lua_State* L){ }
char buffer[BUFFER_LEN];
- int extra_len = len = 0;
+ len = 0;
str* a = str_init("");
char* header_eof = NULL;
for(; (len = SSL_read(ssl, buffer, BUFFER_LEN)) > 0;){
str_pushl(a, buffer, len);
if((header_eof = memmem(a->c, a->len, "\r\n\r\n", 4)) != NULL){
- extra_len = a->len - (header_eof - a->c);
break;
}
memset(buffer, 0, BUFFER_LEN);
@@ -671,7 +669,6 @@ void* handle_client(void *_arg){ thread_arg_struct* args = (thread_arg_struct*)_arg;
int client_fd = args->fd;
char* buffer;
- char dummy[2] = {0, 0};
int header_eof = -1;
lua_State* L = args->L;
luaL_openlibs(L);
@@ -694,7 +691,6 @@ void* handle_client(void *_arg){ str* sR = (str*)parray_get(table, "Request");
str* sT = (str*)parray_get(table, "Content-Type");
str* sC = (str*)parray_get(table, "Cookie");
- int some = bite - header_eof - 10;
struct file_parse* file_cont = calloc(1, sizeof * file_cont);
lua_newtable(L);
@@ -800,7 +796,6 @@ void* handle_client(void *_arg){ luaI_tsetv(L, req_idx, "parameters", new_param_idx);
for(int z = 0; z != awa->len; z++){
- char* path;
struct lchar* wowa = awa->cs[z];
//if request is HEAD, it is valid for GET and HEAD listeners
if(strcmp(wowa->req, "all") == 0 || strcmp(wowa->req, sR->c) == 0 ||
diff --git a/src/net/lua.c b/src/net/lua.c index ba9a204..d6bba65 100644 --- a/src/net/lua.c +++ b/src/net/lua.c @@ -75,7 +75,7 @@ int l_send(lua_State* L){ } else i_write_header(L, header, &resp, content, len); - int a = send(client_fd, resp->c, resp->len, MSG_NOSIGNAL); + send(client_fd, resp->c, resp->len, MSG_NOSIGNAL); // lua_pushstring(L, "client_fd"); diff --git a/src/net/luai.c b/src/net/luai.c index 205f217..ac9e090 100644 --- a/src/net/luai.c +++ b/src/net/luai.c @@ -49,7 +49,6 @@ int rolling_file_parse(lua_State* L, int* files_idx, int* body_idx, char* buffer str* boundary_id = (str*)parray_get(content, "_boundary_id"); int* dash_count = (int*)parray_get(content, "_dash_count"); int* table_idx = (int*)parray_get(content, "_table_idx");*/ - int override = 0; //time_start(start) if(content.status == _ignore){ diff --git a/src/net/util.c b/src/net/util.c index efdbe75..3e91c7c 100644 --- a/src/net/util.c +++ b/src/net/util.c @@ -107,9 +107,7 @@ int64_t recv_full_buffer(int client_fd, char** _buffer, int* header_eof, int* st */ int parse_header(char* buffer, int header_eof, parray_t** _table){ if(header_eof == -1) return -1; - char add[] = {0,0}; - int lines = 3; - for(int i = 0; i != header_eof; i++) lines += buffer[i] == '\n'; + parray_t* table = parray_init(); str* current = str_init(""); int oi = 0; @@ -143,7 +141,7 @@ int parse_header(char* buffer, int header_eof, parray_t** _table){ str* sw = NULL; for(int i = oi + 1; i != header_eof; i++){ if(buffer[i] == ' ' && strcmp(current->c, "") == 0) continue; - if(key && buffer[i] == ':' || !key && buffer[i] == '\n'){ + if((key && buffer[i] == ':') || (!key && buffer[i] == '\n')){ if(key){ sw = current; current = str_init(""); @@ -423,7 +421,7 @@ void parse_mimetypes(){ for(;(read = getline(&line, &len, fp)) != -1;){ if(line[0] == '#' || line[0] == '\n') continue; - int used = 0; + char* mtype = calloc(1024, sizeof * mtype); int mtype_len = 0; int i = 0; @@ -440,7 +438,6 @@ void parse_mimetypes(){ char* mtype_c = calloc(1024, sizeof * mtype); strcpy(mtype_c, mtype); map_set(&mime_type, type, mtype_c); - used = 1; type_len = 0; type = calloc(512, sizeof * type); } else { diff --git a/src/table.c b/src/table.c index ea57b2c..418da3a 100644 --- a/src/table.c +++ b/src/table.c @@ -184,8 +184,6 @@ int l_indexof(lua_State* L) { size_t start = argc == 3 ? luaL_checknumber(L,3) : 0; start = start > 0 ? start : start; - double cur = 0; - for(size_t i = 0; i <= len-1; i++){ lua_pushinteger(L,i+1); lua_gettable(L,1); @@ -202,15 +200,13 @@ int l_indexof(lua_State* L) { } int l_sindexof(lua_State* L) { - int argc = lua_gettop(L); double target = luaL_checknumber(L, 2); luaL_checktype(L, 1, LUA_TTABLE); size_t len = lua_objlen(L,1); int l = 0; int r = len - 1; - size_t cid = len/2; - for(size_t i = 0; l<=r; i++){ + for(; l<=r;){ int m = l + (r - l) /2; lua_pushinteger(L,m+1); lua_gettable(L,1); diff --git a/src/thread.c b/src/thread.c index babab52..5aed694 100644 --- a/src/thread.c +++ b/src/thread.c @@ -51,7 +51,7 @@ int l_tlock(lua_State* L){ pthread_mutex_lock(&mutex);
pthread_mutex_t* mp = malloc(sizeof * mp);
*mp = mutex;
- int id = larray_set(&thread_locks, idx, (void*)mp);
+ larray_set(&thread_locks, idx, (void*)mp);
} else {
pthread_mutex_t *m = (pthread_mutex_t*)thread_locks->arr[i].value;
pthread_mutex_lock(&thread_priority_lock);
@@ -417,7 +417,7 @@ void meta_proxy_gen(lua_State* L, struct thread_buffer *buffer, int meta_idx, in lua_pushnil(L);
for(; lua_next(L, meta_idx) != 0;){
- int k, v = lua_gettop(L);
+ int k = lua_gettop(L);
k = lua_gettop(L) - 1;
char* fn = calloc(128, sizeof * fn);
diff --git a/src/types/map.c b/src/types/map.c index 31e79a9..abf075c 100644 --- a/src/types/map.c +++ b/src/types/map.c @@ -114,22 +114,3 @@ void map_clear(map_t* M, enum free_type free){ }
map_lclear(M);
}
-
-int __main(){
- int i = 5;
- int b = 24;
- int c = 9;
- map_t* m = map_init();
-
- map_set(&m, "wowa", &b);
- printf("%i\n",*(int*)map_get(m, "wowa"));
- map_set(&m, "aw", &i);
- map_set(&m, "awc", &i);
- map_set(&m, "awa", &i);
- map_set(&m, "aww", &i);
- printf("%i\n",*(int*)map_get(m, "wowa"));
-
- map_clear(m, NONE);
-
- return 0;
-}
diff --git a/tests/hash.lua b/tests/hash.lua index 894d284..f59228b 100644 --- a/tests/hash.lua +++ b/tests/hash.lua @@ -163,8 +163,6 @@ test("sha224","meow","e28f8ee4dd8618b890df366b85a2d45d2506dd842e95272b9a598998") test("sha256","meow","404cdd7bc109c432f8cc2443b45bcfe95980f5107215c645236e577929ac3e52")
test("sysvchecksum","meow","1b8")
test("xor8","meow","48")
-test("xxh32","meow","6ba6f6f0")
-test("xxh64","meow","bc11093a30a6315f")
test("buzhash8","meow","57")
test("buzhash16","meow","0255")
test("djb2","meow","7c9a913d")
|
