Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git: remove unneeded casts #1396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion builtin/credential-store.c
Expand Up @@ -165,7 +165,7 @@ int cmd_credential_store(int argc, const char **argv, const char *prefix)

umask(077);

argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
argc = parse_options(argc, argv, prefix, options, usage, 0);
if (argc != 1)
usage_with_options(usage, options);
op = argv[0];
Expand Down
8 changes: 4 additions & 4 deletions diff.c
Expand Up @@ -1776,8 +1776,8 @@ static void emit_rewrite_diff(const char *name_a,
ecbdata.opt = o;
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
mmfile_t mf1, mf2;
mf1.ptr = (char *)data_one;
mf2.ptr = (char *)data_two;
mf1.ptr = data_one;
mf2.ptr = data_two;
mf1.size = size_one;
mf2.size = size_two;
check_blank_at_eof(&mf1, &mf2, &ecbdata);
Expand Down Expand Up @@ -1809,9 +1809,9 @@ static void emit_rewrite_diff(const char *name_a,
if (lc_b)
emit_rewrite_lines(&ecbdata, '+', data_two, size_two);
if (textconv_one)
free((char *)data_one);
free(data_one);
if (textconv_two)
free((char *)data_two);
free(data_two);
}

struct diff_words_buffer {
Expand Down
4 changes: 2 additions & 2 deletions http.c
Expand Up @@ -2319,8 +2319,8 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
}

do {
ssize_t retval = xwrite(freq->localfile,
(char *) ptr + posn, size - posn);
ssize_t retval =
xwrite(freq->localfile, ptr + posn, size - posn);
if (retval < 0)
return posn / eltsize;
posn += retval;
Expand Down
5 changes: 3 additions & 2 deletions imap-send.c
Expand Up @@ -779,7 +779,7 @@ static int get_cmd_result(struct imap_store *ctx, struct imap_cmd *tcmd)
if (cmdp->cb.data) {
n = socket_write(&imap->buf.sock, cmdp->cb.data, cmdp->cb.dlen);
FREE_AND_NULL(cmdp->cb.data);
if (n != (int)cmdp->cb.dlen)
if (n != cmdp->cb.dlen)
return RESP_BAD;
} else if (cmdp->cb.cont) {
if (cmdp->cb.cont(ctx, cmdp, cmd))
Expand Down Expand Up @@ -1526,7 +1526,8 @@ int cmd_main(int argc, const char **argv)
setup_git_directory_gently(&nongit_ok);
git_config(git_imap_config, NULL);

argc = parse_options(argc, (const char **)argv, "", imap_send_options, imap_send_usage, 0);
argc = parse_options(argc, argv, "", imap_send_options, imap_send_usage,
0);

if (argc)
usage_with_options(imap_send_usage, imap_send_options);
Expand Down
2 changes: 1 addition & 1 deletion merge-ort.c
Expand Up @@ -2574,7 +2574,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,

/* Find parent directories missing from opt->priv->paths */
cur_path = mem_pool_strdup(&opt->priv->pool, new_path);
free((char*)new_path);
free(new_path);
new_path = (char *)cur_path;

while (1) {
Expand Down
2 changes: 1 addition & 1 deletion oidmap.h
Expand Up @@ -87,7 +87,7 @@ static inline void *oidmap_iter_first(struct oidmap *map,
{
oidmap_iter_init(map, iter);
/* TODO: this API could be reworked to do compile-time type checks */
return (void *)oidmap_iter_next(iter);
return oidmap_iter_next(iter);
}

#endif
3 changes: 2 additions & 1 deletion pack-revindex.c
Expand Up @@ -428,7 +428,8 @@ static int midx_pack_order_cmp(const void *va, const void *vb)
const struct midx_pack_key *key = va;
struct multi_pack_index *midx = key->midx;

uint32_t versus = pack_pos_to_midx(midx, (uint32_t*)vb - (const uint32_t *)midx->revindex_data);
uint32_t versus =
pack_pos_to_midx(midx, (uint32_t *)vb - midx->revindex_data);
uint32_t versus_pack = nth_midxed_pack_int_id(midx, versus);
off_t versus_offset;

Expand Down
2 changes: 1 addition & 1 deletion read-cache.c
Expand Up @@ -3022,7 +3022,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,

offset = hashfile_total(f);
}
if (ce_write_entry(f, ce, previous_name, (struct ondisk_cache_entry *)&ondisk) < 0)
if (ce_write_entry(f, ce, previous_name, &ondisk) < 0)
err = -1;

if (err)
Expand Down
2 changes: 1 addition & 1 deletion ref-filter.c
Expand Up @@ -396,7 +396,7 @@ static int trailers_atom_parser(struct ref_format *format, struct used_atom *ato
strbuf_addf(err, _("expected %%(trailers:key=<value>)"));
else
strbuf_addf(err, _("unknown %%(trailers) argument: %s"), invalid_arg);
free((char *)invalid_arg);
free(invalid_arg);
return -1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion strbuf.c
Expand Up @@ -493,7 +493,7 @@ void strbuf_add_percentencode(struct strbuf *dst, const char *src, int flags)
if (ch <= 0x1F || ch >= 0x7F ||
(ch == '/' && (flags & STRBUF_ENCODE_SLASH)) ||
strchr(URL_UNSAFE_CHARS, ch))
strbuf_addf(dst, "%%%02X", (unsigned char)ch);
strbuf_addf(dst, "%%%02X", ch);
else
strbuf_addch(dst, ch);
}
Expand Down
2 changes: 1 addition & 1 deletion t/helper/test-parse-options.c
Expand Up @@ -161,7 +161,7 @@ int cmd__parse_options(int argc, const char **argv)

trace2_cmd_name("_parse_");

argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
argc = parse_options(argc, argv, prefix, options, usage, 0);

if (length_cb.called) {
const char *arg = length_cb.arg;
Expand Down
8 changes: 6 additions & 2 deletions t/helper/test-path-utils.c
Expand Up @@ -276,13 +276,17 @@ static int protect_ntfs_hfs_benchmark(int argc, const char **argv)
for (j = 0; j < nr; j++)
verify_path(names[j], file_mode);
end = getnanotime();
printf("protect_ntfs = %d, protect_hfs = %d: %lfms\n", protect_ntfs, protect_hfs, (end-begin) / (double)1e6);
printf("protect_ntfs = %d, protect_hfs = %d: %lfms\n",
protect_ntfs, protect_hfs,
(end - begin) / 1e6);
cumul += end - begin;
cumul2 += (end - begin) * (end - begin);
}
m[protect_ntfs][protect_hfs] = cumul / (double)repetitions;
v[protect_ntfs][protect_hfs] = my_sqrt(cumul2 / (double)repetitions - m[protect_ntfs][protect_hfs] * m[protect_ntfs][protect_hfs]);
printf("mean: %lfms, stddev: %lfms\n", m[protect_ntfs][protect_hfs] / (double)1e6, v[protect_ntfs][protect_hfs] / (double)1e6);
printf("mean: %lfms, stddev: %lfms\n",
m[protect_ntfs][protect_hfs] / 1e6,
v[protect_ntfs][protect_hfs] / 1e6);
}

for (protect_ntfs = 0; protect_ntfs < 2; protect_ntfs++)
Expand Down
10 changes: 5 additions & 5 deletions t/helper/test-run-command.c
Expand Up @@ -312,8 +312,8 @@ static int quote_stress_test(int argc, const char **argv)
if (ret) {
fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
for (j = 0; j < arg_count; j++)
fprintf(stderr, "arg #%d: '%s'\n",
(int)j, args.v[j + arg_offset]);
fprintf(stderr, "arg #%d: '%s'\n", j,
args.v[j + arg_offset]);

strbuf_release(&out);
strvec_clear(&args);
Expand All @@ -322,7 +322,7 @@ static int quote_stress_test(int argc, const char **argv)
}

if (i && (i % 100) == 0)
fprintf(stderr, "Trials completed: %d\n", (int)i);
fprintf(stderr, "Trials completed: %d\n", i);
}

strbuf_release(&out);
Expand Down Expand Up @@ -418,7 +418,7 @@ int cmd__run_command(int argc, const char **argv)
ret = 1;
goto cleanup;
}
strvec_pushv(&proc.args, (const char **)argv + 2);
strvec_pushv(&proc.args, argv + 2);

if (!strcmp(argv[1], "start-command-ENOENT")) {
if (start_command(&proc) < 0 && errno == ENOENT) {
Expand All @@ -441,7 +441,7 @@ int cmd__run_command(int argc, const char **argv)

jobs = atoi(argv[2]);
strvec_clear(&proc.args);
strvec_pushv(&proc.args, (const char **)argv + 3);
strvec_pushv(&proc.args, argv + 3);

if (!strcmp(argv[1], "run-command-parallel")) {
opts.get_next_task = parallel_next;
Expand Down
2 changes: 1 addition & 1 deletion t/helper/test-subprocess.c
Expand Up @@ -15,6 +15,6 @@ int cmd__subprocess(int argc, const char **argv)
argv++;
}
cp.git_cmd = 1;
strvec_pushv(&cp.args, (const char **)argv + 1);
strvec_pushv(&cp.args, argv + 1);
return run_command(&cp);
}
2 changes: 1 addition & 1 deletion thread-utils.c
Expand Up @@ -57,7 +57,7 @@ int online_cpus(void)
#endif /* defined(HAVE_BSD_SYSCTL) && defined(HW_NCPU) */

#ifdef _SC_NPROCESSORS_ONLN
if ((ncpus = (long)sysconf(_SC_NPROCESSORS_ONLN)) > 0)
if ((ncpus = sysconf(_SC_NPROCESSORS_ONLN)) > 0)
return (int)ncpus;
#endif

Expand Down
2 changes: 1 addition & 1 deletion xdiff/xprepare.c
Expand Up @@ -188,7 +188,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
if (!(crec = xdl_cha_alloc(&xdf->rcha)))
goto abort;
crec->ptr = prev;
crec->size = (long) (cur - prev);
crec->size = (cur - prev);
crec->ha = hav;
recs[nrec++] = crec;
if (xdl_classify_record(pass, cf, rhash, hbits, crec) < 0)
Expand Down
2 changes: 1 addition & 1 deletion xdiff/xutils.c
Expand Up @@ -130,7 +130,7 @@ long xdl_guess_lines(mmfile_t *mf, long sample) {
else
cur++;
}
tsize += (long) (cur - data);
tsize += (cur - data);
}

if (nl && tsize)
Expand Down