Skip to content

Commit d65fd42

Browse files
jonathantanmygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3cdd5d1 commit d65fd42

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

trailer.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ static struct conf_info default_conf_info;
2727
struct trailer_item {
2828
struct trailer_item *previous;
2929
struct trailer_item *next;
30-
const char *token;
31-
const char *value;
30+
char *token;
31+
char *value;
3232
struct conf_info conf;
3333
};
3434

@@ -95,8 +95,8 @@ static void free_trailer_item(struct trailer_item *item)
9595
free(item->conf.name);
9696
free(item->conf.key);
9797
free(item->conf.command);
98-
free((char *)item->token);
99-
free((char *)item->value);
98+
free(item->token);
99+
free(item->value);
100100
free(item);
101101
}
102102

@@ -215,13 +215,13 @@ static struct trailer_item *remove_first(struct trailer_item **first)
215215
return item;
216216
}
217217

218-
static const char *apply_command(const char *command, const char *arg)
218+
static char *apply_command(const char *command, const char *arg)
219219
{
220220
struct strbuf cmd = STRBUF_INIT;
221221
struct strbuf buf = STRBUF_INIT;
222222
struct child_process cp = CHILD_PROCESS_INIT;
223223
const char *argv[] = {NULL, NULL};
224-
const char *result;
224+
char *result;
225225

226226
strbuf_addstr(&cmd, command);
227227
if (arg)
@@ -425,7 +425,7 @@ static int set_if_missing(struct conf_info *item, const char *value)
425425
return 0;
426426
}
427427

428-
static void duplicate_conf(struct conf_info *dst, struct conf_info *src)
428+
static void duplicate_conf(struct conf_info *dst, const struct conf_info *src)
429429
{
430430
*dst = *src;
431431
if (src->name)

0 commit comments

Comments
 (0)