summaryrefslogtreecommitdiff
path: root/bxgen.c
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2024-06-10 06:33:41 +0200
committerMitya Selivanov <automainint@guattari.tech>2024-06-10 06:33:41 +0200
commit220be7cf4a53dd3824008ff4ecfcad5a4e6f3bc1 (patch)
tree585117055f746ed781070246a252ee54f848537b /bxgen.c
parent9bc6afd129f4730855a12de7ad01222a2614da26 (diff)
downloadbxgen-220be7cf4a53dd3824008ff4ecfcad5a4e6f3bc1.zip
Cleanup
Diffstat (limited to 'bxgen.c')
-rwxr-xr-xbxgen.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/bxgen.c b/bxgen.c
index 987f333..560c704 100755
--- a/bxgen.c
+++ b/bxgen.c
@@ -1,7 +1,12 @@
#if 0
SRC=${0##*/}
BIN=${SRC%.*}
-gcc -o $BIN.tmp $SRC && ./$BIN.tmp $@ && rm $BIN.tmp
+gcc \
+ -Wno-missing-field-initializers -Wno-missing-braces \
+ -Wall -Wextra -Werror -pedantic \
+ -O0 -fsanitize=undefined,address,leak -mshstk \
+ -o $BIN.tmp $SRC && \
+ ./$BIN.tmp $@ && rm $BIN.tmp
exit $?
#endif
@@ -275,7 +280,7 @@ void u_elf_x86_64(i64 unit, c8 const *output_file_name);
//
i64 pool_add(pool_t *pool, entity_t data) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entity_count < pool->capacity);
i64 id = pool->entity_count++;
@@ -286,7 +291,7 @@ i64 pool_add(pool_t *pool, entity_t data) {
}
void pool_remove(pool_t *pool, i64 entity, i16 type) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[entity].is_enabled);
assert(pool->entities[entity].type == type);
@@ -333,7 +338,7 @@ void proc_destroy(pool_t *pool, i64 proc) {
}
void proc_set_name(pool_t *pool, i64 proc, i64 name_size, c8 const *name) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[proc].is_enabled);
assert(pool->entities[proc].type == TYPE_PROC);
@@ -348,7 +353,7 @@ void proc_set_name(pool_t *pool, i64 proc, i64 name_size, c8 const *name) {
}
void proc_node_add(pool_t *pool, i64 proc, i64 node) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[proc].is_enabled);
assert(pool->entities[proc].type == TYPE_PROC);
assert(pool->entities[node].is_enabled);
@@ -364,7 +369,7 @@ void proc_node_add(pool_t *pool, i64 proc, i64 node) {
}
void proc_node_remove(pool_t *pool, i64 proc, i64 node) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[proc].is_enabled);
assert(pool->entities[proc].type == TYPE_PROC);
assert(pool->entities[node].type == TYPE_NODE);
@@ -387,7 +392,7 @@ void unit_destroy(pool_t *pool, i64 unit) {
}
void unit_proc_add(pool_t *pool, i64 unit, i64 proc) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[unit].is_enabled);
assert(pool->entities[unit].type == TYPE_UNIT);
assert(pool->entities[proc].is_enabled);
@@ -403,7 +408,7 @@ void unit_proc_add(pool_t *pool, i64 unit, i64 proc) {
}
void unit_proc_remove(pool_t *pool, i64 unit, i64 proc) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[unit].is_enabled);
assert(pool->entities[unit].type == TYPE_UNIT);
assert(pool->entities[proc].type == TYPE_PROC);
@@ -412,7 +417,7 @@ void unit_proc_remove(pool_t *pool, i64 unit, i64 proc) {
}
void unit_set_entry_point(pool_t *pool, i64 unit, i64 entry_point_proc) {
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[unit].is_enabled);
assert(pool->entities[unit].type == TYPE_UNIT);
assert(pool->entities[entry_point_proc].type == TYPE_PROC);
@@ -427,7 +432,7 @@ void unit_write(pool_t *pool, i64 unit, u16 target, FILE *out) {
// TODO
// Use callback instead of `FILE` to not depend on `stdio.h` here.
- assert(pool != NULL);
+ assert(pool != NULL && pool->entities != NULL);
assert(pool->entities[unit].is_enabled);
assert(pool->entities[unit].unit.entry_point != UNDEFINED);
assert(out != NULL);
@@ -594,9 +599,13 @@ void u_elf_x86_64(i64 unit, c8 const *output_file_name) {
#ifndef DISABLE_EXAMPLE
int main(int argc, char **argv) {
- printf("node - %d bytes\n", (i32) sizeof(node_t));
- printf("proc - %d bytes\n", (i32) sizeof(proc_t));
- printf("unit - %d bytes\n", (i32) sizeof(unit_t));
+ (void) argc;
+ (void) argv;
+
+ printf("node - %d bytes\n", (i32) sizeof(node_t));
+ printf("proc - %d bytes\n", (i32) sizeof(proc_t));
+ printf("unit - %d bytes\n", (i32) sizeof(unit_t));
+ printf("entity - %d bytes\n", (i32) sizeof(entity_t));
i64 main = p_new("main");
i64 n0 = n_i64(42);