diff options
author | Patrick Steinhardt <ps@pks.im> | 2020-06-08 12:40:47 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2020-06-09 14:57:06 +0200 |
commit | a6c9e0b367c4882ab0f8e78bd0ad4ab2904ac377 (patch) | |
tree | e45c4ff8b8110a46f5bd84f0415c6c537b27ecb5 | |
parent | 7c499b544dc3383cce38956f86d67f328bc718e6 (diff) | |
download | libgit2-a6c9e0b367c4882ab0f8e78bd0ad4ab2904ac377.tar.gz |
tree-wide: mark local functions as static
We've accumulated quite some functions which are never used outside of
their respective code unit, but which are lacking the `static` keyword.
Add it to reduce their linkage scope and allow the compiler to optimize
better.
-rw-r--r-- | src/checkout.c | 2 | ||||
-rw-r--r-- | src/config.c | 2 | ||||
-rw-r--r-- | src/diff.c | 12 | ||||
-rw-r--r-- | src/diff_generate.c | 16 | ||||
-rw-r--r-- | src/diff_print.c | 2 | ||||
-rw-r--r-- | src/diff_stats.c | 12 | ||||
-rw-r--r-- | src/filter.c | 6 | ||||
-rw-r--r-- | src/merge.c | 4 | ||||
-rw-r--r-- | src/merge_file.c | 10 | ||||
-rw-r--r-- | src/pack-objects.c | 10 | ||||
-rw-r--r-- | src/patch_parse.c | 2 | ||||
-rw-r--r-- | src/path.c | 6 | ||||
-rw-r--r-- | src/pool.c | 4 | ||||
-rw-r--r-- | src/refs.c | 4 | ||||
-rw-r--r-- | src/remote.c | 4 | ||||
-rw-r--r-- | src/revparse.c | 4 | ||||
-rw-r--r-- | src/submodule.c | 8 | ||||
-rw-r--r-- | src/transports/httpclient.c | 2 | ||||
-rw-r--r-- | src/util.c | 6 | ||||
-rw-r--r-- | src/win32/path_w32.c | 4 |
20 files changed, 59 insertions, 61 deletions
diff --git a/src/checkout.c b/src/checkout.c index 1e6ea4ddf..44a867153 100644 --- a/src/checkout.c +++ b/src/checkout.c @@ -806,7 +806,7 @@ static int checkout_conflictdata_cmp(const void *a, const void *b) return diff; } -int checkout_conflictdata_empty( +static int checkout_conflictdata_empty( const git_vector *conflicts, size_t idx, void *payload) { checkout_conflictdata *conflict; diff --git a/src/config.c b/src/config.c index 8338da010..81f010fa2 100644 --- a/src/config.c +++ b/src/config.c @@ -1000,7 +1000,7 @@ static int multivar_iter_next(git_config_entry **entry, git_config_iterator *_it return error; } -void multivar_iter_free(git_config_iterator *_iter) +static void multivar_iter_free(git_config_iterator *_iter) { multivar_iter *iter = (multivar_iter *) _iter; diff --git a/src/diff.c b/src/diff.c index efbedb50b..9fd361343 100644 --- a/src/diff.c +++ b/src/diff.c @@ -150,7 +150,7 @@ int git_diff_foreach( return error; } -int git_diff_format_email__append_header_tobuf( +static int diff_format_email_append_header_tobuf( git_buf *out, const git_oid *id, const git_signature *author, @@ -207,7 +207,7 @@ int git_diff_format_email__append_header_tobuf( return error; } -int git_diff_format_email__append_patches_tobuf( +static int diff_format_email_append_patches_tobuf( git_buf *out, git_diff *diff) { @@ -287,7 +287,7 @@ int git_diff_format_email( strncpy(summary, opts->summary, offset); } - error = git_diff_format_email__append_header_tobuf(out, + error = diff_format_email_append_header_tobuf(out, opts->id, opts->author, summary == NULL ? opts->summary : summary, opts->body, opts->patch_no, opts->total_patches, ignore_marker); @@ -300,7 +300,7 @@ int git_diff_format_email( (error = git_diff_get_stats(&stats, diff)) < 0 || (error = git_diff_stats_to_buf(out, stats, format_flags, 0)) < 0 || (error = git_buf_putc(out, '\n')) < 0 || - (error = git_diff_format_email__append_patches_tobuf(out, diff)) < 0) + (error = diff_format_email_append_patches_tobuf(out, diff)) < 0) goto on_error; error = git_buf_puts(out, "--\nlibgit2 " LIBGIT2_VERSION "\n\n"); @@ -421,7 +421,7 @@ static void strip_spaces(git_buf *buf) git_buf_truncate(buf, len); } -int git_diff_patchid_print_callback__to_buf( +static int diff_patchid_print_callback_to_buf( const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, @@ -480,7 +480,7 @@ int git_diff_patchid(git_oid *out, git_diff *diff, git_diff_patchid_options *opt if ((error = git_diff_print(diff, GIT_DIFF_FORMAT_PATCH_ID, - git_diff_patchid_print_callback__to_buf, + diff_patchid_print_callback_to_buf, &args)) < 0) goto out; diff --git a/src/diff_generate.c b/src/diff_generate.c index e9e524229..e7bfd6223 100644 --- a/src/diff_generate.c +++ b/src/diff_generate.c @@ -301,14 +301,14 @@ GIT_INLINE(const char *) diff_delta__i2w_path(const git_diff_delta *delta) delta->old_file.path : delta->new_file.path; } -int git_diff_delta__i2w_cmp(const void *a, const void *b) +static int diff_delta_i2w_cmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); return val ? val : ((int)da->status - (int)db->status); } -int git_diff_delta__i2w_casecmp(const void *a, const void *b) +static int diff_delta_i2w_casecmp(const void *a, const void *b) { const git_diff_delta *da = a, *db = b; int val = strcasecmp(diff_delta__i2w_path(da), diff_delta__i2w_path(db)); @@ -361,7 +361,7 @@ static const char *diff_mnemonic_prefix( return pfx; } -void git_diff__set_ignore_case(git_diff *diff, bool ignore_case) +static void diff_set_ignore_case(git_diff *diff, bool ignore_case) { if (!ignore_case) { diff->opts.flags &= ~GIT_DIFF_IGNORE_CASE; @@ -431,7 +431,7 @@ static git_diff_generated *diff_generated_alloc( /* Use case-insensitive compare if either iterator has * the ignore_case bit set */ - git_diff__set_ignore_case( + diff_set_ignore_case( &diff->base, git_iterator_ignore_case(old_iter) || git_iterator_ignore_case(new_iter)); @@ -1375,7 +1375,7 @@ int git_diff_tree_to_index( /* if index is in case-insensitive order, re-sort deltas to match */ if (index_ignore_case) - git_diff__set_ignore_case(diff, true); + diff_set_ignore_case(diff, true); *out = diff; diff = NULL; @@ -1526,7 +1526,7 @@ int git_diff_index_to_index( /* if index is in case-insensitive order, re-sort deltas to match */ if (old_index->ignore_case || new_index->ignore_case) - git_diff__set_ignore_case(diff, true); + diff_set_ignore_case(diff, true); *out = diff; diff = NULL; @@ -1583,10 +1583,10 @@ int git_diff__paired_foreach( if (i2w_icase && !icase_mismatch) { strcomp = git__strcasecmp; - git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_casecmp); + git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_casecmp); git_vector_sort(&idx2wd->deltas); } else if (idx2wd != NULL) { - git_vector_set_cmp(&idx2wd->deltas, git_diff_delta__i2w_cmp); + git_vector_set_cmp(&idx2wd->deltas, diff_delta_i2w_cmp); git_vector_sort(&idx2wd->deltas); } diff --git a/src/diff_print.c b/src/diff_print.c index a78953c32..9ff6d9a7a 100644 --- a/src/diff_print.c +++ b/src/diff_print.c @@ -337,7 +337,7 @@ static int diff_delta_format_with_paths( return git_buf_printf(out, template, oldpath, newpath); } -int diff_delta_format_similarity_header( +static int diff_delta_format_similarity_header( git_buf *out, const git_diff_delta *delta) { diff --git a/src/diff_stats.c b/src/diff_stats.c index 19c9da05f..1028b01a7 100644 --- a/src/diff_stats.c +++ b/src/diff_stats.c @@ -46,7 +46,7 @@ static int digits_for_value(size_t val) return count; } -int git_diff_file_stats__full_to_buf( +static int diff_file_stats_full_to_buf( git_buf *out, const git_diff_delta *delta, const diff_file_stats *filestat, @@ -134,7 +134,7 @@ on_error: return (git_buf_oom(out) ? -1 : 0); } -int git_diff_file_stats__number_to_buf( +static int diff_file_stats_number_to_buf( git_buf *out, const git_diff_delta *delta, const diff_file_stats *filestats) @@ -151,7 +151,7 @@ int git_diff_file_stats__number_to_buf( return error; } -int git_diff_file_stats__summary_to_buf( +static int diff_file_stats_summary_to_buf( git_buf *out, const git_diff_delta *delta) { @@ -288,7 +288,7 @@ int git_diff_stats_to_buf( if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; - error = git_diff_file_stats__number_to_buf( + error = diff_file_stats_number_to_buf( out, delta, &stats->filestats[i]); if (error < 0) return error; @@ -309,7 +309,7 @@ int git_diff_stats_to_buf( if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; - error = git_diff_file_stats__full_to_buf( + error = diff_file_stats_full_to_buf( out, delta, &stats->filestats[i], stats, width); if (error < 0) return error; @@ -342,7 +342,7 @@ int git_diff_stats_to_buf( if ((delta = git_diff_get_delta(stats->diff, i)) == NULL) continue; - error = git_diff_file_stats__summary_to_buf(out, delta); + error = diff_file_stats_summary_to_buf(out, delta); if (error < 0) return error; } diff --git a/src/filter.c b/src/filter.c index bb9d66ad6..09b57dc80 100644 --- a/src/filter.c +++ b/src/filter.c @@ -941,7 +941,7 @@ out: return error; } -void stream_list_free(git_vector *streams) +static void filter_streams_free(git_vector *streams) { git_writestream *stream; size_t i; @@ -990,7 +990,7 @@ done: if (fd >= 0) p_close(fd); - stream_list_free(&filter_streams); + filter_streams_free(&filter_streams); git_buf_dispose(&abspath); return error; } @@ -1018,7 +1018,7 @@ out: if (initialized) error |= stream_start->close(stream_start); - stream_list_free(&filter_streams); + filter_streams_free(&filter_streams); return error; } diff --git a/src/merge.c b/src/merge.c index 6e3a6c648..652b7ea6e 100644 --- a/src/merge.c +++ b/src/merge.c @@ -80,7 +80,7 @@ static int cache_invalid_marker; /* Merge base computation */ -int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[]) +static int merge_bases_many(git_commit_list **out, git_revwalk **walk_out, git_repository *repo, size_t length, const git_oid input_array[]) { git_revwalk *walk = NULL; git_vector list; @@ -2845,7 +2845,7 @@ on_error: return error; } -const char *merge_their_label(const char *branchname) +static const char *merge_their_label(const char *branchname) { const char *slash; diff --git a/src/merge_file.c b/src/merge_file.c index 23daa84c4..755340fa9 100644 --- a/src/merge_file.c +++ b/src/merge_file.c @@ -28,7 +28,7 @@ #define GIT_MERGE_FILE_SIDE_EXISTS(X) ((X)->mode != 0) -int git_merge_file__input_from_index( +static int merge_file_input_from_index( git_merge_file_input *input_out, git_odb_object **odb_object_out, git_odb *odb, @@ -276,17 +276,15 @@ int git_merge_file_from_index( goto done; if (ancestor) { - if ((error = git_merge_file__input_from_index( + if ((error = merge_file_input_from_index( &ancestor_input, &odb_object[0], odb, ancestor)) < 0) goto done; ancestor_ptr = &ancestor_input; } - if ((error = git_merge_file__input_from_index( - &our_input, &odb_object[1], odb, ours)) < 0 || - (error = git_merge_file__input_from_index( - &their_input, &odb_object[2], odb, theirs)) < 0) + if ((error = merge_file_input_from_index(&our_input, &odb_object[1], odb, ours)) < 0 || + (error = merge_file_input_from_index(&their_input, &odb_object[2], odb, theirs)) < 0) goto done; error = merge_file__from_inputs(out, diff --git a/src/pack-objects.c b/src/pack-objects.c index 1ac618a84..cf10e6cb5 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -1642,7 +1642,7 @@ static int mark_edges_uninteresting(git_packbuilder *pb, git_commit_list *commit return 0; } -int insert_tree(git_packbuilder *pb, git_tree *tree) +static int pack_objects_insert_tree(git_packbuilder *pb, git_tree *tree) { size_t i; int error; @@ -1669,7 +1669,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) if ((error = git_tree_lookup(&subtree, pb->repo, entry_id)) < 0) return error; - error = insert_tree(pb, subtree); + error = pack_objects_insert_tree(pb, subtree); git_tree_free(subtree); if (error < 0) @@ -1695,7 +1695,7 @@ int insert_tree(git_packbuilder *pb, git_tree *tree) return error; } -int insert_commit(git_packbuilder *pb, struct walk_object *obj) +static int pack_objects_insert_commit(git_packbuilder *pb, struct walk_object *obj) { int error; git_commit *commit = NULL; @@ -1712,7 +1712,7 @@ int insert_commit(git_packbuilder *pb, struct walk_object *obj) if ((error = git_tree_lookup(&tree, pb->repo, git_commit_tree_id(commit))) < 0) goto cleanup; - if ((error = insert_tree(pb, tree)) < 0) + if ((error = pack_objects_insert_tree(pb, tree)) < 0) goto cleanup; cleanup: @@ -1747,7 +1747,7 @@ int git_packbuilder_insert_walk(git_packbuilder *pb, git_revwalk *walk) if (obj->seen || obj->uninteresting) continue; - if ((error = insert_commit(pb, obj)) < 0) + if ((error = pack_objects_insert_commit(pb, obj)) < 0) return error; } diff --git a/src/patch_parse.c b/src/patch_parse.c index 0e251cb88..918575306 100644 --- a/src/patch_parse.c +++ b/src/patch_parse.c @@ -941,7 +941,7 @@ static int parse_patch_body( return parse_patch_hunks(patch, ctx); } -int check_header_names( +static int check_header_names( const char *one, const char *two, const char *old_or_new, diff --git a/src/path.c b/src/path.c index 625b95c0d..0d0b40f9c 100644 --- a/src/path.c +++ b/src/path.c @@ -322,7 +322,7 @@ int git_path_root(const char *path) return -1; /* Not a real error - signals that path is not rooted */ } -void git_path_trim_slashes(git_buf *path) +static void path_trim_slashes(git_buf *path) { int ceiling = git_path_root(path->ptr) + 1; assert(ceiling >= 0); @@ -1219,7 +1219,7 @@ int git_path_diriter_init( if (git_buf_puts(&diriter->path_utf8, path) < 0) return -1; - git_path_trim_slashes(&diriter->path_utf8); + path_trim_slashes(&diriter->path_utf8); if (diriter->path_utf8.size == 0) { git_error_set(GIT_ERROR_FILESYSTEM, "could not open directory '%s'", path); @@ -1368,7 +1368,7 @@ int git_path_diriter_init( if (git_buf_puts(&diriter->path, path) < 0) return -1; - git_path_trim_slashes(&diriter->path); + path_trim_slashes(&diriter->path); if (diriter->path.size == 0) { git_error_set(GIT_ERROR_FILESYSTEM, "could not open directory '%s'", path); diff --git a/src/pool.c b/src/pool.c index baae91882..cb98f1af1 100644 --- a/src/pool.c +++ b/src/pool.c @@ -21,7 +21,7 @@ struct git_pool_page { static void *pool_alloc_page(git_pool *pool, size_t size); -size_t git_pool__system_page_size(void) +static size_t pool_system_page_size(void) { static size_t size = 0; @@ -44,7 +44,7 @@ int git_pool_init(git_pool *pool, size_t item_size) memset(pool, 0, sizeof(git_pool)); pool->item_size = item_size; - pool->page_size = git_pool__system_page_size(); + pool->page_size = pool_system_page_size(); return 0; } diff --git a/src/refs.c b/src/refs.c index 633d83abd..c5d69c18c 100644 --- a/src/refs.c +++ b/src/refs.c @@ -480,7 +480,7 @@ static int reference__create( return 0; } -int configured_ident(git_signature **out, const git_repository *repo) +static int refs_configured_ident(git_signature **out, const git_repository *repo) { if (repo->ident_name && repo->ident_email) return git_signature_now(out, repo->ident_name, repo->ident_email); @@ -494,7 +494,7 @@ int git_reference__log_signature(git_signature **out, git_repository *repo) int error; git_signature *who; - if(((error = configured_ident(&who, repo)) < 0) && + if(((error = refs_configured_ident(&who, repo)) < 0) && ((error = git_signature_default(&who, repo)) < 0) && ((error = git_signature_now(&who, "unknown", "unknown")) < 0)) return error; diff --git a/src/remote.c b/src/remote.c index b0ccf0305..78e056a9d 100644 --- a/src/remote.c +++ b/src/remote.c @@ -686,7 +686,7 @@ int git_remote__urlfordirection(git_buf *url_out, struct git_remote *remote, int return resolve_url(url_out, url, direction, callbacks); } -int set_transport_callbacks(git_transport *t, const git_remote_callbacks *cbs) +static int remote_transport_set_callbacks(git_transport *t, const git_remote_callbacks *cbs) { if (!t->set_callbacks || !cbs) return 0; @@ -744,7 +744,7 @@ int git_remote__connect(git_remote *remote, git_direction direction, const git_r if ((error = set_transport_custom_headers(t, conn->custom_headers)) != 0) goto on_error; - if ((error = set_transport_callbacks(t, callbacks)) < 0 || + if ((error = remote_transport_set_callbacks(t, callbacks)) < 0 || (error = t->connect(t, url.ptr, credentials, payload, conn->proxy, direction, flags)) != 0) goto on_error; diff --git a/src/revparse.c b/src/revparse.c index c627de67c..9e0790f6b 100644 --- a/src/revparse.c +++ b/src/revparse.c @@ -659,7 +659,7 @@ static int ensure_left_hand_identifier_is_not_known_yet(git_object *object, git_ return GIT_EINVALIDSPEC; } -int revparse__ext( +static int revparse( git_object **object_out, git_reference **reference_out, size_t *identifier_len_out, @@ -835,7 +835,7 @@ int git_revparse_ext( git_object *obj = NULL; git_reference *ref = NULL; - if ((error = revparse__ext(&obj, &ref, &identifier_len, repo, spec)) < 0) + if ((error = revparse(&obj, &ref, &identifier_len, repo, spec)) < 0) goto cleanup; *object_out = obj; diff --git a/src/submodule.c b/src/submodule.c index 1690e08f8..7ae78c181 100644 --- a/src/submodule.c +++ b/src/submodule.c @@ -958,7 +958,7 @@ cleanup: return error; } -const char *git_submodule_update_to_str(git_submodule_update_t update) +static const char *submodule_update_to_str(git_submodule_update_t update) { int i; for (i = 0; i < (int)ARRAY_SIZE(_sm_update_map); ++i) @@ -1401,7 +1401,7 @@ int git_submodule_init(git_submodule *sm, int overwrite) /* write "submodule.NAME.update" if not default */ val = (sm->update == GIT_SUBMODULE_UPDATE_CHECKOUT) ? - NULL : git_submodule_update_to_str(sm->update); + NULL : submodule_update_to_str(sm->update); if ((error = git_buf_printf(&key, "submodule.%s.update", sm->name)) < 0 || (error = git_config__update_entry( @@ -1838,7 +1838,7 @@ int git_submodule_parse_update(git_submodule_update_t *out, const char *value) return 0; } -int git_submodule_parse_recurse(git_submodule_recurse_t *out, const char *value) +static int submodule_parse_recurse(git_submodule_recurse_t *out, const char *value) { int val; @@ -1934,7 +1934,7 @@ static int submodule_read_config(git_submodule *sm, git_config *cfg) if ((error = get_value(&value, cfg, &key, sm->name, "fetchRecurseSubmodules")) == 0) { in_config = 1; - if ((error = git_submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) + if ((error = submodule_parse_recurse(&sm->fetch_recurse, value)) < 0) goto cleanup; sm->fetch_recurse_default = sm->fetch_recurse; } else if (error != GIT_ENOTFOUND) { diff --git a/src/transports/httpclient.c b/src/transports/httpclient.c index 010baa604..dda267833 100644 --- a/src/transports/httpclient.c +++ b/src/transports/httpclient.c @@ -445,7 +445,7 @@ GIT_INLINE(int) client_write_request(git_http_client *client) 0); } -const char *name_for_method(git_http_method method) +static const char *name_for_method(git_http_method method) { switch (method) { case GIT_HTTP_METHOD_GET: diff --git a/src/util.c b/src/util.c index c4e322d5a..2efb212bc 100644 --- a/src/util.c +++ b/src/util.c @@ -777,7 +777,7 @@ static const int8_t utf8proc_utf8class[256] = { 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 }; -int git__utf8_charlen(const uint8_t *str, size_t str_len) +static int util_utf8_charlen(const uint8_t *str, size_t str_len) { size_t length, i; @@ -802,7 +802,7 @@ int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst) int32_t uc = -1; *dst = -1; - length = git__utf8_charlen(str, str_len); + length = util_utf8_charlen(str, str_len); if (length < 0) return -1; @@ -839,7 +839,7 @@ size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len) size_t offset = 0; while (offset < str_len) { - int length = git__utf8_charlen(str + offset, str_len - offset); + int length = util_utf8_charlen(str + offset, str_len - offset); if (length < 0) break; diff --git a/src/win32/path_w32.c b/src/win32/path_w32.c index 18b43e728..9faddcf3b 100644 --- a/src/win32/path_w32.c +++ b/src/win32/path_w32.c @@ -151,7 +151,7 @@ int git_win32_path_canonicalize(git_win32_path path) return (int)(to - path); } -int git_win32_path__cwd(wchar_t *out, size_t len) +static int win32_path_cwd(wchar_t *out, size_t len) { int cwd_len; @@ -241,7 +241,7 @@ int git_win32_path_from_utf8(git_win32_path out, const char *src) else { int cwd_len; - if ((cwd_len = git_win32_path__cwd(dest, MAX_PATH)) < 0) + if ((cwd_len = win32_path_cwd(dest, MAX_PATH)) < 0) goto on_error; dest[cwd_len++] = L'\\'; |