diff options
| author | Patrick Steinhardt <ps@pks.im> | 2024-06-07 08:37:39 +0200 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2024-06-07 10:30:48 -0700 |
| commit | b567004b4b43f9b0d88aa1f0b15698eae8f15836 (patch) | |
| tree | fc7b75831c1eb79a89c0196fbb78bd6b7d09d0b1 /reftable/stack.c | |
| parent | Merge branch 'ps/leakfixes' into ps/no-writable-strings (diff) | |
| download | git-b567004b4b43f9b0d88aa1f0b15698eae8f15836.tar.gz git-b567004b4b43f9b0d88aa1f0b15698eae8f15836.zip | |
global: improve const correctness when assigning string constants
We're about to enable `-Wwrite-strings`, which changes the type of
string constants to `const char[]`. Fix various sites where we assign
such constants to non-const variables.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'reftable/stack.c')
| -rw-r--r-- | reftable/stack.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/reftable/stack.c b/reftable/stack.c index a59ebe038d..09549c51c9 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -204,7 +204,8 @@ static struct reftable_reader **stack_copy_readers(struct reftable_stack *st, return cur; } -static int reftable_stack_reload_once(struct reftable_stack *st, char **names, +static int reftable_stack_reload_once(struct reftable_stack *st, + const char **names, int reuse_open) { size_t cur_len = !st->merged ? 0 : st->merged->stack_len; @@ -222,7 +223,7 @@ static int reftable_stack_reload_once(struct reftable_stack *st, char **names, while (*names) { struct reftable_reader *rd = NULL; - char *name = *names++; + const char *name = *names++; /* this is linear; we assume compaction keeps the number of tables under control so this is not quadratic. */ @@ -354,7 +355,7 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st, goto out; } - err = reftable_stack_reload_once(st, names, reuse_open); + err = reftable_stack_reload_once(st, (const char **) names, reuse_open); if (!err) break; if (err != REFTABLE_NOT_EXIST_ERROR) @@ -368,7 +369,8 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st, err = read_lines(st->list_file, &names_after); if (err < 0) goto out; - if (names_equal(names_after, names)) { + if (names_equal((const char **) names_after, + (const char **) names)) { err = REFTABLE_NOT_EXIST_ERROR; goto out; } |
