"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
build with -Wmissing-prototypes
To:
gameoftrees@openbsd.org
Date:
Sat, 25 Jun 2022 09:40:11 +0200

Download raw body.

Thread
as per title, what about if we build got with -Wmissing-prototypes?
Its purpose is to emit a warning when the compiler sees a non-static
function without having seen a corresponding prototype first.

The bulk of the diff is just adding `static' to local functions or add
missing include, but note that it also catched an unused function
got_path_is_current_dir.  (it was introduced in a129376 and never used)

thoughts?

diff /home/op/w/got
commit - 9802c41ca727979975e9ee6fbd898dfec7f283c4
path + /home/op/w/got
blob - 328c4a1e1795d88a1e53519b52ad67b9e682f85a
file + Makefile.inc
--- Makefile.inc
+++ Makefile.inc
@@ -10,7 +10,8 @@ BINDIR ?= ${PREFIX}/bin
 LIBEXECDIR ?= ${PREFIX}/libexec
 MANDIR ?= ${PREFIX}/man/man
 .else
-CFLAGS += -Werror -Wall -Wstrict-prototypes -Wunused-variable
+CFLAGS += -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes
+CFLAGS += -Wunused-variable
 PREFIX ?= ${HOME}
 BINDIR ?= ${PREFIX}/bin
 LIBEXECDIR ?= ${BINDIR}
blob - 98f3281d5becb5173121e9f4f0b74eee3b61bebf
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -405,7 +405,7 @@ usage_import(void)
 	exit(1);
 }
 
-int
+static int
 spawn_editor(const char *editor, const char *file)
 {
 	pid_t pid;
@@ -3118,7 +3118,7 @@ struct got_update_progress_arg {
 	int verbosity;
 };
 
-void
+static void
 print_update_progress_stats(struct got_update_progress_arg *upa)
 {
 	if (!upa->did_something)
@@ -3141,7 +3141,7 @@ print_update_progress_stats(struct got_update_progress
  * if the work tree was updated. This function should be used by any operation
  * which merges changes into the work tree without updating the work tree.
  */
-void
+static void
 print_merge_progress_stats(struct got_update_progress_arg *upa)
 {
 	if (!upa->did_something)
@@ -9154,7 +9154,7 @@ usage_rebase(void)
 	exit(1);
 }
 
-void
+static void
 trim_logmsg(char *logmsg, int limit)
 {
 	char *nl;
@@ -10697,7 +10697,7 @@ done:
 	return err;
 }
 
-void
+static void
 histedit_free_list(struct got_histedit_list *histedit_cmds)
 {
 	struct got_histedit_list_entry *hle;
blob - 096f0320a2c1debb9a1de9ac9c0a8e2bbab704cd
file + lib/dial.c
--- lib/dial.c
+++ lib/dial.c
@@ -31,6 +31,7 @@
 #include "got_path.h"
 
 #include "got_lib_dial.h"
+#include "got_dial.h"
 
 #ifndef nitems
 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
blob - 77f774c3d3737b31b6f815a4434406dd96458a69
file + lib/diff_main.c
--- lib/diff_main.c
+++ lib/diff_main.c
@@ -350,7 +350,7 @@ diff_state_add_chunk(struct diff_state *state, bool so
 	return diff_state_add_solved_chunk(state, &chunk);
 }
 
-void
+static void
 diff_data_init_root(struct diff_data *d, FILE *f, const uint8_t *data,
     unsigned long long len, int diff_flags)
 {
@@ -501,7 +501,7 @@ diff_algo_none(const struct diff_algo_config *algo_con
 	return DIFF_RC_OK;
 }
 
-int
+static int
 diff_run_algo(const struct diff_algo_config *algo_config,
 	      struct diff_state *state)
 {
blob - abcbc8d0355b6f45e427bb4374f6b94fc5c3d7f4
file + lib/diff_patience.c
--- lib/diff_patience.c
+++ lib/diff_patience.c
@@ -186,7 +186,7 @@ diff_atoms_mark_unique_in_both(struct diff_data *left,
 
 /* Use an optimized sorting algorithm (qsort, mergesort) to find unique lines */
 
-int diff_atoms_compar(const void *_a, const void *_b)
+static int diff_atoms_compar(const void *_a, const void *_b)
 {
 	const struct diff_atom *a = *(struct diff_atom**)_a;
 	const struct diff_atom *b = *(struct diff_atom**)_b;
blob - b05a8137d02606a3c4fee8f04809b0ac5cd71e8d
file + lib/fileindex.c
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -980,7 +980,7 @@ read_dirlist(struct got_pathlist_head *dirlist, DIR *d
 	return err;
 }
 
-void
+static void
 free_dirlist(struct got_pathlist_head *dirlist)
 {
 	struct got_pathlist_entry *dle;
blob - ab884984fe1018932f9071e31e6880538386570d
file + lib/gotconfig.c
--- lib/gotconfig.c
+++ lib/gotconfig.c
@@ -38,6 +38,8 @@
 #include "got_lib_privsep.h"
 #include "got_lib_gotconfig.h"
 
+#include "got_gotconfig.h"
+
 const struct got_error *
 got_gotconfig_read(struct got_gotconfig **conf, const char *gotconfig_path)
 {
blob - f39d1d87d659236f80c05f15876b571c2e27febf
file + lib/object.c
--- lib/object.c
+++ lib/object.c
@@ -1070,7 +1070,7 @@ request_tree(struct got_tree_object **tree, struct got
 	return got_privsep_recv_tree(tree, ibuf);
 }
 
-const struct got_error *
+static const struct got_error *
 read_tree_privsep(struct got_tree_object **tree, int obj_fd,
     struct got_object_id *id, struct got_repository *repo)
 {
blob - 644fb1ad06904cfc5d4c57cd3db0c88cd97119ea
file + lib/object_cache.c
--- lib/object_cache.c
+++ lib/object_cache.c
@@ -83,7 +83,7 @@ got_object_cache_init(struct got_object_cache *cache,
 	return NULL;
 }
 
-size_t
+static size_t
 get_size_obj(struct got_object *obj)
 {
 	size_t size = sizeof(*obj);
@@ -101,7 +101,7 @@ get_size_obj(struct got_object *obj)
 	return size;
 }
 
-size_t
+static size_t
 get_size_tree(struct got_tree_object *tree)
 {
 	size_t size = sizeof(*tree);
@@ -110,7 +110,7 @@ get_size_tree(struct got_tree_object *tree)
 	return size;
 }
 
-size_t
+static size_t
 get_size_commit(struct got_commit_object *commit)
 {
 	size_t size = sizeof(*commit);
@@ -127,7 +127,7 @@ get_size_commit(struct got_commit_object *commit)
 	return size;
 }
 
-size_t
+static size_t
 get_size_tag(struct got_tag_object *tag)
 {
 	size_t size = sizeof(*tag);
@@ -139,7 +139,7 @@ get_size_tag(struct got_tag_object *tag)
 	return size;
 }
 
-size_t
+static size_t
 get_size_raw(struct got_raw_object *raw)
 {
 	return sizeof(*raw);
blob - a3ad6737a9675482940881b8c700cfd61cb68e29
file + lib/object_create.c
--- lib/object_create.c
+++ lib/object_create.c
@@ -43,6 +43,8 @@
 #include "got_lib_object_parse.h"
 #include "got_lib_lockfile.h"
 
+#include "got_lib_object_create.h"
+
 #ifndef nitems
 #define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
 #endif
blob - 2e6d5f071a005d22724536b529a844122de2155f
file + lib/pack_create.c
--- lib/pack_create.c
+++ lib/pack_create.c
@@ -1784,7 +1784,7 @@ done:
 	return err;
 }
 
-const struct got_error *
+static const struct got_error *
 hwrite(FILE *f, void *buf, off_t len, SHA1_CTX *ctx)
 {
 	size_t n;
@@ -1796,7 +1796,7 @@ hwrite(FILE *f, void *buf, off_t len, SHA1_CTX *ctx)
 	return NULL;
 }
 
-const struct got_error *
+static const struct got_error *
 hcopy(FILE *fsrc, FILE *fdst, off_t len, SHA1_CTX *ctx)
 {
 	unsigned char buf[65536];
@@ -1818,7 +1818,7 @@ hcopy(FILE *fsrc, FILE *fdst, off_t len, SHA1_CTX *ctx
 	return NULL;
 }
 
-const struct got_error *
+static const struct got_error *
 hcopy_mmap(uint8_t *src, off_t src_offset, size_t src_size,
     FILE *fdst, off_t len, SHA1_CTX *ctx)
 {
blob - f4b3d337163db35814aa20bf256f110b9febeb41
file + lib/path.c
--- lib/path.c
+++ lib/path.c
@@ -148,12 +148,6 @@ got_path_is_root_dir(const char *path)
 }
 
 int
-got_path_is_current_dir(const char *path)
-{
-	return (path[0] == '.' && path[1] == '\0');
-}
-
-int
 got_path_is_child(const char *child, const char *parent, size_t parent_len)
 {
 	if (parent_len == 0 || got_path_is_root_dir(parent))
blob - b9ef91ba3083180edcfef203a56a0a06f4273b2b
file + lib/pkt.c
--- lib/pkt.c
+++ lib/pkt.c
@@ -23,6 +23,7 @@
 #include <unistd.h>
 
 #include "got_error.h"
+#include "got_lib_pkt.h"
 
 const struct got_error *
 got_pkt_readn(ssize_t *off, int fd, void *buf, size_t n)
blob - ce17d48b6a8e1d25bb31f00aae6c63b3b8bdddc7
file + lib/privsep.c
--- lib/privsep.c
+++ lib/privsep.c
@@ -48,6 +48,8 @@
 #include "got_lib_privsep.h"
 #include "got_lib_pack.h"
 
+#include "got_privsep.h"
+
 #ifndef MIN
 #define	MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
 #endif
blob - 0fefe7552a676b9488741693766a6ec76dcacf60
file + lib/worktree.c
--- lib/worktree.c
+++ lib/worktree.c
@@ -3350,7 +3350,7 @@ status_old(void *arg, struct got_fileindex_entry *ie, 
 	    ie->path, &blob_id, NULL, &commit_id, -1, NULL);
 }
 
-void
+static void
 free_ignorelist(struct got_pathlist_head *ignorelist)
 {
 	struct got_pathlist_entry *pe;
@@ -3360,7 +3360,7 @@ free_ignorelist(struct got_pathlist_head *ignorelist)
 	got_pathlist_free(ignorelist);
 }
 
-void
+static void
 free_ignores(struct got_pathlist_head *ignores)
 {
 	struct got_pathlist_entry *pe;
@@ -3429,7 +3429,7 @@ done:
 	return err;
 }
 
-int
+static int
 match_ignores(struct got_pathlist_head *ignores, const char *path)
 {
 	struct got_pathlist_entry *pe;
@@ -5596,7 +5596,7 @@ done:
 	return err;
 }
 
-const struct got_error *
+static const struct got_error *
 commit_worktree(struct got_object_id **new_commit_id,
     struct got_pathlist_head *commitable_paths,
     struct got_object_id *head_commit_id,
@@ -6637,7 +6637,7 @@ done:
 	return err;
 }
 
-const struct got_error *
+static const struct got_error *
 create_backup_ref(const char *backup_ref_prefix, struct got_reference *branch,
     struct got_object_id *new_commit_id, struct got_repository *repo)
 {
@@ -7918,7 +7918,7 @@ struct check_stage_ok_arg {
 	int have_changes;
 };
 
-const struct got_error *
+static const struct got_error *
 check_stage_ok(void *arg, unsigned char status,
     unsigned char staged_status, const char *relpath,
     struct got_object_id *blob_id, struct got_object_id *staged_blob_id,
blob - 1c790b2db1b1ff2264cbe8535dda3cd449e7753f
file + libexec/got-read-gotconfig/parse.y
--- libexec/got-read-gotconfig/parse.y
+++ libexec/got-read-gotconfig/parse.y
@@ -73,6 +73,7 @@ struct sym {
 };
 
 int	 symset(const char *, const char *, int);
+int	 cmdline_symset(char *);
 char	*symget(const char *);
 
 static int	 atoul(char *, u_long *);
blob - cb01bcd4c601aae790a8c7ed5467fd7dc9bc7f1b
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -224,7 +224,7 @@ free_colors(struct tog_colors *colors)
 	}
 }
 
-struct tog_color *
+static struct tog_color *
 get_color(struct tog_colors *colors, int colorpair)
 {
 	struct tog_color *tc = NULL;
@@ -1023,7 +1023,7 @@ view_input(struct tog_view **new, int *done, struct to
 	return err;
 }
 
-void
+static void
 view_vborder(struct tog_view *view)
 {
 	PANEL *panel;
@@ -1041,7 +1041,7 @@ view_vborder(struct tog_view *view)
 	    got_locale_is_utf8() ? ACS_VLINE : '|', view->nlines);
 }
 
-int
+static int
 view_needs_focus_indication(struct tog_view *view)
 {
 	if (view_is_parent_view(view)) {
@@ -3108,7 +3108,7 @@ match_line(const char *line, regex_t *regex, size_t nm
 	return regexec(regex, line, nmatch, regmatch, 0) == 0;
 }
 
-struct tog_color *
+static struct tog_color *
 match_color(struct tog_colors *colors, const char *line)
 {
 	struct tog_color *tc = NULL;
@@ -6267,7 +6267,7 @@ ref_view_load_refs(struct tog_ref_view_state *s)
 	return NULL;
 }
 
-void
+static void
 ref_view_free_refs(struct tog_ref_view_state *s)
 {
 	struct tog_reflist_entry *re;