From d074e9de89070c5091af7cd00fc7a5910751d225 Mon Sep 17 00:00:00 2001 From: emmadoth Date: Thu, 8 Jun 2023 22:42:41 +0200 Subject: [PATCH] fix warnings, fix return type of input handler --- main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 1ed4f5a..04fbeb7 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,7 @@ #include #include -#define F_ARGS _Size* size, _Bool (*board)[size->width], char (*neighbours)[size->width], int y, int x +#define F_ARGS _Size* size, _Bool (*board)[size->width], [[maybe_unused]] char (*neighbours)[size->width], int y, int x typedef struct { int height; @@ -62,7 +62,7 @@ void apply_rules(F_ARGS) } } -int handle_input(int input) +_Bool handle_input(int input) { switch(input) { @@ -84,11 +84,11 @@ int main(void) _Size size; getmaxyx(stdscr, size.height, size.width); - _Bool (*board )[size.width] = malloc(size.height * size.width * sizeof(_Bool)); - char (*neighbours)[size.width] = malloc(size.height * size.width * sizeof(char )); + _Bool (*board )[size.width] = malloc((size_t)size.height * (size_t)size.width * sizeof(_Bool)); + char (*neighbours)[size.width] = malloc((size_t)size.height * (size_t)size.width * sizeof(char )); - memset(board , 0, size.height * size.width * sizeof(_Bool)); - memset(neighbours, 0, size.height * size.width * sizeof(char )); + memset(board , 0, (size_t)size.height * (size_t)size.width * sizeof(_Bool)); + memset(neighbours, 0, (size_t)size.height * (size_t)size.width * sizeof(char )); board[0][1] = 1; board[1][2] = 1; @@ -114,7 +114,7 @@ int main(void) input = getch(); run = handle_input(input); - memset(neighbours, 0, size.height * size.width * sizeof(char )); + memset(neighbours, 0, (size_t)size.height * (size_t)size.width * sizeof(char )); } free(board);