Merge branch 'jk/unused-post-2.39' into maint-2.39

Code clean-up around unused function parameters.

* jk/unused-post-2.39:
  userdiff: mark unused parameter in internal callback
  list-objects-filter: mark unused parameters in virtual functions
  diff: mark unused parameters in callbacks
  xdiff: mark unused parameter in xdl_call_hunk_func()
  xdiff: drop unused parameter in def_ff()
  ws: drop unused parameter from ws_blank_line()
  list-objects: drop process_gitlink() function
  blob: drop unused parts of parse_blob_buffer()
  ls-refs: use repository parameter to iterate refs
This commit is contained in:
Junio C Hamano 2023-02-14 14:15:55 -08:00
Родитель 2f80d1b42e c25d9e529d
Коммит 8d404d0d95
30 изменённых файлов: 90 добавлений и 108 удалений

Просмотреть файл

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

Просмотреть файл

@ -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 '\\':

3
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;
}

3
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 */

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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++)

Просмотреть файл

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

Просмотреть файл

@ -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++)

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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 */

Просмотреть файл

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

Просмотреть файл

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

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

Просмотреть файл

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

Просмотреть файл

@ -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) {

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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);
}
/*

9
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);

6
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.
*/

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

2
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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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