commit 98715832ec794a35ff6e6a5b565501a43c2c18e6
parent 30ef36d3dbffce202bfa3d6e6385283833abb480
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Mon, 13 Dec 2021 16:43:05 -0600
fix warnings, cleanup
Diffstat:
7 files changed, 19 insertions(+), 27 deletions(-)
diff --git a/elf.c b/elf.c
@@ -4,7 +4,7 @@
#include "nooc.h"
#include "elf.h"
-int
+void
elf(size_t entry, char *text, size_t len, char* data, size_t dlen, FILE *f)
{
Elf64_Ehdr ehdr = { 0 };
diff --git a/elf.h b/elf.h
@@ -1 +1 @@
-int elf(size_t entry, char *text, size_t len, char* data, size_t dlen, FILE *f);
+void elf(size_t entry, char *text, size_t len, char* data, size_t dlen, FILE *f);
diff --git a/main.c b/main.c
@@ -22,7 +22,7 @@
#include "map.h"
#include "blockstack.c"
-const char const *tokenstr[] = {
+const char *const tokenstr[] = {
[TOK_NONE] = "TOK_NONE",
[TOK_NAME] = "TOK_NAME",
[TOK_LPAREN] = "TOK_LPAREN",
@@ -85,6 +85,8 @@ char *exprkind_str(enum exprkind kind)
default:
die("invalid exprkind");
}
+
+ return NULL;
}
struct exprs exprs;
@@ -99,6 +101,9 @@ dumpval(struct expr *e)
case C_STR:
fprintf(stderr, "\"%.*s\"", (int)e->d.v.v.s.len, e->d.v.v.s.data);
break;
+ case C_PROC:
+ fprintf(stderr, "proc with %lu params", e->d.proc.params.len);
+ break;
}
}
diff --git a/parse.c b/parse.c
@@ -11,7 +11,7 @@
#include "type.h"
#include "map.h"
-extern const char const *tokenstr[];
+extern const char *const tokenstr[];
extern struct decls decls;
extern struct assgns assgns;
@@ -203,10 +203,8 @@ binary_common:
static size_t
parsetype()
{
- uint8_t hash[16];
struct type type = { 0 };
struct mapkey key;
- size_t offset;
union mapval val;
if (strncmp(tok->slice.data, "proc", 3) == 0) {
diff --git a/type.c b/type.c
@@ -36,7 +36,6 @@ inittypes()
table.vals = xcalloc(2, sizeof(*table.vals));
struct type type = { 0 };
struct mapkey key = { 0 };
- uint8_t out[16];
// first one should be 0
type_put(&type);
@@ -55,7 +54,7 @@ inittypes()
}
static void
-hashtype(struct type *type, char *out)
+hashtype(struct type *type, uint8_t *out)
{
struct blake3 b3;
@@ -65,6 +64,7 @@ hashtype(struct type *type, char *out)
switch (type->class) {
case TYPE_PROC:
blake3_update(&b3, type->d.typelist.data, type->d.typelist.len * sizeof(*type->d.typelist.data));
+ default:
}
blake3_out(&b3, out, 16);
@@ -133,21 +133,3 @@ type_put(struct type *type)
return types.len - 1;
}
-
-/*
-int
-main()
-{
- struct type i64 = { .class = TYPE_I64 };
- struct type str = { .class = TYPE_STR };
- struct type proc = { .class = TYPE_PROC };
- uint8_t i64hash[16], strhash[16], prochash[16];
-
- hashtype(&i64, i64hash);
- hashtype(&str, strhash);
- hashtype(&proc, prochash);
- printf("%x%x\n", *(uint64_t*)i64hash);
- printf("%x%x\n", *(uint64_t*)strhash);
- printf("%x%x\n", *(uint64_t*)prochash);
-}
-*/
diff --git a/util.c b/util.c
@@ -34,7 +34,7 @@ error(size_t line, size_t col, const char *error, ...)
{
va_list args;
- fprintf(stderr, "%s:%u:%u: ", infile, line, col);
+ fprintf(stderr, "%s:%lu:%lu: ", infile, line, col);
va_start(args, error);
vfprintf(stderr, error, args);
va_end(args);
diff --git a/x64.c b/x64.c
@@ -27,6 +27,7 @@ getreg()
}
die("out of registers!");
+ return 0; // prevents warning
}
void
@@ -195,6 +196,8 @@ jng(char *buf, int64_t offset)
} else {
die("unimplemented jng offet!");
}
+
+ return 0; // prevents warning
}
size_t
@@ -210,6 +213,8 @@ jg(char *buf, int64_t offset)
} else {
die("unimplemented jg offet!");
}
+
+ return 0; // prevents warning
}
size_t
@@ -225,6 +230,8 @@ jmp(char *buf, int64_t offset)
} else {
die("unimplemented jmp offet!");
}
+
+ return 0; // prevents warning
}
size_t