int n, err;
char **names = NULL;
const char *want[] = { "line1", "line2", "line3" };
- int i = 0;
check_int(fd, >, 0);
n = write_in_full(fd, out, strlen(out));
err = read_lines(fn, &names);
check(!err);
- for (i = 0; names[i]; i++) {
+ for (size_t i = 0; names[i]; i++)
check_str(want[i], names[i]);
- }
free_names(names);
(void) remove(fn);
}
};
strbuf_reset(&buf);
- strbuf_addf(&buf, "refs/heads/branch-%04u", (unsigned) i);
+ strbuf_addf(&buf, "refs/heads/branch-%04"PRIuMAX, (uintmax_t)i);
ref.refname = buf.buf;
set_test_hash(ref.value.val1, i);
.value_type = REFTABLE_REF_SYMREF,
.value.symref = (char *) "master",
};
- struct reftable_ref_record dest = { NULL };
+ struct reftable_ref_record dest = { 0 };
struct stat stat_result = { 0 };
err = reftable_new_stack(&st, dir, &opts);
check(!err);
- err = reftable_stack_add(st, &write_test_ref, &ref);
+ err = reftable_stack_add(st, write_test_ref, &ref);
check(!err);
err = reftable_stack_read_ref(st, ref.refname, &dest);
err = reftable_new_stack(&st2, dir, &opts);
check(!err);
- err = reftable_stack_add(st1, &write_test_ref, &ref1);
+ err = reftable_stack_add(st1, write_test_ref, &ref1);
check(!err);
- err = reftable_stack_add(st2, &write_test_ref, &ref2);
+ err = reftable_stack_add(st2, write_test_ref, &ref2);
check_int(err, ==, REFTABLE_OUTDATED_ERROR);
err = reftable_stack_reload(st2);
check(!err);
- err = reftable_stack_add(st2, &write_test_ref, &ref2);
+ err = reftable_stack_add(st2, write_test_ref, &ref2);
check(!err);
reftable_stack_destroy(st1);
reftable_stack_destroy(st2);
.value_type = REFTABLE_REF_SYMREF,
.value.symref = (char *) "master",
};
- struct reftable_ref_record dest = { NULL };
+ struct reftable_ref_record dest = { 0 };
err = reftable_new_stack(&st, dir, &opts);
check(!err);
err = reftable_stack_new_addition(&add, st);
check(!err);
- err = reftable_addition_add(add, &write_test_ref, &ref);
+ err = reftable_addition_add(add, write_test_ref, &ref);
check(!err);
err = reftable_addition_commit(add);
struct reftable_write_options opts = {0};
struct reftable_addition *add = NULL;
struct reftable_stack *st = NULL;
- int i, n = 20, err;
+ size_t n = 20;
+ int err;
err = reftable_new_stack(&st, dir, &opts);
check(!err);
- for (i = 0; i <= n; i++) {
+ for (size_t i = 0; i <= n; i++) {
struct reftable_ref_record ref = {
.update_index = reftable_stack_next_update_index(st),
.value_type = REFTABLE_REF_SYMREF,
};
char name[100];
- snprintf(name, sizeof(name), "branch%04d", i);
+ snprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
ref.refname = name;
/*
err = reftable_stack_new_addition(&add, st);
check(!err);
- err = reftable_addition_add(add, &write_test_ref, &ref);
+ err = reftable_addition_add(add, write_test_ref, &ref);
check(!err);
err = reftable_addition_commit(add);
.value_type = REFTABLE_REF_VAL1,
.value.val1 = {0x01},
};
- struct reftable_write_options opts = {0};
+ struct reftable_write_options opts = { 0 };
struct reftable_stack *st;
struct strbuf table_path = STRBUF_INIT;
char *dir = get_tmp_dir(__LINE__);
err = reftable_new_stack(&st, dir, &opts);
check(!err);
- err = reftable_stack_add(st, &write_test_ref, &ref1);
+ err = reftable_stack_add(st, write_test_ref, &ref1);
check(!err);
- err = reftable_stack_add(st, &write_test_ref, &ref2);
+ err = reftable_stack_add(st, write_test_ref, &ref2);
check_int(err, ==, REFTABLE_API_ERROR);
reftable_stack_destroy(st);
clear_dir(dir);
err = reftable_new_stack(&st, dir, &opts);
check(!err);
for (i = -1; i != REFTABLE_EMPTY_TABLE_ERROR; i--) {
- err = reftable_stack_add(st, &write_error, &i);
+ err = reftable_stack_add(st, write_error, &i);
check_int(err, ==, i);
}
static void t_reftable_stack_add(void)
{
- int i = 0;
int err = 0;
struct reftable_write_options opts = {
.exact_log_message = 1,
};
struct reftable_stack *st = NULL;
char *dir = get_tmp_dir(__LINE__);
- struct reftable_ref_record refs[2] = { { NULL } };
- struct reftable_log_record logs[2] = { { NULL } };
+ struct reftable_ref_record refs[2] = { 0 };
+ struct reftable_log_record logs[2] = { 0 };
struct strbuf path = STRBUF_INIT;
struct stat stat_result;
- int N = ARRAY_SIZE(refs);
+ size_t i, N = ARRAY_SIZE(refs);
err = reftable_new_stack(&st, dir, &opts);
check(!err);
for (i = 0; i < N; i++) {
char buf[256];
- snprintf(buf, sizeof(buf), "branch%02d", i);
+ snprintf(buf, sizeof(buf), "branch%02"PRIuMAX, (uintmax_t)i);
refs[i].refname = xstrdup(buf);
refs[i].update_index = i + 1;
refs[i].value_type = REFTABLE_REF_VAL1;
}
for (i = 0; i < N; i++) {
- int err = reftable_stack_add(st, &write_test_ref, &refs[i]);
+ int err = reftable_stack_add(st, write_test_ref, &refs[i]);
check(!err);
}
.log = &logs[i],
.update_index = reftable_stack_next_update_index(st),
};
- int err = reftable_stack_add(st, &write_test_log, &arg);
+ int err = reftable_stack_add(st, write_test_log, &arg);
check(!err);
}
check(!err);
for (i = 0; i < N; i++) {
- struct reftable_ref_record dest = { NULL };
+ struct reftable_ref_record dest = { 0 };
int err = reftable_stack_read_ref(st, refs[i].refname, &dest);
check(!err);
}
for (i = 0; i < N; i++) {
- struct reftable_log_record dest = { NULL };
+ struct reftable_log_record dest = { 0 };
int err = reftable_stack_read_log(st, refs[i].refname, &dest);
check(!err);
check(reftable_log_record_equal(&dest, logs + i,
check(!err);
input.value.update.message = (char *) "one\ntwo";
- err = reftable_stack_add(st, &write_test_log, &arg);
+ err = reftable_stack_add(st, write_test_log, &arg);
check_int(err, ==, REFTABLE_API_ERROR);
input.value.update.message = (char *) "one";
- err = reftable_stack_add(st, &write_test_log, &arg);
+ err = reftable_stack_add(st, write_test_log, &arg);
check(!err);
err = reftable_stack_read_log(st, input.refname, &dest);
input.value.update.message = (char *) "two\n";
arg.update_index = 2;
- err = reftable_stack_add(st, &write_test_log, &arg);
+ err = reftable_stack_add(st, write_test_log, &arg);
check(!err);
err = reftable_stack_read_log(st, input.refname, &dest);
check(!err);
static void t_reftable_stack_tombstone(void)
{
- int i = 0;
char *dir = get_tmp_dir(__LINE__);
struct reftable_write_options opts = { 0 };
struct reftable_stack *st = NULL;
int err;
- struct reftable_ref_record refs[2] = { { NULL } };
- struct reftable_log_record logs[2] = { { NULL } };
- int N = ARRAY_SIZE(refs);
- struct reftable_ref_record dest = { NULL };
- struct reftable_log_record log_dest = { NULL };
+ struct reftable_ref_record refs[2] = { 0 };
+ struct reftable_log_record logs[2] = { 0 };
+ size_t i, N = ARRAY_SIZE(refs);
+ struct reftable_ref_record dest = { 0 };
+ struct reftable_log_record log_dest = { 0 };
err = reftable_new_stack(&st, dir, &opts);
check(!err);
}
}
for (i = 0; i < N; i++) {
- int err = reftable_stack_add(st, &write_test_ref, &refs[i]);
+ int err = reftable_stack_add(st, write_test_ref, &refs[i]);
check(!err);
}
.log = &logs[i],
.update_index = reftable_stack_next_update_index(st),
};
- int err = reftable_stack_add(st, &write_test_log, &arg);
+ int err = reftable_stack_add(st, write_test_log, &arg);
check(!err);
}
struct reftable_stack *st32 = NULL;
struct reftable_write_options opts_default = { 0 };
struct reftable_stack *st_default = NULL;
- struct reftable_ref_record dest = { NULL };
+ struct reftable_ref_record dest = { 0 };
err = reftable_new_stack(&st, dir, &opts);
check(!err);
- err = reftable_stack_add(st, &write_test_ref, &ref);
+ err = reftable_stack_add(st, write_test_ref, &ref);
check(!err);
/* can't read it with the wrong hash ID. */
char *dir = get_tmp_dir(__LINE__);
struct reftable_write_options opts = { 0 };
struct reftable_stack *st = NULL;
- struct reftable_log_record logs[20] = { { NULL } };
- int N = ARRAY_SIZE(logs) - 1;
- int i = 0;
+ struct reftable_log_record logs[20] = { 0 };
+ size_t i, N = ARRAY_SIZE(logs) - 1;
int err;
struct reftable_log_expiry_config expiry = {
.time = 10,
};
- struct reftable_log_record log = { NULL };
+ struct reftable_log_record log = { 0 };
err = reftable_new_stack(&st, dir, &opts);
check(!err);
for (i = 1; i <= N; i++) {
char buf[256];
- snprintf(buf, sizeof(buf), "branch%02d", i);
+ snprintf(buf, sizeof(buf), "branch%02"PRIuMAX, (uintmax_t)i);
logs[i].refname = xstrdup(buf);
logs[i].update_index = i;
.log = &logs[i],
.update_index = reftable_stack_next_update_index(st),
};
- int err = reftable_stack_add(st, &write_test_log, &arg);
+ int err = reftable_stack_add(st, write_test_log, &arg);
check(!err);
}
/* cleanup */
reftable_stack_destroy(st);
- for (i = 0; i <= N; i++) {
+ for (i = 0; i <= N; i++)
reftable_log_record_release(&logs[i]);
- }
clear_dir(dir);
reftable_log_record_release(&log);
}
err = reftable_new_stack(&st, dir, &opts);
check(!err);
- err = reftable_stack_add(st, &write_nothing, NULL);
+ err = reftable_stack_add(st, write_nothing, NULL);
check(!err);
err = reftable_new_stack(&st2, dir, &opts);
};
struct reftable_stack *st = NULL;
char *dir = get_tmp_dir(__LINE__);
- int err, i;
- int N = 100;
+ int err;
+ size_t i, N = 100;
err = reftable_new_stack(&st, dir, &opts);
check(!err);
.value_type = REFTABLE_REF_SYMREF,
.value.symref = (char *) "master",
};
- snprintf(name, sizeof(name), "branch%04d", i);
+ snprintf(name, sizeof(name), "branch%04"PRIuMAX, (uintmax_t)i);
- err = reftable_stack_add(st, &write_test_ref, &ref);
+ err = reftable_stack_add(st, write_test_ref, &ref);
check(!err);
err = reftable_stack_auto_compact(st);
struct reftable_stack *st = NULL;
struct strbuf refname = STRBUF_INIT;
char *dir = get_tmp_dir(__LINE__);
- int err, i, n = 20;
+ int err;
+ size_t i, n = 20;
err = reftable_new_stack(&st, dir, &opts);
check(!err);
st->opts.disable_auto_compact = i != n;
strbuf_reset(&refname);
- strbuf_addf(&refname, "branch-%04d", i);
+ strbuf_addf(&refname, "branch-%04"PRIuMAX, (uintmax_t)i);
ref.refname = refname.buf;
- err = reftable_stack_add(st, &write_test_ref, &ref);
+ err = reftable_stack_add(st, write_test_ref, &ref);
check(!err);
/*