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>
This commit is contained in:

committed by
Junio C Hamano

parent
5529cba09f
commit
b567004b4b
@ -2,7 +2,8 @@
|
||||
#include "strbuf.h"
|
||||
|
||||
/* wrapper that supplies tests with an empty, initialized strbuf */
|
||||
static void setup(void (*f)(struct strbuf*, void*), void *data)
|
||||
static void setup(void (*f)(struct strbuf*, const void*),
|
||||
const void *data)
|
||||
{
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
@ -13,7 +14,8 @@ static void setup(void (*f)(struct strbuf*, void*), void *data)
|
||||
}
|
||||
|
||||
/* wrapper that supplies tests with a populated, initialized strbuf */
|
||||
static void setup_populated(void (*f)(struct strbuf*, void*), char *init_str, void *data)
|
||||
static void setup_populated(void (*f)(struct strbuf*, const void*),
|
||||
const char *init_str, const void *data)
|
||||
{
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
@ -64,7 +66,7 @@ static void t_dynamic_init(void)
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
static void t_addch(struct strbuf *buf, void *data)
|
||||
static void t_addch(struct strbuf *buf, const void *data)
|
||||
{
|
||||
const char *p_ch = data;
|
||||
const char ch = *p_ch;
|
||||
@ -83,7 +85,7 @@ static void t_addch(struct strbuf *buf, void *data)
|
||||
check_char(buf->buf[buf->len], ==, '\0');
|
||||
}
|
||||
|
||||
static void t_addstr(struct strbuf *buf, void *data)
|
||||
static void t_addstr(struct strbuf *buf, const void *data)
|
||||
{
|
||||
const char *text = data;
|
||||
size_t len = strlen(text);
|
||||
|
Reference in New Issue
Block a user