reftable/writer: fix type used for number of records
Both `reftable_writer_add_refs()` and `reftable_writer_add_logs()` accept an array of records that should be added to the new table. Callers of this function are expected to also pass the number of such records to the function to tell it how many such records it is supposed to write. But while all callers pass in a `size_t`, which is a sensible choice, the function in fact accepts an `int` as argument, which is less so. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>main
parent
e813a0200a
commit
9077923c8e
|
@ -156,7 +156,7 @@ int reftable_writer_add_ref(struct reftable_writer *w,
|
|||
the records before adding them, reordering the records array passed in.
|
||||
*/
|
||||
int reftable_writer_add_refs(struct reftable_writer *w,
|
||||
struct reftable_ref_record *refs, int n);
|
||||
struct reftable_ref_record *refs, size_t n);
|
||||
|
||||
/*
|
||||
adds reftable_log_records. Log records are keyed by (refname, decreasing
|
||||
|
@ -171,7 +171,7 @@ int reftable_writer_add_log(struct reftable_writer *w,
|
|||
the records before adding them, reordering records array passed in.
|
||||
*/
|
||||
int reftable_writer_add_logs(struct reftable_writer *w,
|
||||
struct reftable_log_record *logs, int n);
|
||||
struct reftable_log_record *logs, size_t n);
|
||||
|
||||
/* reftable_writer_close finalizes the reftable. The writer is retained so
|
||||
* statistics can be inspected. */
|
||||
|
|
|
@ -395,14 +395,15 @@ out:
|
|||
}
|
||||
|
||||
int reftable_writer_add_refs(struct reftable_writer *w,
|
||||
struct reftable_ref_record *refs, int n)
|
||||
struct reftable_ref_record *refs, size_t n)
|
||||
{
|
||||
int err = 0;
|
||||
int i = 0;
|
||||
|
||||
QSORT(refs, n, reftable_ref_record_compare_name);
|
||||
for (i = 0; err == 0 && i < n; i++) {
|
||||
|
||||
for (size_t i = 0; err == 0 && i < n; i++)
|
||||
err = reftable_writer_add_ref(w, &refs[i]);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -486,15 +487,15 @@ done:
|
|||
}
|
||||
|
||||
int reftable_writer_add_logs(struct reftable_writer *w,
|
||||
struct reftable_log_record *logs, int n)
|
||||
struct reftable_log_record *logs, size_t n)
|
||||
{
|
||||
int err = 0;
|
||||
int i = 0;
|
||||
|
||||
QSORT(logs, n, reftable_log_record_compare_key);
|
||||
|
||||
for (i = 0; err == 0 && i < n; i++) {
|
||||
for (size_t i = 0; err == 0 && i < n; i++)
|
||||
err = reftable_writer_add_log(w, &logs[i]);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue