From: "Rose via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Rose <83477269+AtariDreams@users.noreply.github.com>,
Seija Kijin <doremylover123@gmail.com>
Subject: [PATCH] git: remove unneeded casts
Date: Wed, 14 Dec 2022 15:35:26 +0000 [thread overview]
Message-ID: <pull.1396.git.git.1671032126602.gitgitgadget@gmail.com> (raw)
From: Seija Kijin <doremylover123@gmail.com>
Many of these casts remain,
even though the target variable is the type it is being casted to.
We can safely remove said casts.
Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
git: remove unneeded casts
Many of these casts remain, even though the target variable is the type
it is being casted to. We can safely remove said casts.
Signed-off-by: Seija Kijin doremylover123@gmail.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1396%2FAtariDreams%2Ffix-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1396/AtariDreams/fix-v1
Pull-Request: https://github.com/git/git/pull/1396
builtin/credential-store.c | 2 +-
diff.c | 8 ++++----
http.c | 4 ++--
imap-send.c | 5 +++--
merge-ort.c | 2 +-
oidmap.h | 2 +-
pack-revindex.c | 3 ++-
read-cache.c | 2 +-
ref-filter.c | 2 +-
strbuf.c | 2 +-
t/helper/test-parse-options.c | 2 +-
t/helper/test-path-utils.c | 8 ++++++--
t/helper/test-run-command.c | 10 +++++-----
t/helper/test-subprocess.c | 2 +-
thread-utils.c | 2 +-
xdiff/xprepare.c | 2 +-
xdiff/xutils.c | 2 +-
17 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index 62a4f3c2653..93e521af395 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -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];
diff --git a/diff.c b/diff.c
index 1054a4b7329..2e58c9372b4 100644
--- a/diff.c
+++ b/diff.c
@@ -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);
@@ -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 {
diff --git a/http.c b/http.c
index 8a5ba3f4776..32db5d76a7c 100644
--- a/http.c
+++ b/http.c
@@ -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;
diff --git a/imap-send.c b/imap-send.c
index a50af56b827..e67dbfc5567 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -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))
@@ -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);
diff --git a/merge-ort.c b/merge-ort.c
index d1611ca400a..a2aefd609ad 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -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) {
diff --git a/oidmap.h b/oidmap.h
index c66a83ab1d6..9cefbba550d 100644
--- a/oidmap.h
+++ b/oidmap.h
@@ -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
diff --git a/pack-revindex.c b/pack-revindex.c
index 08dc1601679..fa897b54584 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -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;
diff --git a/read-cache.c b/read-cache.c
index 1ff518b2a7f..f4c4cc63dc4 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -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)
diff --git a/ref-filter.c b/ref-filter.c
index caf10ab23eb..e5993f7cc43 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -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;
}
}
diff --git a/strbuf.c b/strbuf.c
index 0890b1405c5..940f59473eb 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -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);
}
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 506835521a4..a788196adf5 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -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;
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index f69709d674f..eb7a204f3b7 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -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++)
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 3ecb830f4a8..eadde7c47b1 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -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);
@@ -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);
@@ -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) {
@@ -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;
diff --git a/t/helper/test-subprocess.c b/t/helper/test-subprocess.c
index ff22f2fa2c5..32a5b339eae 100644
--- a/t/helper/test-subprocess.c
+++ b/t/helper/test-subprocess.c
@@ -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);
}
diff --git a/thread-utils.c b/thread-utils.c
index 53298456913..6d3de821473 100644
--- a/thread-utils.c
+++ b/thread-utils.c
@@ -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
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
index c84549f6c50..04fa4e5a01d 100644
--- a/xdiff/xprepare.c
+++ b/xdiff/xprepare.c
@@ -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)
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index 9e36f24875d..853f2260a1d 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c
@@ -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)
base-commit: 57e2c6ebbe7108b35ba30184dcbcb6c34c929ad8
--
gitgitgadget
next reply other threads:[~2022-12-14 15:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 15:35 Rose via GitGitGadget [this message]
2022-12-14 21:16 ` [PATCH] git: remove unneeded casts Jeff King
2022-12-14 23:49 ` Junio C Hamano
2022-12-17 13:32 ` Jeff King
2022-12-19 1:07 ` Junio C Hamano
2022-12-15 10:07 ` Ævar Arnfjörð Bjarmason
2022-12-17 13:55 ` Jeff King
2022-12-15 10:18 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1396.git.git.1671032126602.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=83477269+AtariDreams@users.noreply.github.com \
--cc=doremylover123@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).