trailer: improve const correctness
Change "const char *" to "char *" in struct trailer_item and in the return value of apply_command (since those strings are owned strings). Change "struct conf_info *" to "const struct conf_info *" (since that struct is not modified). Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
3cdd5d1917
commit
d65fd424ad
14
trailer.c
14
trailer.c
@ -27,8 +27,8 @@ static struct conf_info default_conf_info;
|
||||
struct trailer_item {
|
||||
struct trailer_item *previous;
|
||||
struct trailer_item *next;
|
||||
const char *token;
|
||||
const char *value;
|
||||
char *token;
|
||||
char *value;
|
||||
struct conf_info conf;
|
||||
};
|
||||
|
||||
@ -95,8 +95,8 @@ static void free_trailer_item(struct trailer_item *item)
|
||||
free(item->conf.name);
|
||||
free(item->conf.key);
|
||||
free(item->conf.command);
|
||||
free((char *)item->token);
|
||||
free((char *)item->value);
|
||||
free(item->token);
|
||||
free(item->value);
|
||||
free(item);
|
||||
}
|
||||
|
||||
@ -215,13 +215,13 @@ static struct trailer_item *remove_first(struct trailer_item **first)
|
||||
return item;
|
||||
}
|
||||
|
||||
static const char *apply_command(const char *command, const char *arg)
|
||||
static char *apply_command(const char *command, const char *arg)
|
||||
{
|
||||
struct strbuf cmd = STRBUF_INIT;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
struct child_process cp = CHILD_PROCESS_INIT;
|
||||
const char *argv[] = {NULL, NULL};
|
||||
const char *result;
|
||||
char *result;
|
||||
|
||||
strbuf_addstr(&cmd, command);
|
||||
if (arg)
|
||||
@ -425,7 +425,7 @@ static int set_if_missing(struct conf_info *item, const char *value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void duplicate_conf(struct conf_info *dst, struct conf_info *src)
|
||||
static void duplicate_conf(struct conf_info *dst, const struct conf_info *src)
|
||||
{
|
||||
*dst = *src;
|
||||
if (src->name)
|
||||
|
Loading…
Reference in New Issue
Block a user