Skip to content

Commit 8ea9492

Browse files
committed
cocci: use MEMZERO_ARRAY() a bit more
Existing code in files that have been fairly stable trigger the "make coccicheck" suggestions due to the new check. Rewrite them to use MEMZERO_ARRAY() Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d2e4099 commit 8ea9492

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

diffcore-delta.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static struct spanhash_top *spanhash_rehash(struct spanhash_top *orig)
5656
st_mult(sizeof(struct spanhash), sz)));
5757
new_spanhash->alloc_log2 = orig->alloc_log2 + 1;
5858
new_spanhash->free = INITIAL_FREE(new_spanhash->alloc_log2);
59-
memset(new_spanhash->data, 0, sizeof(struct spanhash) * sz);
59+
MEMZERO_ARRAY(new_spanhash->data, sz);
6060
for (i = 0; i < osz; i++) {
6161
struct spanhash *o = &(orig->data[i]);
6262
int bucket;
@@ -135,7 +135,7 @@ static struct spanhash_top *hash_chars(struct repository *r,
135135
st_mult(sizeof(struct spanhash), (size_t)1 << i)));
136136
hash->alloc_log2 = i;
137137
hash->free = INITIAL_FREE(i);
138-
memset(hash->data, 0, sizeof(struct spanhash) * ((size_t)1 << i));
138+
MEMZERO_ARRAY(hash->data, ((size_t)1 << i));
139139

140140
n = 0;
141141
accum1 = accum2 = 0;

linear-assignment.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void compute_assignment(int column_count, int row_count, int *cost,
2020
int i, j, phase;
2121

2222
if (column_count < 2) {
23-
memset(column2row, 0, sizeof(int) * column_count);
24-
memset(row2column, 0, sizeof(int) * row_count);
23+
MEMZERO_ARRAY(column2row, column_count);
24+
MEMZERO_ARRAY(row2column, row_count);
2525
return;
2626
}
2727

shallow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
713713

714714
if (used) {
715715
int bitmap_size = DIV_ROUND_UP(pi.nr_bits, 32) * sizeof(uint32_t);
716-
memset(used, 0, sizeof(*used) * info->shallow->nr);
716+
MEMZERO_ARRAY(used, info->shallow->nr);
717717
for (i = 0; i < nr_shallow; i++) {
718718
const struct commit *c = lookup_commit(the_repository,
719719
&oid[shallow[i]]);
@@ -782,7 +782,7 @@ static void post_assign_shallow(struct shallow_info *info,
782782

783783
trace_printf_key(&trace_shallow, "shallow: post_assign_shallow\n");
784784
if (ref_status)
785-
memset(ref_status, 0, sizeof(*ref_status) * info->ref->nr);
785+
MEMZERO_ARRAY(ref_status, info->ref->nr);
786786

787787
/* Remove unreachable shallow commits from "theirs" */
788788
for (i = dst = 0; i < info->nr_theirs; i++) {

0 commit comments

Comments
 (0)