Merge branch 'jk/unused-parameter-cleanup'

Code cleanup.

* jk/unused-parameter-cleanup:
  convert: drop path parameter from actual conversion functions
  convert: drop len parameter from conversion checks
  config: drop unused parameter from maybe_remove_section()
  show_date_relative(): drop unused "tz" parameter
  column: drop unused "opts" parameter in item_length()
  create_bundle(): drop unused "header" parameter
  apply: drop unused "def" parameter from find_name_gnu()
  match-trees: drop unused path parameter from score functions
This commit is contained in:
Junio C Hamano
2019-02-06 22:05:23 -08:00
11 changed files with 37 additions and 42 deletions

View File

@ -467,7 +467,6 @@ static char *squash_slash(char *name)
static char *find_name_gnu(struct apply_state *state, static char *find_name_gnu(struct apply_state *state,
const char *line, const char *line,
const char *def,
int p_value) int p_value)
{ {
struct strbuf name = STRBUF_INIT; struct strbuf name = STRBUF_INIT;
@ -714,7 +713,7 @@ static char *find_name(struct apply_state *state,
int terminate) int terminate)
{ {
if (*line == '"') { if (*line == '"') {
char *name = find_name_gnu(state, line, def, p_value); char *name = find_name_gnu(state, line, p_value);
if (name) if (name)
return name; return name;
} }
@ -731,7 +730,7 @@ static char *find_name_traditional(struct apply_state *state,
size_t date_len; size_t date_len;
if (*line == '"') { if (*line == '"') {
char *name = find_name_gnu(state, line, def, p_value); char *name = find_name_gnu(state, line, p_value);
if (name) if (name)
return name; return name;
} }

View File

@ -56,8 +56,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
} }
if (!startup_info->have_repository) if (!startup_info->have_repository)
die(_("Need a repository to create a bundle.")); die(_("Need a repository to create a bundle."));
return !!create_bundle(the_repository, &header, return !!create_bundle(the_repository, bundle_file, argc, argv);
bundle_file, argc, argv);
} else if (!strcmp(cmd, "unbundle")) { } else if (!strcmp(cmd, "unbundle")) {
if (!startup_info->have_repository) if (!startup_info->have_repository)
die(_("Need a repository to unbundle.")); die(_("Need a repository to unbundle."));

View File

@ -424,8 +424,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
return ref_count; return ref_count;
} }
int create_bundle(struct repository *r, struct bundle_header *header, int create_bundle(struct repository *r, const char *path,
const char *path, int argc, const char **argv) int argc, const char **argv)
{ {
struct lock_file lock = LOCK_INIT; struct lock_file lock = LOCK_INIT;
int bundle_fd = -1; int bundle_fd = -1;

View File

@ -18,8 +18,8 @@ struct bundle_header {
int is_bundle(const char *path, int quiet); int is_bundle(const char *path, int quiet);
int read_bundle_header(const char *path, struct bundle_header *header); int read_bundle_header(const char *path, struct bundle_header *header);
int create_bundle(struct repository *r, struct bundle_header *header, int create_bundle(struct repository *r, const char *path,
const char *path, int argc, const char **argv); int argc, const char **argv);
int verify_bundle(struct repository *r, struct bundle_header *header, int verbose); int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
#define BUNDLE_VERBOSE 1 #define BUNDLE_VERBOSE 1
int unbundle(struct repository *r, struct bundle_header *header, int unbundle(struct repository *r, struct bundle_header *header,

View File

@ -1488,7 +1488,7 @@ struct date_mode {
struct date_mode *date_mode_from_type(enum date_mode_type type); struct date_mode *date_mode_from_type(enum date_mode_type type);
const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode); const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode);
void show_date_relative(timestamp_t time, int tz, const struct timeval *now, void show_date_relative(timestamp_t time, const struct timeval *now,
struct strbuf *timebuf); struct strbuf *timebuf);
int parse_date(const char *date, struct strbuf *out); int parse_date(const char *date, struct strbuf *out);
int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset); int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset);

View File

@ -21,7 +21,7 @@ struct column_data {
}; };
/* return length of 's' in letters, ANSI escapes stripped */ /* return length of 's' in letters, ANSI escapes stripped */
static int item_length(unsigned int colopts, const char *s) static int item_length(const char *s)
{ {
int len, i = 0; int len, i = 0;
struct strbuf str = STRBUF_INIT; struct strbuf str = STRBUF_INIT;
@ -167,7 +167,7 @@ static void display_table(const struct string_list *list,
ALLOC_ARRAY(data.len, list->nr); ALLOC_ARRAY(data.len, list->nr);
for (i = 0; i < list->nr; i++) for (i = 0; i < list->nr; i++)
data.len[i] = item_length(colopts, list->items[i].string); data.len[i] = item_length(list->items[i].string);
layout(&data, &initial_width); layout(&data, &initial_width);

View File

@ -2565,7 +2565,6 @@ static ssize_t write_pair(int fd, const char *key, const char *value,
* entry (which all are to be removed). * entry (which all are to be removed).
*/ */
static void maybe_remove_section(struct config_store_data *store, static void maybe_remove_section(struct config_store_data *store,
const char *contents,
size_t *begin_offset, size_t *end_offset, size_t *begin_offset, size_t *end_offset,
int *seen_ptr) int *seen_ptr)
{ {
@ -2850,7 +2849,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
replace_end = store.parsed[j].end; replace_end = store.parsed[j].end;
copy_end = store.parsed[j].begin; copy_end = store.parsed[j].begin;
if (!value) if (!value)
maybe_remove_section(&store, contents, maybe_remove_section(&store,
&copy_end, &copy_end,
&replace_end, &i); &replace_end, &i);
/* /*

View File

@ -91,7 +91,7 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat *
* The same heuristics as diff.c::mmfile_is_binary() * The same heuristics as diff.c::mmfile_is_binary()
* We treat files with bare CR as binary * We treat files with bare CR as binary
*/ */
static int convert_is_binary(unsigned long size, const struct text_stat *stats) static int convert_is_binary(const struct text_stat *stats)
{ {
if (stats->lonecr) if (stats->lonecr)
return 1; return 1;
@ -109,7 +109,7 @@ static unsigned int gather_convert_stats(const char *data, unsigned long size)
if (!data || !size) if (!data || !size)
return 0; return 0;
gather_stats(data, size, &stats); gather_stats(data, size, &stats);
if (convert_is_binary(size, &stats)) if (convert_is_binary(&stats))
ret |= CONVERT_STAT_BITS_BIN; ret |= CONVERT_STAT_BITS_BIN;
if (stats.crlf) if (stats.crlf)
ret |= CONVERT_STAT_BITS_TXT_CRLF; ret |= CONVERT_STAT_BITS_TXT_CRLF;
@ -244,7 +244,7 @@ static int has_crlf_in_index(const struct index_state *istate, const char *path)
return has_crlf; return has_crlf;
} }
static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats, static int will_convert_lf_to_crlf(struct text_stat *stats,
enum crlf_action crlf_action) enum crlf_action crlf_action)
{ {
if (output_eol(crlf_action) != EOL_CRLF) if (output_eol(crlf_action) != EOL_CRLF)
@ -259,7 +259,7 @@ static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
if (stats->lonecr || stats->crlf) if (stats->lonecr || stats->crlf)
return 0; return 0;
if (convert_is_binary(len, stats)) if (convert_is_binary(stats))
return 0; return 0;
} }
return 1; return 1;
@ -526,7 +526,7 @@ static int crlf_to_git(const struct index_state *istate,
convert_crlf_into_lf = !!stats.crlf; convert_crlf_into_lf = !!stats.crlf;
if (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) { if (crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_INPUT || crlf_action == CRLF_AUTO_CRLF) {
if (convert_is_binary(len, &stats)) if (convert_is_binary(&stats))
return 0; return 0;
/* /*
* If the file in the index has any CR in it, do not * If the file in the index has any CR in it, do not
@ -548,7 +548,7 @@ static int crlf_to_git(const struct index_state *istate,
new_stats.crlf = 0; new_stats.crlf = 0;
} }
/* simulate "git checkout" */ /* simulate "git checkout" */
if (will_convert_lf_to_crlf(len, &new_stats, crlf_action)) { if (will_convert_lf_to_crlf(&new_stats, crlf_action)) {
new_stats.crlf += new_stats.lonelf; new_stats.crlf += new_stats.lonelf;
new_stats.lonelf = 0; new_stats.lonelf = 0;
} }
@ -590,7 +590,7 @@ static int crlf_to_git(const struct index_state *istate,
return 1; return 1;
} }
static int crlf_to_worktree(const char *path, const char *src, size_t len, static int crlf_to_worktree(const char *src, size_t len,
struct strbuf *buf, enum crlf_action crlf_action) struct strbuf *buf, enum crlf_action crlf_action)
{ {
char *to_free = NULL; char *to_free = NULL;
@ -600,7 +600,7 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
return 0; return 0;
gather_stats(src, len, &stats); gather_stats(src, len, &stats);
if (!will_convert_lf_to_crlf(len, &stats, crlf_action)) if (!will_convert_lf_to_crlf(&stats, crlf_action))
return 0; return 0;
/* are we "faking" in place editing ? */ /* are we "faking" in place editing ? */
@ -1090,7 +1090,7 @@ static int count_ident(const char *cp, unsigned long size)
return cnt; return cnt;
} }
static int ident_to_git(const char *path, const char *src, size_t len, static int ident_to_git(const char *src, size_t len,
struct strbuf *buf, int ident) struct strbuf *buf, int ident)
{ {
char *dst, *dollar; char *dst, *dollar;
@ -1134,7 +1134,7 @@ static int ident_to_git(const char *path, const char *src, size_t len,
return 1; return 1;
} }
static int ident_to_worktree(const char *path, const char *src, size_t len, static int ident_to_worktree(const char *src, size_t len,
struct strbuf *buf, int ident) struct strbuf *buf, int ident)
{ {
struct object_id oid; struct object_id oid;
@ -1415,7 +1415,7 @@ int convert_to_git(const struct index_state *istate,
len = dst->len; len = dst->len;
} }
} }
return ret | ident_to_git(path, src, len, dst, ca.ident); return ret | ident_to_git(src, len, dst, ca.ident);
} }
void convert_to_git_filter_fd(const struct index_state *istate, void convert_to_git_filter_fd(const struct index_state *istate,
@ -1433,7 +1433,7 @@ void convert_to_git_filter_fd(const struct index_state *istate,
encode_to_git(path, dst->buf, dst->len, dst, ca.working_tree_encoding, conv_flags); encode_to_git(path, dst->buf, dst->len, dst, ca.working_tree_encoding, conv_flags);
crlf_to_git(istate, path, dst->buf, dst->len, dst, ca.crlf_action, conv_flags); crlf_to_git(istate, path, dst->buf, dst->len, dst, ca.crlf_action, conv_flags);
ident_to_git(path, dst->buf, dst->len, dst, ca.ident); ident_to_git(dst->buf, dst->len, dst, ca.ident);
} }
static int convert_to_working_tree_internal(const struct index_state *istate, static int convert_to_working_tree_internal(const struct index_state *istate,
@ -1446,7 +1446,7 @@ static int convert_to_working_tree_internal(const struct index_state *istate,
convert_attrs(istate, &ca, path); convert_attrs(istate, &ca, path);
ret |= ident_to_worktree(path, src, len, dst, ca.ident); ret |= ident_to_worktree(src, len, dst, ca.ident);
if (ret) { if (ret) {
src = dst->buf; src = dst->buf;
len = dst->len; len = dst->len;
@ -1457,7 +1457,7 @@ static int convert_to_working_tree_internal(const struct index_state *istate,
* support smudge). The filters might expect CRLFs. * support smudge). The filters might expect CRLFs.
*/ */
if ((ca.drv && (ca.drv->smudge || ca.drv->process)) || !normalizing) { if ((ca.drv && (ca.drv->smudge || ca.drv->process)) || !normalizing) {
ret |= crlf_to_worktree(path, src, len, dst, ca.crlf_action); ret |= crlf_to_worktree(src, len, dst, ca.crlf_action);
if (ret) { if (ret) {
src = dst->buf; src = dst->buf;
len = dst->len; len = dst->len;

8
date.c
View File

@ -107,9 +107,9 @@ static int local_tzoffset(timestamp_t time)
return offset * eastwest; return offset * eastwest;
} }
void show_date_relative(timestamp_t time, int tz, void show_date_relative(timestamp_t time,
const struct timeval *now, const struct timeval *now,
struct strbuf *timebuf) struct strbuf *timebuf)
{ {
timestamp_t diff; timestamp_t diff;
if (now->tv_sec < time) { if (now->tv_sec < time) {
@ -216,7 +216,7 @@ const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
strbuf_reset(&timebuf); strbuf_reset(&timebuf);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
show_date_relative(time, tz, &now, &timebuf); show_date_relative(time, &now, &timebuf);
return timebuf.buf; return timebuf.buf;
} }

View File

@ -3,7 +3,7 @@
#include "tree-walk.h" #include "tree-walk.h"
#include "object-store.h" #include "object-store.h"
static int score_missing(unsigned mode, const char *path) static int score_missing(unsigned mode)
{ {
int score; int score;
@ -16,7 +16,7 @@ static int score_missing(unsigned mode, const char *path)
return score; return score;
} }
static int score_differs(unsigned mode1, unsigned mode2, const char *path) static int score_differs(unsigned mode1, unsigned mode2)
{ {
int score; int score;
@ -29,7 +29,7 @@ static int score_differs(unsigned mode1, unsigned mode2, const char *path)
return score; return score;
} }
static int score_matches(unsigned mode1, unsigned mode2, const char *path) static int score_matches(unsigned mode1, unsigned mode2)
{ {
int score; int score;
@ -98,24 +98,22 @@ static int score_trees(const struct object_id *hash1, const struct object_id *ha
if (cmp < 0) { if (cmp < 0) {
/* path1 does not appear in two */ /* path1 does not appear in two */
score += score_missing(one.entry.mode, one.entry.path); score += score_missing(one.entry.mode);
update_tree_entry(&one); update_tree_entry(&one);
} else if (cmp > 0) { } else if (cmp > 0) {
/* path2 does not appear in one */ /* path2 does not appear in one */
score += score_missing(two.entry.mode, two.entry.path); score += score_missing(two.entry.mode);
update_tree_entry(&two); update_tree_entry(&two);
} else { } else {
/* path appears in both */ /* path appears in both */
if (!oideq(&one.entry.oid, &two.entry.oid)) { if (!oideq(&one.entry.oid, &two.entry.oid)) {
/* they are different */ /* they are different */
score += score_differs(one.entry.mode, score += score_differs(one.entry.mode,
two.entry.mode, two.entry.mode);
one.entry.path);
} else { } else {
/* same subtree or blob */ /* same subtree or blob */
score += score_matches(one.entry.mode, score += score_matches(one.entry.mode,
two.entry.mode, two.entry.mode);
one.entry.path);
} }
update_tree_entry(&one); update_tree_entry(&one);
update_tree_entry(&two); update_tree_entry(&two);

View File

@ -16,7 +16,7 @@ static void show_relative_dates(const char **argv, struct timeval *now)
for (; *argv; argv++) { for (; *argv; argv++) {
time_t t = atoi(*argv); time_t t = atoi(*argv);
show_date_relative(t, 0, now, &buf); show_date_relative(t, now, &buf);
printf("%s -> %s\n", *argv, buf.buf); printf("%s -> %s\n", *argv, buf.buf);
} }
strbuf_release(&buf); strbuf_release(&buf);