From: Mart Lubbers Date: Mon, 9 Jan 2017 17:39:19 +0000 (+0100) Subject: robustify task and sds initialization X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=1383ec4c1733cc6f07fe68e0619446d60fe5277e;p=mTask.git robustify task and sds initialization --- diff --git a/int/interpret.c b/int/interpret.c index 6875097..bf437ae 100644 --- a/int/interpret.c +++ b/int/interpret.c @@ -20,6 +20,7 @@ void run_task(struct task *t, int fd) printf("stack: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", stack[0], stack[1], stack[2], stack[3], stack[4], stack[5], stack[6], stack[7], stack[8], stack[9]); + switch(program[pc++]){ case BCNOP: trace("nop\n"); break; diff --git a/int/main.c b/int/main.c index 886170e..02852ef 100644 --- a/int/main.c +++ b/int/main.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -97,7 +96,7 @@ void open_filedescriptors() { struct sockaddr_in sa; - bzero((char *) &sa, sizeof(sa)); + memset(&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; sa.sin_addr.s_addr = INADDR_ANY; sa.sin_port = htons(port); @@ -153,6 +152,11 @@ int main(int argc, char *argv[]) opti++; } + //Initialize systems + sds_init(); + task_init(); + + //Open communication open_filedescriptors(); write(fd, "\n", 1); diff --git a/int/sds.c b/int/sds.c index 3a14c60..19ebadb 100644 --- a/int/sds.c +++ b/int/sds.c @@ -11,6 +11,11 @@ struct sds sdss[MAXSDSS]; uint8_t c; +void sds_init() +{ + memset(&sdss, 0, sizeof(struct sds)*MAXSDSS); +} + void sds_register(int fd) { uint8_t cs; diff --git a/int/sds.h b/int/sds.h index fbd9636..5e9644b 100644 --- a/int/sds.h +++ b/int/sds.h @@ -11,6 +11,7 @@ struct sds { bool used; }; +void sds_init(); void sds_register(int fd); bool sds_update(int fd); void sds_publish(int id, int fd); diff --git a/int/task.c b/int/task.c index 3b5690a..47c5bd1 100644 --- a/int/task.c +++ b/int/task.c @@ -6,9 +6,14 @@ #include "misc.h" #include "task.h" -struct task tasks[MAXTASKS];// = {0}; +struct task tasks[MAXTASKS]; uint8_t c; +void task_init() +{ + memset(&tasks, 0, sizeof(struct task)*MAXTASKS); +} + int task_register(int fd) { uint8_t ct; diff --git a/int/task.h b/int/task.h index 8f51171..22a615c 100644 --- a/int/task.h +++ b/int/task.h @@ -15,6 +15,7 @@ struct task { bool used; }; +void task_init(); int task_register(int fd); void task_delete(int fd); struct task *task_get(int num); diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index 1cd7c70..5876047 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -68,7 +68,7 @@ bclength _ = 1 toByteVal :: BC -> [Char] toByteVal b -# bt = toChar $ consIndex{|*|} b + 1 +# bt = toChar $ consIndex{|*|} b = [bt:case b of (BCPush i) = i (BCLab i) = [toChar i]