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>
Jonathan Tan committed
Oct 14, 2016 at 10:37 UTC
d65fd424ad21adbc1ea11fcddae331698453d1e2
1 file changed
+7
-7
trailer.c
+7
-7
@@ -27,8 +27,8 @@ static struct conf_info default_conf_info;
27
struct trailer_item {
28
struct trailer_item *previous;
29
struct trailer_item *next;
30
- const char *token;
31
- const char *value;
30
+ char *token;
31
+ char *value;
32
struct conf_info conf;
33
};
34
@@ -95,8 +95,8 @@ static void free_trailer_item(struct trailer_item *item)
95
free(item->conf.name);
96
free(item->conf.key);
97
free(item->conf.command);
98
- free((char *)item->token);
99
- free((char *)item->value);
98
+ free(item->token);
99
+ free(item->value);
100
free(item);
101
}
102
@@ -215,13 +215,13 @@ static struct trailer_item *remove_first(struct trailer_item **first)
215
return item;
216
}
217
218
-static const char *apply_command(const char *command, const char *arg)
218
+static char *apply_command(const char *command, const char *arg)
219
{
220
struct strbuf cmd = STRBUF_INIT;
221
struct strbuf buf = STRBUF_INIT;
222
struct child_process cp = CHILD_PROCESS_INIT;
223
const char *argv[] = {NULL, NULL};
224
- const char *result;
224
+ char *result;
225
226
strbuf_addstr(&cmd, command);
227
if (arg)
@@ -425,7 +425,7 @@ static int set_if_missing(struct conf_info *item, const char *value)
425
return 0;
426
}
427
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)
429
{
430
*dst = *src;
431
if (src->name)