diff --git a/add-interactive.c b/add-interactive.c index ae1839c04a..00a0f6f96f 100644 --- a/add-interactive.c +++ b/add-interactive.c @@ -724,7 +724,7 @@ static int run_update(struct add_i_state *s, const struct pathspec *ps, } static void revert_from_diff(struct diff_queue_struct *q, - struct diff_options *opt, void *data) + struct diff_options *opt, void *data UNUSED) { int i, add_flags = ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE; diff --git a/apply.c b/apply.c index eec2da2b03..8c7ae3f714 100644 --- a/apply.c +++ b/apply.c @@ -2913,7 +2913,7 @@ static int apply_one_fragment(struct apply_state *state, break; case ' ': if (plen && (ws_rule & WS_BLANK_AT_EOF) && - ws_blank_line(patch + 1, plen, ws_rule)) + ws_blank_line(patch + 1, plen)) is_blank_context = 1; /* fallthrough */ case '-': @@ -2942,7 +2942,7 @@ static int apply_one_fragment(struct apply_state *state, (first == '+' ? 0 : LINE_COMMON)); if (first == '+' && (ws_rule & WS_BLANK_AT_EOF) && - ws_blank_line(patch + 1, plen, ws_rule)) + ws_blank_line(patch + 1, plen)) added_blank_line = 1; break; case '@': case '\\': diff --git a/blob.c b/blob.c index 182718aba9..8f83523b0c 100644 --- a/blob.c +++ b/blob.c @@ -13,8 +13,7 @@ struct blob *lookup_blob(struct repository *r, const struct object_id *oid) return object_as_type(obj, OBJ_BLOB, 0); } -int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size) +void parse_blob_buffer(struct blob *item) { item->object.parsed = 1; - return 0; } diff --git a/blob.h b/blob.h index 1664872055..74555c90c4 100644 --- a/blob.h +++ b/blob.h @@ -11,8 +11,6 @@ struct blob { struct blob *lookup_blob(struct repository *r, const struct object_id *oid); -int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size); - /** * Blobs do not contain references to other objects and do not have * structured data that needs parsing. However, code may use the @@ -21,5 +19,6 @@ int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size); * parse_blob_buffer() is used (by object.c) to flag that the object * has been read successfully from the database. **/ +void parse_blob_buffer(struct blob *item); #endif /* BLOB_H */ diff --git a/builtin/add.c b/builtin/add.c index 76277df326..190d1a692a 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -88,7 +88,7 @@ static int fix_unmerged_status(struct diff_filepair *p, } static void update_callback(struct diff_queue_struct *q, - struct diff_options *opt, void *cbdata) + struct diff_options *opt UNUSED, void *cbdata) { int i; struct update_callback_data *data = cbdata; diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 3b3314e7b2..39a890fc00 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -409,7 +409,7 @@ static const char *anonymize_oid(const char *oid_hex) } static void show_filemodify(struct diff_queue_struct *q, - struct diff_options *options, void *data) + struct diff_options *options UNUSED, void *data) { int i; struct string_list *changed = data; diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index e3767087bb..ae2c011681 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -98,7 +98,7 @@ static void *origin(struct merge_list *entry, unsigned long *size) return NULL; } -static int show_outf(void *priv_, mmbuffer_t *mb, int nbuf) +static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf) { int i; for (i = 0; i < nbuf; i++) diff --git a/builtin/merge.c b/builtin/merge.c index dd474371a2..17b41fbe38 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -776,7 +776,7 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, } static void count_diff_files(struct diff_queue_struct *q, - struct diff_options *opt, void *data) + struct diff_options *opt UNUSED, void *data) { int *count = data; diff --git a/builtin/rerere.c b/builtin/rerere.c index 8b7392d5b4..94ffb8c21a 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -14,7 +14,7 @@ static const char * const rerere_usage[] = { NULL, }; -static int outf(void *dummy, mmbuffer_t *ptr, int nbuf) +static int outf(void *dummy UNUSED, mmbuffer_t *ptr, int nbuf) { int i; for (i = 0; i < nbuf; i++) diff --git a/builtin/reset.c b/builtin/reset.c index 1fa86edb4c..d2e0185e55 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -133,7 +133,8 @@ static void print_new_head_line(struct commit *commit) } static void update_index_from_diff(struct diff_queue_struct *q, - struct diff_options *opt, void *data) + struct diff_options *opt UNUSED, + void *data) { int i; int intent_to_add = *(int *)data; diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 05f2c9bc98..6743fb27bd 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1043,7 +1043,7 @@ static void prepare_submodule_summary(struct summary_cb *info, } static void submodule_summary_callback(struct diff_queue_struct *q, - struct diff_options *options, + struct diff_options *options UNUSED, void *data) { int i; diff --git a/cache.h b/cache.h index 07d40b0964..fcf49706ad 100644 --- a/cache.h +++ b/cache.h @@ -1865,7 +1865,7 @@ unsigned ws_check(const char *line, int len, unsigned ws_rule); void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws); char *whitespace_error_string(unsigned ws); void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *); -int ws_blank_line(const char *line, int len, unsigned ws_rule); +int ws_blank_line(const char *line, int len); #define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK) /* ls-files */ diff --git a/combine-diff.c b/combine-diff.c index b0ece95480..1a39b5dde0 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -372,7 +372,7 @@ struct combine_diff_state { static void consume_hunk(void *state_, long ob, long on, long nb, long nn, - const char *funcline, long funclen) + const char *func UNUSED, long funclen UNUSED) { struct combine_diff_state *state = state_; diff --git a/diff-lib.c b/diff-lib.c index 2edea41a23..dec040c366 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -673,7 +673,7 @@ int index_differs_from(struct repository *r, return (has_changes != 0); } -static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data) +static struct strbuf *idiff_prefix_cb(struct diff_options *opt UNUSED, void *data) { return data; } diff --git a/diff.c b/diff.c index 3117fce39b..6a5ed216de 100644 --- a/diff.c +++ b/diff.c @@ -604,7 +604,7 @@ static unsigned long diff_filespec_size(struct repository *r, return one->size; } -static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule) +static int count_trailing_blank(mmfile_t *mf) { char *ptr = mf->ptr; long size = mf->size; @@ -622,7 +622,7 @@ static int count_trailing_blank(mmfile_t *mf, unsigned ws_rule) for (prev_eol = ptr; mf->ptr <= prev_eol; prev_eol--) if (*prev_eol == '\n') break; - if (!ws_blank_line(prev_eol + 1, ptr - prev_eol, ws_rule)) + if (!ws_blank_line(prev_eol + 1, ptr - prev_eol)) break; cnt++; ptr = prev_eol - 1; @@ -634,9 +634,8 @@ static void check_blank_at_eof(mmfile_t *mf1, mmfile_t *mf2, struct emit_callback *ecbdata) { int l1, l2, at; - unsigned ws_rule = ecbdata->ws_rule; - l1 = count_trailing_blank(mf1, ws_rule); - l2 = count_trailing_blank(mf2, ws_rule); + l1 = count_trailing_blank(mf1); + l2 = count_trailing_blank(mf2); if (l2 <= l1) { ecbdata->blank_at_eof_in_preimage = 0; ecbdata->blank_at_eof_in_postimage = 0; @@ -1583,7 +1582,7 @@ static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line ecbdata->blank_at_eof_in_preimage <= ecbdata->lno_in_preimage && ecbdata->blank_at_eof_in_postimage <= ecbdata->lno_in_postimage)) return 0; - return ws_blank_line(line, len, ecbdata->ws_rule); + return ws_blank_line(line, len); } static void emit_add_line(struct emit_callback *ecbdata, @@ -1955,7 +1954,7 @@ static int color_words_output_graph_prefix(struct diff_words_data *diff_words) static void fn_out_diff_words_aux(void *priv, long minus_first, long minus_len, long plus_first, long plus_len, - const char *func, long funclen) + const char *func UNUSED, long funclen UNUSED) { struct diff_words_data *diff_words = priv; struct diff_words_style *style = diff_words->style; @@ -3185,8 +3184,9 @@ static int is_conflict_marker(const char *line, int marker_size, unsigned long l } static void checkdiff_consume_hunk(void *priv, - long ob, long on, long nb, long nn, - const char *func, long funclen) + long ob UNUSED, long on UNUSED, + long nb, long nn UNUSED, + const char *func UNUSED, long funclen UNUSED) { struct checkdiff_t *data = priv; diff --git a/list-objects-filter.c b/list-objects-filter.c index dfc3f49f4f..7ed21cb299 100644 --- a/list-objects-filter.c +++ b/list-objects-filter.c @@ -70,13 +70,13 @@ struct filter { }; static enum list_objects_filter_result filter_blobs_none( - struct repository *r, + struct repository *r UNUSED, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, + const char *pathname UNUSED, + const char *filename UNUSED, struct oidset *omits, - void *filter_data_) + void *filter_data_ UNUSED) { switch (filter_situation) { default: @@ -112,7 +112,7 @@ static enum list_objects_filter_result filter_blobs_none( } static void filter_blobs_none__init( - struct list_objects_filter_options *filter_options, + struct list_objects_filter_options *filter_options UNUSED, struct filter *filter) { filter->filter_object_fn = filter_blobs_none; @@ -159,11 +159,11 @@ static int filter_trees_update_omits( } static enum list_objects_filter_result filter_trees_depth( - struct repository *r, + struct repository *r UNUSED, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, + const char *pathname UNUSED, + const char *filename UNUSED, struct oidset *omits, void *filter_data_) { @@ -274,8 +274,8 @@ static enum list_objects_filter_result filter_blobs_limit( struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, + const char *pathname UNUSED, + const char *filename UNUSED, struct oidset *omits, void *filter_data_) { @@ -555,12 +555,12 @@ struct filter_object_type_data { }; static enum list_objects_filter_result filter_object_type( - struct repository *r, + struct repository *r UNUSED, enum list_objects_filter_situation filter_situation, struct object *obj, - const char *pathname, - const char *filename, - struct oidset *omits, + const char *pathname UNUSED, + const char *filename UNUSED, + struct oidset *omits UNUSED, void *filter_data_) { struct filter_object_type_data *filter_data = filter_data_; @@ -676,7 +676,7 @@ static enum list_objects_filter_result filter_combine( struct object *obj, const char *pathname, const char *filename, - struct oidset *omits, + struct oidset *omits UNUSED, void *filter_data) { struct combine_filter_data *d = filter_data; diff --git a/list-objects.c b/list-objects.c index 250d9de41c..7528fe1db2 100644 --- a/list-objects.c +++ b/list-objects.c @@ -81,36 +81,6 @@ static void process_blob(struct traversal_context *ctx, strbuf_setlen(path, pathlen); } -/* - * Processing a gitlink entry currently does nothing, since - * we do not recurse into the subproject. - * - * We *could* eventually add a flag that actually does that, - * which would involve: - * - is the subproject actually checked out? - * - if so, see if the subproject has already been added - * to the alternates list, and add it if not. - * - process the commit (or tag) the gitlink points to - * recursively. - * - * However, it's unclear whether there is really ever any - * reason to see superprojects and subprojects as such a - * "unified" object pool (potentially resulting in a totally - * humongous pack - avoiding which was the whole point of - * having gitlinks in the first place!). - * - * So for now, there is just a note that we *could* follow - * the link, and how to do it. Whether it necessarily makes - * any sense what-so-ever to ever do that is another issue. - */ -static void process_gitlink(struct traversal_context *ctx, - const unsigned char *sha1, - struct strbuf *path, - const char *name) -{ - /* Nothing to do */ -} - static void process_tree(struct traversal_context *ctx, struct tree *tree, struct strbuf *base, @@ -149,8 +119,7 @@ static void process_tree_contents(struct traversal_context *ctx, process_tree(ctx, t, base, entry.path); } else if (S_ISGITLINK(entry.mode)) - process_gitlink(ctx, entry.oid.hash, - base, entry.path); + ; /* ignore gitlink */ else { struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid); if (!b) { diff --git a/ls-refs.c b/ls-refs.c index fb6769742c..697d4beb8d 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -194,8 +194,9 @@ int ls_refs(struct repository *r, struct packet_reader *request) send_possibly_unborn_head(&data); if (!data.prefixes.nr) strvec_push(&data.prefixes, ""); - for_each_fullref_in_prefixes(get_git_namespace(), data.prefixes.v, - send_ref, &data); + refs_for_each_fullref_in_prefixes(get_main_ref_store(r), + get_git_namespace(), data.prefixes.v, + send_ref, &data); packet_fflush(stdout); strvec_clear(&data.prefixes); strbuf_release(&data.buf); diff --git a/object.c b/object.c index 682b852a46..344087de4d 100644 --- a/object.c +++ b/object.c @@ -212,8 +212,7 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id if (type == OBJ_BLOB) { struct blob *blob = lookup_blob(r, oid); if (blob) { - if (parse_blob_buffer(blob, buffer, size)) - return NULL; + parse_blob_buffer(blob); obj = &blob->object; } } else if (type == OBJ_TREE) { @@ -292,7 +291,7 @@ struct object *parse_object_with_flags(struct repository *r, error(_("hash mismatch %s"), oid_to_hex(oid)); return NULL; } - parse_blob_buffer(lookup_blob(r, oid), NULL, 0); + parse_blob_buffer(lookup_blob(r, oid)); return lookup_object(r, oid); } diff --git a/range-diff.c b/range-diff.c index 8b7d81adc1..8255ab4349 100644 --- a/range-diff.c +++ b/range-diff.c @@ -269,14 +269,18 @@ static void find_exact_matches(struct string_list *a, struct string_list *b) hashmap_clear(&map); } -static int diffsize_consume(void *data, char *line, unsigned long len) +static int diffsize_consume(void *data, + char *line UNUSED, + unsigned long len UNUSED) { (*(int *)data)++; return 0; } -static void diffsize_hunk(void *data, long ob, long on, long nb, long nn, - const char *funcline, long funclen) +static void diffsize_hunk(void *data, + long ob UNUSED, long on UNUSED, + long nb UNUSED, long nn UNUSED, + const char *func UNUSED, long funclen UNUSED) { diffsize_consume(data, NULL, 0); } @@ -461,7 +465,7 @@ static void patch_diff(const char *a, const char *b, diff_flush(diffopt); } -static struct strbuf *output_prefix_cb(struct diff_options *opt, void *data) +static struct strbuf *output_prefix_cb(struct diff_options *opt UNUSED, void *data) { return data; } diff --git a/ref-filter.c b/ref-filter.c index 9dc2cd1451..971303683b 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2128,8 +2128,9 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, return for_each_fullref_in("", cb, cb_data); } - return for_each_fullref_in_prefixes(NULL, filter->name_patterns, - cb, cb_data); + return refs_for_each_fullref_in_prefixes(get_main_ref_store(the_repository), + NULL, filter->name_patterns, + cb, cb_data); } /* diff --git a/refs.c b/refs.c index 2c7e88b190..e31dbcda59 100644 --- a/refs.c +++ b/refs.c @@ -1723,9 +1723,10 @@ static void find_longest_prefixes(struct string_list *out, strbuf_release(&prefix); } -int for_each_fullref_in_prefixes(const char *namespace, - const char **patterns, - each_ref_fn fn, void *cb_data) +int refs_for_each_fullref_in_prefixes(struct ref_store *ref_store, + const char *namespace, + const char **patterns, + each_ref_fn fn, void *cb_data) { struct string_list prefixes = STRING_LIST_INIT_DUP; struct string_list_item *prefix; @@ -1740,7 +1741,7 @@ int for_each_fullref_in_prefixes(const char *namespace, for_each_string_list_item(prefix, &prefixes) { strbuf_addstr(&buf, prefix->string); - ret = for_each_fullref_in(buf.buf, fn, cb_data); + ret = refs_for_each_fullref_in(ref_store, buf.buf, fn, cb_data); if (ret) break; strbuf_setlen(&buf, namespace_len); diff --git a/refs.h b/refs.h index 3266fd8f57..935cdd1ece 100644 --- a/refs.h +++ b/refs.h @@ -354,8 +354,10 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data); * * callers should be prepared to ignore references that they did not ask for. */ -int for_each_fullref_in_prefixes(const char *namespace, const char **patterns, - each_ref_fn fn, void *cb_data); +int refs_for_each_fullref_in_prefixes(struct ref_store *refs, + const char *namespace, const char **patterns, + each_ref_fn fn, void *cb_data); + /** * iterate refs from the respective area. */ diff --git a/revision.c b/revision.c index 439e34a7c5..ec441b80ef 100644 --- a/revision.c +++ b/revision.c @@ -600,10 +600,12 @@ static struct commit *one_relevant_parent(const struct rev_info *revs, static int tree_difference = REV_TREE_SAME; static void file_add_remove(struct diff_options *options, - int addremove, unsigned mode, - const struct object_id *oid, - int oid_valid, - const char *fullpath, unsigned dirty_submodule) + int addremove, + unsigned mode UNUSED, + const struct object_id *oid UNUSED, + int oid_valid UNUSED, + const char *fullpath UNUSED, + unsigned dirty_submodule UNUSED) { int diff = addremove == '+' ? REV_TREE_NEW : REV_TREE_OLD; struct rev_info *revs = options->change_fn_data; @@ -614,12 +616,15 @@ static void file_add_remove(struct diff_options *options, } static void file_change(struct diff_options *options, - unsigned old_mode, unsigned new_mode, - const struct object_id *old_oid, - const struct object_id *new_oid, - int old_oid_valid, int new_oid_valid, - const char *fullpath, - unsigned old_dirty_submodule, unsigned new_dirty_submodule) + unsigned old_mode UNUSED, + unsigned new_mode UNUSED, + const struct object_id *old_oid UNUSED, + const struct object_id *new_oid UNUSED, + int old_oid_valid UNUSED, + int new_oid_valid UNUSED, + const char *fullpath UNUSED, + unsigned old_dirty_submodule UNUSED, + unsigned new_dirty_submodule UNUSED) { tree_difference = REV_TREE_DIFFERENT; options->flags.has_changes = 1; diff --git a/submodule.c b/submodule.c index 8ac2fca855..fae24ef34a 100644 --- a/submodule.c +++ b/submodule.c @@ -832,7 +832,7 @@ static void changed_submodule_data_clear(struct changed_submodule_data *cs_data) } static void collect_changed_submodules_cb(struct diff_queue_struct *q, - struct diff_options *options, + struct diff_options *options UNUSED, void *data) { struct collect_changed_submodules_cb_data *me = data; diff --git a/userdiff.c b/userdiff.c index 151d9a5278..e25356a061 100644 --- a/userdiff.c +++ b/userdiff.c @@ -315,7 +315,8 @@ struct find_by_namelen_data { }; static int userdiff_find_by_namelen_cb(struct userdiff_driver *driver, - enum userdiff_driver_type type, void *priv) + enum userdiff_driver_type type UNUSED, + void *priv) { struct find_by_namelen_data *cb_data = priv; diff --git a/ws.c b/ws.c index 6e69877f25..46a77bcad6 100644 --- a/ws.c +++ b/ws.c @@ -252,7 +252,7 @@ unsigned ws_check(const char *line, int len, unsigned ws_rule) return ws_check_emit_1(line, len, ws_rule, NULL, NULL, NULL, NULL); } -int ws_blank_line(const char *line, int len, unsigned ws_rule) +int ws_blank_line(const char *line, int len) { /* * We _might_ want to treat CR differently from other diff --git a/wt-status.c b/wt-status.c index 5813174896..76e37a8088 100644 --- a/wt-status.c +++ b/wt-status.c @@ -438,7 +438,7 @@ static char short_submodule_status(struct wt_status_change_data *d) } static void wt_status_collect_changed_cb(struct diff_queue_struct *q, - struct diff_options *options, + struct diff_options *options UNUSED, void *data) { struct wt_status *s = data; @@ -525,7 +525,7 @@ static int unmerged_mask(struct index_state *istate, const char *path) } static void wt_status_collect_updated_cb(struct diff_queue_struct *q, - struct diff_options *options, + struct diff_options *options UNUSED, void *data) { struct wt_status *s = data; diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c index 32652ded2d..344c2dfc3e 100644 --- a/xdiff/xdiffi.c +++ b/xdiff/xdiffi.c @@ -973,7 +973,7 @@ void xdl_free_script(xdchange_t *xscr) { } } -static int xdl_call_hunk_func(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb, +static int xdl_call_hunk_func(xdfenv_t *xe UNUSED, xdchange_t *xscr, xdemitcb_t *ecb, xdemitconf_t const *xecfg) { xdchange_t *xch, *xche; diff --git a/xdiff/xemit.c b/xdiff/xemit.c index c4ccd68d47..75f0fe4986 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -95,7 +95,7 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg) } -static long def_ff(const char *rec, long len, char *buf, long sz, void *priv) +static long def_ff(const char *rec, long len, char *buf, long sz) { if (len > 0 && (isalpha((unsigned char)*rec) || /* identifier? */ @@ -117,7 +117,7 @@ static long match_func_rec(xdfile_t *xdf, xdemitconf_t const *xecfg, long ri, const char *rec; long len = xdl_get_rec(xdf, ri, &rec); if (!xecfg->find_func) - return def_ff(rec, len, buf, sz, xecfg->find_func_priv); + return def_ff(rec, len, buf, sz); return xecfg->find_func(rec, len, buf, sz, xecfg->find_func_priv); }