aboutsummaryrefslogtreecommitdiff
path: root/unfinished
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-02-16 21:21:15 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-02-18 00:13:15 +0000
commit0186d78da9e83103eb80b3814d4de8031f29232f (patch)
tree26774b7be7540d980a1ee5cba5d83445a528bd5b /unfinished
parenta7e738aceb36e4a70d41cf09a74b2d7a3af6cbe0 (diff)
downloadpuzzles-0186d78da9e83103eb80b3814d4de8031f29232f.zip
puzzles-0186d78da9e83103eb80b3814d4de8031f29232f.tar.gz
puzzles-0186d78da9e83103eb80b3814d4de8031f29232f.tar.bz2
puzzles-0186d78da9e83103eb80b3814d4de8031f29232f.tar.xz
Mark many more function (and some objects) static
I noticed commit db3b531e2cab765a00475054d2e9046c9d0437d3 in the history where Simon added a bunch of "static" qualifiers. That suggested that consistently marking internal functions "static" is desirable, so I tried a build using GCC's -Wmissing-declarations, which requires prior declaration (presumed to be in a header file) of all global functions. This commit makes the GTK build clean under GCC's -Wmissing-declarations. I've also adding "static" to a few obviously internal objects, but GCC doesn't complain about those so I certainly haven't got them all.
Diffstat (limited to 'unfinished')
-rw-r--r--unfinished/numgame.c16
-rw-r--r--unfinished/separate.c16
-rw-r--r--unfinished/sokoban.c2
3 files changed, 17 insertions, 17 deletions
diff --git a/unfinished/numgame.c b/unfinished/numgame.c
index e6dc03a..b819a93 100644
--- a/unfinished/numgame.c
+++ b/unfinished/numgame.c
@@ -987,11 +987,11 @@ static void free_sets(struct sets *s)
/*
* Print a text formula for producing a given output.
*/
-void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
- int priority, int assoc, int child);
-void print_recurse_inner(struct sets *s, struct set *ss,
- struct ancestor *a, int pathindex, int index,
- int priority, int assoc, int child)
+static void print_recurse(struct sets *s, struct set *ss, int pathindex,
+ int index, int priority, int assoc, int child);
+static void print_recurse_inner(struct sets *s, struct set *ss,
+ struct ancestor *a, int pathindex, int index,
+ int priority, int assoc, int child)
{
if (a->prev && index != a->pr) {
int pi;
@@ -1066,8 +1066,8 @@ void print_recurse_inner(struct sets *s, struct set *ss,
printf("/%d", ss->numbers[2*index+1]);
}
}
-void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
- int priority, int assoc, int child)
+static void print_recurse(struct sets *s, struct set *ss, int pathindex,
+ int index, int priority, int assoc, int child)
{
if (!ss->a.prev || pathindex < ss->a.prev->npaths) {
print_recurse_inner(s, ss, &ss->a, pathindex,
@@ -1085,7 +1085,7 @@ void print_recurse(struct sets *s, struct set *ss, int pathindex, int index,
}
}
}
-void print(int pathindex, struct sets *s, struct output *o)
+static void print(int pathindex, struct sets *s, struct output *o)
{
print_recurse(s, o->set, pathindex, o->index, 0, 0, 0);
}
diff --git a/unfinished/separate.c b/unfinished/separate.c
index 1a8edc6..9ffa632 100644
--- a/unfinished/separate.c
+++ b/unfinished/separate.c
@@ -215,7 +215,7 @@ struct solver_scratch {
int *tmp;
};
-struct solver_scratch *solver_scratch_new(int w, int h, int k)
+static struct solver_scratch *solver_scratch_new(int w, int h, int k)
{
int wh = w*h;
struct solver_scratch *sc = snew(struct solver_scratch);
@@ -233,7 +233,7 @@ struct solver_scratch *solver_scratch_new(int w, int h, int k)
return sc;
}
-void solver_scratch_free(struct solver_scratch *sc)
+static void solver_scratch_free(struct solver_scratch *sc)
{
sfree(sc->dsf);
sfree(sc->size);
@@ -243,7 +243,7 @@ void solver_scratch_free(struct solver_scratch *sc)
sfree(sc);
}
-void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
+static void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
{
int w = sc->w, h = sc->h, k = sc->k;
int wh = w*h;
@@ -297,7 +297,7 @@ void solver_connect(struct solver_scratch *sc, int yx1, int yx2)
sc->disconnect[i*wh+yx2]);
}
-void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
+static void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
{
int w = sc->w, h = sc->h;
int wh = w*h;
@@ -316,7 +316,7 @@ void solver_disconnect(struct solver_scratch *sc, int yx1, int yx2)
sc->disconnect[yx2*wh+yx1] = true;
}
-void solver_init(struct solver_scratch *sc)
+static void solver_init(struct solver_scratch *sc)
{
int w = sc->w, h = sc->h;
int wh = w*h;
@@ -332,8 +332,8 @@ void solver_init(struct solver_scratch *sc)
memset(sc->disconnect, 0, wh*wh * sizeof(bool));
}
-int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
- bool *gen_lock)
+static int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
+ bool *gen_lock)
{
int w = sc->w, h = sc->h, k = sc->k;
int wh = w*h;
@@ -492,7 +492,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
return 0;
}
-unsigned char *generate(int w, int h, int k, random_state *rs)
+static unsigned char *generate(int w, int h, int k, random_state *rs)
{
int wh = w*h;
int n = wh/k;
diff --git a/unfinished/sokoban.c b/unfinished/sokoban.c
index 26c957c..80596c2 100644
--- a/unfinished/sokoban.c
+++ b/unfinished/sokoban.c
@@ -957,7 +957,7 @@ struct game_drawstate {
* subfunction. move_type() returns -1 for an illegal move, 0 for a
* movement, and 1 for a push.
*/
-int move_type(const game_state *state, int dx, int dy)
+static int move_type(const game_state *state, int dx, int dy)
{
int w = state->p.w, h = state->p.h;
int px = state->px, py = state->py;