Git fork

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>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
9077923c e813a020

+11 -10
+2 -2
reftable/reftable-writer.h
··· 156 156 the records before adding them, reordering the records array passed in. 157 157 */ 158 158 int reftable_writer_add_refs(struct reftable_writer *w, 159 - struct reftable_ref_record *refs, int n); 159 + struct reftable_ref_record *refs, size_t n); 160 160 161 161 /* 162 162 adds reftable_log_records. Log records are keyed by (refname, decreasing ··· 171 171 the records before adding them, reordering records array passed in. 172 172 */ 173 173 int reftable_writer_add_logs(struct reftable_writer *w, 174 - struct reftable_log_record *logs, int n); 174 + struct reftable_log_record *logs, size_t n); 175 175 176 176 /* reftable_writer_close finalizes the reftable. The writer is retained so 177 177 * statistics can be inspected. */
+9 -8
reftable/writer.c
··· 395 395 } 396 396 397 397 int reftable_writer_add_refs(struct reftable_writer *w, 398 - struct reftable_ref_record *refs, int n) 398 + struct reftable_ref_record *refs, size_t n) 399 399 { 400 400 int err = 0; 401 - int i = 0; 401 + 402 402 QSORT(refs, n, reftable_ref_record_compare_name); 403 - for (i = 0; err == 0 && i < n; i++) { 403 + 404 + for (size_t i = 0; err == 0 && i < n; i++) 404 405 err = reftable_writer_add_ref(w, &refs[i]); 405 - } 406 + 406 407 return err; 407 408 } 408 409 ··· 486 487 } 487 488 488 489 int reftable_writer_add_logs(struct reftable_writer *w, 489 - struct reftable_log_record *logs, int n) 490 + struct reftable_log_record *logs, size_t n) 490 491 { 491 492 int err = 0; 492 - int i = 0; 493 + 493 494 QSORT(logs, n, reftable_log_record_compare_key); 494 495 495 - for (i = 0; err == 0 && i < n; i++) { 496 + for (size_t i = 0; err == 0 && i < n; i++) 496 497 err = reftable_writer_add_log(w, &logs[i]); 497 - } 498 + 498 499 return err; 499 500 } 500 501