From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 2/7] oid_array: use size_t for iteration
Date: Mon, 30 Mar 2020 10:03:20 -0400 [thread overview]
Message-ID: <20200330140320.GB2456038@coredump.intra.peff.net> (raw)
In-Reply-To: <20200330140247.GA476088@coredump.intra.peff.net>
The previous commit started using size_t for our allocations. There are
some iterations that use int or unsigned, though. These aren't dangerous
with respect to memory, but they could produce incorrect results.
Signed-off-by: Jeff King <peff@peff.net>
---
sha1-array.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sha1-array.c b/sha1-array.c
index 3eeadfede9..bada0c4353 100644
--- a/sha1-array.c
+++ b/sha1-array.c
@@ -46,7 +46,7 @@ int oid_array_for_each(struct oid_array *array,
for_each_oid_fn fn,
void *data)
{
- int i;
+ size_t i;
/* No oid_array_sort() here! See sha1-array.h */
@@ -62,7 +62,7 @@ int oid_array_for_each_unique(struct oid_array *array,
for_each_oid_fn fn,
void *data)
{
- int i;
+ size_t i;
if (!array->sorted)
oid_array_sort(array);
@@ -82,7 +82,7 @@ void oid_array_filter(struct oid_array *array,
for_each_oid_fn want,
void *cb_data)
{
- unsigned nr = array->nr, src, dst;
+ size_t nr = array->nr, src, dst;
struct object_id *oids = array->oid;
for (src = dst = 0; src < nr; src++) {
--
2.26.0.597.g7e08ed78ff
next prev parent reply other threads:[~2020-03-30 14:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-30 14:02 [PATCH 0/7] oid_array cleanups Jeff King
2020-03-30 14:03 ` [PATCH 1/7] oid_array: use size_t for count and allocation Jeff King
2020-03-30 14:09 ` Jeff King
2020-04-15 0:27 ` Taylor Blau
2020-03-30 14:03 ` Jeff King [this message]
2020-03-30 14:03 ` [PATCH 3/7] oid_array: rename source file from sha1-array Jeff King
2020-04-15 0:34 ` Taylor Blau
2020-03-30 14:04 ` [PATCH 4/7] test-tool: rename sha1-array to oid-array Jeff King
2020-03-30 14:04 ` [PATCH 5/7] bisect: stop referring to sha1_array Jeff King
2020-03-30 14:04 ` [PATCH 6/7] ref-filter: stop referring to "sha1 array" Jeff King
2020-03-30 14:04 ` [PATCH 7/7] oidset: stop referring to sha1-array Jeff King
2020-04-15 0:35 ` [PATCH 0/7] oid_array cleanups Taylor Blau
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=20200330140320.GB2456038@coredump.intra.peff.net \
--to=peff@peff.net \
--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).