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.
This commit is contained in:
Ben Harris
2023-02-16 21:21:15 +00:00
parent a7e738aceb
commit 0186d78da9
12 changed files with 113 additions and 109 deletions

View File

@ -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;