Compare commits

...
2 Commits
Author SHA1 Message Date
nelsbrock 2b55717595 remove unnecessary struct tags 2025-04-29 20:34:11 +02:00
nelsbrock 504c950c15 remove unnecessary return value of tictactoe_game_init 2025-04-29 20:26:38 +02:00
4 changed files with 5 additions and 12 deletions
+1 -3
View File
@@ -7,7 +7,7 @@
/* /*
* Initializes a new game instance. * Initializes a new game instance.
*/ */
int tictactoe_game_init(ttt_game_t *game) void tictactoe_game_init(ttt_game_t *game)
{ {
game->next_turn = 'X'; game->next_turn = 'X';
game->winner = 0; game->winner = 0;
@@ -16,8 +16,6 @@ int tictactoe_game_init(ttt_game_t *game)
game->board[x][y] = ' '; game->board[x][y] = ' ';
} }
} }
return 0;
} }
/* /*
+2 -2
View File
@@ -3,13 +3,13 @@
#include <linux/types.h> #include <linux/types.h>
typedef struct tictactoe_game { typedef struct {
char next_turn; char next_turn;
char winner; char winner;
char board[3][3]; char board[3][3];
} ttt_game_t; } ttt_game_t;
int tictactoe_game_init(ttt_game_t *game); void tictactoe_game_init(ttt_game_t *game);
int tictactoe_game_make_turn(ttt_game_t *game, size_t x, size_t y); int tictactoe_game_make_turn(ttt_game_t *game, size_t x, size_t y);
int tictactoe_game_snprint(ttt_game_t *game, char *buf, size_t len); int tictactoe_game_snprint(ttt_game_t *game, char *buf, size_t len);
+1 -1
View File
@@ -10,7 +10,7 @@
#define tictactoe_error(format, ...) \ #define tictactoe_error(format, ...) \
pr_err("%s: " format, __func__, ##__VA_ARGS__) pr_err("%s: " format, __func__, ##__VA_ARGS__)
typedef struct annotated_string { typedef struct {
struct mutex lock; struct mutex lock;
size_t len; size_t len;
char *buf; char *buf;
+1 -6
View File
@@ -225,12 +225,7 @@ static int __init tictactoe_init(void)
tictactoe_error("failed to allocate game memory\n"); tictactoe_error("failed to allocate game memory\n");
return -EFAULT; return -EFAULT;
} }
ret = tictactoe_game_init(tictactoe_current_game); tictactoe_game_init(tictactoe_current_game);
if (ret) {
mutex_unlock(&tictactoe_mutex_current_game);
tictactoe_error("failed to initialize game\n");
return -EFAULT;
}
mutex_unlock(&tictactoe_mutex_current_game); mutex_unlock(&tictactoe_mutex_current_game);
ret = misc_register(&tictactoe_dev); ret = misc_register(&tictactoe_dev);