Download raw body.
build with -Wmissing-prototypes
Omar Polo <op@omarpolo.com> wrote: > 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? I forgot about regress, updated diff. diff refs/remotes/got/main refs/heads/wmissingproto commit - 9802c41ca727979975e9ee6fbd898dfec7f283c4 commit + c486b8f9c13f2088bf7c337849062915f89d9814 blob - 328c4a1e1795d88a1e53519b52ad67b9e682f85a blob + ef99224d337170364b2e5458bf6e2a3206c3e05a --- 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 blob + 79d2837a85b78836e571782fcb582caecb77e697 --- 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 blob + 4f688a96c44c72c60f3157e3d1293fcca25111c6 --- 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 blob + dd83abd4cdf8024f27f362b535f73b9a965c0073 --- 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 blob + a06df2c36c9d8cb203803661ff563e969a584e88 --- 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 blob + 52947dd222fcda2c7cb0b987113304a68bb33445 --- 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 blob + 5b602c9f5513aee64b98ca608535d5b85280ec42 --- 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 blob + 7a1fbe3ab0e107d0ec9075abdf9379a3b9de0071 --- 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 blob + 6ed62392ac8837da1d05604c313f32b82d0d4d7c --- 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 blob + 5036de1b9a6b491a1fc7c0358a03dcd9574f6cf3 --- 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 blob + 2b957c17029c594fc2791494cf62d176ad552645 --- 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 blob + 19dc9c983445c68dbea181cf6bfabcfd1ee9d949 --- 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 blob + a845118f6e6f64c5061dd5eef11341341e9ad2ff --- 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 blob + 70eb167c5ee71b29c045bdae0de5c7b7859403f7 --- 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 blob + ae1ce6d136c77ab98e72f28c8a75c47893044c9b --- 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 blob + b9a0bd38cabe5d893cbbb04c482578a895a094ed --- 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 - 5077275c15513b4be193788a5f50ce0fff48b24a blob + 9d84105f23ebcedee81341088dc0fd38cb0c4261 --- regress/fetch/fetch_test.c +++ regress/fetch/fetch_test.c @@ -45,7 +45,7 @@ static int verbose; static int quiet; -void +static void test_printf(char *fmt, ...) { va_list ap; @@ -248,7 +248,7 @@ fetch_parse_uri(void) if (!quiet) printf("test_%s %s\n", (name), test_ok ? "ok" : "failed"); \ failure = (failure || !test_ok); } -void +static void usage(void) { fprintf(stderr, "usage: fetch_test [-v] [-q]\n"); blob - 64c131e2e42815b06f5e84d8179dd9244cee3c1f blob + 920e69e004d588ab238d738e0915a89dc67bf9eb --- regress/idset/idset_test.c +++ regress/idset/idset_test.c @@ -38,19 +38,6 @@ static int verbose; static int quiet; -void -test_printf(char *fmt, ...) -{ - va_list ap; - - if (!verbose) - return; - - va_start(ap, fmt); - vprintf(fmt, ap); - va_end(ap); -} - static const char *id_str1 = "1111111111111111111111111111111111111111"; static const char *id_str2 = "2222222222222222222222222222222222222222"; static const char *id_str3 = "ffffffffffffffffffffffffffffffffffffffff"; @@ -173,7 +160,7 @@ done: if (!quiet) printf("test_%s %s\n", (name), test_ok ? "ok" : "failed"); \ failure = (failure || !test_ok); } -void +static void usage(void) { fprintf(stderr, "usage: id_test [-v] [-q]\n"); blob - 76b5b1f6f53409fd36f72543864785faa2adb4bc blob + e8001a520fd4f5763bc38dbfb1c94be3fdd0e531 --- regress/path/path_test.c +++ regress/path/path_test.c @@ -33,7 +33,7 @@ static int verbose; static int quiet; -void +static void test_printf(char *fmt, ...) { va_list ap; @@ -211,7 +211,7 @@ path_list_reverse_input(void) if (!quiet) printf("test_%s %s\n", (name), test_ok ? "ok" : "failed"); \ failure = (failure || !test_ok); } -void +static void usage(void) { fprintf(stderr, "usage: path_test [-v] [-q]\n"); blob - cb01bcd4c601aae790a8c7ed5467fd7dc9bc7f1b blob + 41a950c7323ca7ddaf41ebf785ac7598d899d149 --- 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;
build with -Wmissing-prototypes