From: Laurent Mazet Date: Sat, 1 Mar 2025 22:51:24 +0000 (+0100) Subject: clean code X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=7df7703cb19c227cc64cbb61f687d42ebfcb45fe;p=sudoku.git clean code --- diff --git a/function.c b/function.c index c8f73ea..4d8769a 100644 --- a/function.c +++ b/function.c @@ -133,7 +133,9 @@ board_t *initplay (board_t *board) } /* random position */ - pos = (pos > 0) ? rand () % pos : 0; + if (pos > 0) { + pos = rand () % pos; + } for (j = 0; (j < board->length) && (pos >= 0); j++) { if (getvalue (box, j % n, j / n) == ' ') { if (pos == 0) { @@ -144,12 +146,12 @@ board_t *initplay (board_t *board) } } - char *buffer = (char *) calloc (board->length * (8 + board->length) + 1, 1); - _makecomments (buffer, box); - printf ("box:\n%s", buffer); - _makecomments (buffer, board); - printf ("board:\n%s", buffer); - free (buffer); + char *buffer = (char *) calloc (board->length * (8 + board->length) + 1, 1); + _makecomments (buffer, box); + printf ("box:\n%s", buffer); + _makecomments (buffer, board); + printf ("board:\n%s", buffer); + free (buffer); freeboard (box); }