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>

Patrick Steinhardt committed Jun 7, 2024 at 08:37 UTC b567004b4b43f9b0d88aa1f0b15698eae8f15836
38 files changed +106 -102
builtin/bisect.c
+2 -1
@@ -262,7 +262,8 @@ static int bisect_reset(const char *commit)
262 return bisect_clean_state();
263 }
264
265 -static void log_commit(FILE *fp, char *fmt, const char *state,
265 +static void log_commit(FILE *fp,
266 + const char *fmt, const char *state,
267 struct commit *commit)
268 {
269 struct pretty_print_context pp = {0};
builtin/blame.c
+1 -1
@@ -134,7 +134,7 @@ static void get_ac_line(const char *inbuf, const char *what,
134 {
135 struct ident_split ident;
136 size_t len, maillen, namelen;
137 - char *tmp, *endp;
137 + const char *tmp, *endp;
138 const char *namebuf, *mailbuf;
139
140 tmp = strstr(inbuf, what);
builtin/bugreport.c
+1 -1
@@ -107,7 +107,7 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
107 struct tm tm;
108 enum diagnose_mode diagnose = DIAGNOSE_NONE;
109 char *option_output = NULL;
110 - char *option_suffix = "%Y-%m-%d-%H%M";
110 + const char *option_suffix = "%Y-%m-%d-%H%M";
111 const char *user_relative_path = NULL;
112 char *prefixed_filename;
113 size_t output_path_len;
builtin/check-ignore.c
+2 -2
@@ -35,8 +35,8 @@ static const struct option check_ignore_options[] = {
35
36 static void output_pattern(const char *path, struct path_pattern *pattern)
37 {
38 - char *bang = (pattern && pattern->flags & PATTERN_FLAG_NEGATIVE) ? "!" : "";
39 - char *slash = (pattern && pattern->flags & PATTERN_FLAG_MUSTBEDIR) ? "/" : "";
38 + const char *bang = (pattern && pattern->flags & PATTERN_FLAG_NEGATIVE) ? "!" : "";
39 + const char *slash = (pattern && pattern->flags & PATTERN_FLAG_MUSTBEDIR) ? "/" : "";
40 if (!nul_term_line) {
41 if (!verbose) {
42 write_name_quoted(path, stdout, '\n');
builtin/clone.c
+3 -3
@@ -71,7 +71,7 @@ static char *option_branch = NULL;
71 static struct string_list option_not = STRING_LIST_INIT_NODUP;
72 static const char *real_git_dir;
73 static const char *ref_format;
74 -static char *option_upload_pack = "git-upload-pack";
74 +static const char *option_upload_pack = "git-upload-pack";
75 static int option_verbosity;
76 static int option_progress = -1;
77 static int option_sparse_checkout;
@@ -177,8 +177,8 @@ static struct option builtin_clone_options[] = {
177
178 static const char *get_repo_path_1(struct strbuf *path, int *is_bundle)
179 {
180 - static char *suffix[] = { "/.git", "", ".git/.git", ".git" };
181 - static char *bundle_suffix[] = { ".bundle", "" };
180 + static const char *suffix[] = { "/.git", "", ".git/.git", ".git" };
181 + static const char *bundle_suffix[] = { ".bundle", "" };
182 size_t baselen = path->len;
183 struct stat st;
184 int i;
builtin/commit.c
+3 -3
@@ -113,7 +113,7 @@ static char *template_file;
113 * the commit message and/or authorship.
114 */
115 static const char *author_message, *author_message_buffer;
116 -static char *edit_message, *use_message;
116 +static const char *edit_message, *use_message;
117 static char *fixup_message, *fixup_commit, *squash_message;
118 static const char *fixup_prefix;
119 static int all, also, interactive, patch_interactive, only, amend, signoff;
@@ -121,8 +121,8 @@ static int edit_flag = -1; /* unspecified */
121 static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship;
122 static int config_commit_verbose = -1; /* unspecified */
123 static int no_post_rewrite, allow_empty_message, pathspec_file_nul;
124 -static char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
125 -static char *sign_commit, *pathspec_from_file;
124 +static const char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
125 +static const char *sign_commit, *pathspec_from_file;
126 static struct strvec trailer_args = STRVEC_INIT;
127
128 /*
builtin/diagnose.c
+1 -1
@@ -18,7 +18,7 @@ int cmd_diagnose(int argc, const char **argv, const char *prefix)
18 struct tm tm;
19 enum diagnose_mode mode = DIAGNOSE_STATS;
20 char *option_output = NULL;
21 - char *option_suffix = "%Y-%m-%d-%H%M";
21 + const char *option_suffix = "%Y-%m-%d-%H%M";
22 char *prefixed_filename;
23
24 const struct option diagnose_options[] = {
builtin/log.c
+1 -1
@@ -1283,7 +1283,7 @@ static void get_patch_ids(struct rev_info *rev, struct patch_ids *ids)
1283 o2->flags = flags2;
1284 }
1285
1286 -static void gen_message_id(struct rev_info *info, char *base)
1286 +static void gen_message_id(struct rev_info *info, const char *base)
1287 {
1288 struct strbuf buf = STRBUF_INIT;
1289 strbuf_addf(&buf, "%s.%"PRItime".git.%s", base,
builtin/mailsplit.c
+2 -2
@@ -113,8 +113,8 @@ static int populate_maildir_list(struct string_list *list, const char *path)
113 DIR *dir;
114 struct dirent *dent;
115 char *name = NULL;
116 - char *subs[] = { "cur", "new", NULL };
117 - char **sub;
116 + const char *subs[] = { "cur", "new", NULL };
117 + const char **sub;
118 int ret = -1;
119
120 for (sub = subs; *sub; ++sub) {
builtin/pull.c
+26 -26
@@ -71,48 +71,48 @@ static const char * const pull_usage[] = {
71
72 /* Shared options */
73 static int opt_verbosity;
74 -static char *opt_progress;
74 +static const char *opt_progress;
75 static int recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
76 static int recurse_submodules_cli = RECURSE_SUBMODULES_DEFAULT;
77
78 /* Options passed to git-merge or git-rebase */
79 static enum rebase_type opt_rebase = -1;
80 -static char *opt_diffstat;
81 -static char *opt_log;
82 -static char *opt_signoff;
83 -static char *opt_squash;
84 -static char *opt_commit;
85 -static char *opt_edit;
86 -static char *cleanup_arg;
87 -static char *opt_ff;
88 -static char *opt_verify_signatures;
89 -static char *opt_verify;
80 +static const char *opt_diffstat;
81 +static const char *opt_log;
82 +static const char *opt_signoff;
83 +static const char *opt_squash;
84 +static const char *opt_commit;
85 +static const char *opt_edit;
86 +static const char *cleanup_arg;
87 +static const char *opt_ff;
88 +static const char *opt_verify_signatures;
89 +static const char *opt_verify;
90 static int opt_autostash = -1;
91 static int config_autostash;
92 static int check_trust_level = 1;
93 static struct strvec opt_strategies = STRVEC_INIT;
94 static struct strvec opt_strategy_opts = STRVEC_INIT;
95 -static char *opt_gpg_sign;
95 +static const char *opt_gpg_sign;
96 static int opt_allow_unrelated_histories;
97
98 /* Options passed to git-fetch */
99 -static char *opt_all;
100 -static char *opt_append;
101 -static char *opt_upload_pack;
99 +static const char *opt_all;
100 +static const char *opt_append;
101 +static const char *opt_upload_pack;
102 static int opt_force;
103 -static char *opt_tags;
104 -static char *opt_prune;
105 -static char *max_children;
103 +static const char *opt_tags;
104 +static const char *opt_prune;
105 +static const char *max_children;
106 static int opt_dry_run;
107 -static char *opt_keep;
108 -static char *opt_depth;
109 -static char *opt_unshallow;
110 -static char *opt_update_shallow;
111 -static char *opt_refmap;
112 -static char *opt_ipv4;
113 -static char *opt_ipv6;
107 +static const char *opt_keep;
108 +static const char *opt_depth;
109 +static const char *opt_unshallow;
110 +static const char *opt_update_shallow;
111 +static const char *opt_refmap;
112 +static const char *opt_ipv4;
113 +static const char *opt_ipv6;
114 static int opt_show_forced_updates = -1;
115 -static char *set_upstream;
115 +static const char *set_upstream;
116 static struct strvec opt_fetch = STRVEC_INIT;
117
118 static struct option pull_options[] = {
builtin/receive-pack.c
+2 -2
@@ -1249,7 +1249,7 @@ cleanup:
1249 return code;
1250 }
1251
1252 -static char *refuse_unconfigured_deny_msg =
1252 +static const char *refuse_unconfigured_deny_msg =
1253 N_("By default, updating the current branch in a non-bare repository\n"
1254 "is denied, because it will make the index and work tree inconsistent\n"
1255 "with what you pushed, and will require 'git reset --hard' to match\n"
@@ -1269,7 +1269,7 @@ static void refuse_unconfigured_deny(void)
1269 rp_error("%s", _(refuse_unconfigured_deny_msg));
1270 }
1271
1272 -static char *refuse_unconfigured_deny_delete_current_msg =
1272 +static const char *refuse_unconfigured_deny_delete_current_msg =
1273 N_("By default, deleting the current branch is denied, because the next\n"
1274 "'git clone' won't result in any file checked out, causing confusion.\n"
1275 "\n"
builtin/revert.c
+1 -1
@@ -179,7 +179,7 @@ static int run_sequencer(int argc, const char **argv, const char *prefix,
179
180 /* Check for incompatible command line arguments */
181 if (cmd) {
182 - char *this_operation;
182 + const char *this_operation;
183 if (cmd == 'q')
184 this_operation = "--quit";
185 else if (cmd == 'c')
compat/regex/regcomp.c
+1 -1
@@ -848,7 +848,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
848 {
849 unsigned int table_size;
850 #ifndef _LIBC
851 - char *codeset_name;
851 + const char *codeset_name;
852 #endif
853
854 memset (dfa, '\0', sizeof (re_dfa_t));
diff.c
+2 -2
@@ -3764,7 +3764,7 @@ static void builtin_diff(const char *name_a,
3764 return;
3765 }
3766
3767 -static char *get_compact_summary(const struct diff_filepair *p, int is_renamed)
3767 +static const char *get_compact_summary(const struct diff_filepair *p, int is_renamed)
3768 {
3769 if (!is_renamed) {
3770 if (p->status == DIFF_STATUS_ADDED) {
@@ -4076,7 +4076,7 @@ static int reuse_worktree_file(struct index_state *istate,
4076 static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
4077 {
4078 struct strbuf buf = STRBUF_INIT;
4079 - char *dirty = "";
4079 + const char *dirty = "";
4080
4081 /* Are we looking at the work tree? */
4082 if (s->dirty_submodule)
diffcore-rename.c
+3 -3
@@ -406,7 +406,7 @@ static const char *get_highest_rename_path(struct strintmap *counts)
406 return highest_destination_dir;
407 }
408
409 -static char *UNKNOWN_DIR = "/"; /* placeholder -- short, illegal directory */
409 +static const char *UNKNOWN_DIR = "/"; /* placeholder -- short, illegal directory */
410
411 static int dir_rename_already_determinable(struct strintmap *counts)
412 {
@@ -429,8 +429,8 @@ static int dir_rename_already_determinable(struct strintmap *counts)
429 }
430
431 static void increment_count(struct dir_rename_info *info,
432 - char *old_dir,
433 - char *new_dir)
432 + const char *old_dir,
433 + const char *new_dir)
434 {
435 struct strintmap *counts;
436 struct strmap_entry *e;
fmt-merge-msg.c
+1 -1
@@ -447,7 +447,7 @@ static void fmt_merge_msg_title(struct strbuf *out,
447 const char *current_branch)
448 {
449 int i = 0;
450 - char *sep = "";
450 + const char *sep = "";
451
452 strbuf_addstr(out, "Merge ");
453 for (i = 0; i < srcs.nr; i++) {
fsck.c
+1 -1
@@ -1231,7 +1231,7 @@ int fsck_object(struct object *obj, void *data, unsigned long size,
1231 }
1232
1233 int fsck_buffer(const struct object_id *oid, enum object_type type,
1234 - void *data, unsigned long size,
1234 + const void *data, unsigned long size,
1235 struct fsck_options *options)
1236 {
1237 if (type == OBJ_BLOB)
fsck.h
+1 -1
@@ -202,7 +202,7 @@ int fsck_object(struct object *obj, void *data, unsigned long size,
202 * struct.
203 */
204 int fsck_buffer(const struct object_id *oid, enum object_type,
205 - void *data, unsigned long size,
205 + const void *data, unsigned long size,
206 struct fsck_options *options);
207
208 /*
gpg-interface.c
+1 -1
@@ -727,7 +727,7 @@ static int git_gpg_config(const char *var, const char *value,
727 void *cb UNUSED)
728 {
729 struct gpg_format *fmt = NULL;
730 - char *fmtname = NULL;
730 + const char *fmtname = NULL;
731 char *trust;
732 int ret;
733
http-backend.c
+1 -1
@@ -753,7 +753,7 @@ static int bad_request(struct strbuf *hdr, const struct service_cmd *c)
753
754 int cmd_main(int argc UNUSED, const char **argv UNUSED)
755 {
756 - char *method = getenv("REQUEST_METHOD");
756 + const char *method = getenv("REQUEST_METHOD");
757 const char *proto_header;
758 char *dir;
759 struct service_cmd *cmd = NULL;
imap-send.c
+3 -3
@@ -1215,9 +1215,9 @@ static int imap_store_msg(struct imap_store *ctx, struct strbuf *msg)
1215 static void wrap_in_html(struct strbuf *msg)
1216 {
1217 struct strbuf buf = STRBUF_INIT;
1218 - static char *content_type = "Content-Type: text/html;\n";
1219 - static char *pre_open = "<pre>\n";
1220 - static char *pre_close = "</pre>\n";
1218 + static const char *content_type = "Content-Type: text/html;\n";
1219 + static const char *pre_open = "<pre>\n";
1220 + static const char *pre_close = "</pre>\n";
1221 const char *body = strstr(msg->buf, "\n\n");
1222
1223 if (!body)
pretty.c
+1 -1
@@ -1325,7 +1325,7 @@ int format_set_trailers_options(struct process_trailer_options *opts,
1325 static size_t parse_describe_args(const char *start, struct strvec *args)
1326 {
1327 struct {
1328 - char *name;
1328 + const char *name;
1329 enum {
1330 DESCRIBE_ARG_BOOL,
1331 DESCRIBE_ARG_INTEGER,
refs.c
+1 -1
@@ -159,7 +159,7 @@ void update_ref_namespace(enum ref_namespace namespace, char *ref)
159 {
160 struct ref_namespace_info *info = &ref_namespace[namespace];
161 if (info->ref_updated)
162 - free(info->ref);
162 + free((char *)info->ref);
163 info->ref = ref;
164 info->ref_updated = 1;
165 }
refs.h
+1 -1
@@ -975,7 +975,7 @@ struct ref_store *get_worktree_ref_store(const struct worktree *wt);
975 */
976
977 struct ref_namespace_info {
978 - char *ref;
978 + const char *ref;
979 enum decoration_type decoration;
980
981 /*
reftable/basics.c
+6 -9
@@ -67,9 +67,9 @@ void free_names(char **a)
67 reftable_free(a);
68 }
69
70 -size_t names_length(char **names)
70 +size_t names_length(const char **names)
71 {
72 - char **p = names;
72 + const char **p = names;
73 while (*p)
74 p++;
75 return p - names;
@@ -102,15 +102,12 @@ void parse_names(char *buf, int size, char ***namesp)
102 *namesp = names;
103 }
104
105 -int names_equal(char **a, char **b)
105 +int names_equal(const char **a, const char **b)
106 {
107 - int i = 0;
108 - for (; a[i] && b[i]; i++) {
109 - if (strcmp(a[i], b[i])) {
107 + size_t i = 0;
108 + for (; a[i] && b[i]; i++)
109 + if (strcmp(a[i], b[i]))
110 return 0;
111 - }
112 - }
113 -
111 return a[i] == b[i];
112 }
113
reftable/basics.h
+2 -2
@@ -42,10 +42,10 @@ void free_names(char **a);
42 void parse_names(char *buf, int size, char ***namesp);
43
44 /* compares two NULL-terminated arrays of strings. */
45 -int names_equal(char **a, char **b);
45 +int names_equal(const char **a, const char **b);
46
47 /* returns the array size of a NULL-terminated array of strings. */
48 -size_t names_length(char **names);
48 +size_t names_length(const char **names);
49
50 /* Allocation routines; they invoke the functions set through
51 * reftable_set_alloc() */
reftable/basics_test.c
+2 -2
@@ -58,8 +58,8 @@ static void test_binsearch(void)
58
59 static void test_names_length(void)
60 {
61 - char *a[] = { "a", "b", NULL };
62 - EXPECT(names_length(a) == 2);
61 + const char *names[] = { "a", "b", NULL };
62 + EXPECT(names_length(names) == 2);
63 }
64
65 static void test_parse_names_normal(void)
reftable/record.c
+3 -3
@@ -116,7 +116,7 @@ static int decode_string(struct strbuf *dest, struct string_view in)
116 return start_len - in.len;
117 }
118
119 -static int encode_string(char *str, struct string_view s)
119 +static int encode_string(const char *str, struct string_view s)
120 {
121 struct string_view start = s;
122 int l = strlen(str);
@@ -969,9 +969,9 @@ done:
969 return REFTABLE_FORMAT_ERROR;
970 }
971
972 -static int null_streq(char *a, char *b)
972 +static int null_streq(const char *a, const char *b)
973 {
974 - char *empty = "";
974 + const char *empty = "";
975 if (!a)
976 a = empty;
977
reftable/stack.c
+6 -4
@@ -204,7 +204,8 @@ static struct reftable_reader **stack_copy_readers(struct reftable_stack *st,
204 return cur;
205 }
206
207 -static int reftable_stack_reload_once(struct reftable_stack *st, char **names,
207 +static int reftable_stack_reload_once(struct reftable_stack *st,
208 + const char **names,
209 int reuse_open)
210 {
211 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,
223
224 while (*names) {
225 struct reftable_reader *rd = NULL;
225 - char *name = *names++;
226 + const char *name = *names++;
227
228 /* this is linear; we assume compaction keeps the number of
229 tables under control so this is not quadratic. */
@@ -354,7 +355,7 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
355 goto out;
356 }
357
357 - err = reftable_stack_reload_once(st, names, reuse_open);
358 + err = reftable_stack_reload_once(st, (const char **) names, reuse_open);
359 if (!err)
360 break;
361 if (err != REFTABLE_NOT_EXIST_ERROR)
@@ -368,7 +369,8 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
369 err = read_lines(st->list_file, &names_after);
370 if (err < 0)
371 goto out;
371 - if (names_equal(names_after, names)) {
372 + if (names_equal((const char **) names_after,
373 + (const char **) names)) {
374 err = REFTABLE_NOT_EXIST_ERROR;
375 goto out;
376 }
reftable/stack_test.c
+4 -4
@@ -83,7 +83,7 @@ static void test_read_file(void)
83 char out[1024] = "line1\n\nline2\nline3";
84 int n, err;
85 char **names = NULL;
86 - char *want[] = { "line1", "line2", "line3" };
86 + const char *want[] = { "line1", "line2", "line3" };
87 int i = 0;
88
89 EXPECT(fd > 0);
@@ -116,9 +116,9 @@ static void test_parse_names(void)
116
117 static void test_names_equal(void)
118 {
119 - char *a[] = { "a", "b", "c", NULL };
120 - char *b[] = { "a", "b", "d", NULL };
121 - char *c[] = { "a", "b", NULL };
119 + const char *a[] = { "a", "b", "c", NULL };
120 + const char *b[] = { "a", "b", "d", NULL };
121 + const char *c[] = { "a", "b", NULL };
122
123 EXPECT(names_equal(a, a));
124 EXPECT(!names_equal(a, b));
run-command.c
+1 -1
@@ -663,7 +663,7 @@ int start_command(struct child_process *cmd)
663 int need_in, need_out, need_err;
664 int fdin[2], fdout[2], fderr[2];
665 int failed_errno;
666 - char *str;
666 + const char *str;
667
668 /*
669 * In case of errors we must keep the promise to close FDs
t/helper/test-hashmap.c
+2 -1
@@ -36,7 +36,8 @@ static int test_entry_cmp(const void *cmp_data,
36 }
37
38 static struct test_entry *alloc_test_entry(unsigned int hash,
39 - char *key, char *value)
39 + const char *key,
40 + const char *value)
41 {
42 size_t klen = strlen(key);
43 size_t vlen = strlen(value);
t/helper/test-json-writer.c
+5 -5
@@ -174,7 +174,7 @@ static void make_arr4(int pretty)
174 jw_end(&arr4);
175 }
176
177 -static char *expect_nest1 =
177 +static const char *expect_nest1 =
178 "{\"obj1\":{\"a\":\"abc\",\"b\":42,\"c\":true},\"arr1\":[\"abc\",42,true]}";
179
180 static struct json_writer nest1 = JSON_WRITER_INIT;
@@ -195,10 +195,10 @@ static void make_nest1(int pretty)
195 jw_release(&arr1);
196 }
197
198 -static char *expect_inline1 =
198 +static const char *expect_inline1 =
199 "{\"obj1\":{\"a\":\"abc\",\"b\":42,\"c\":true},\"arr1\":[\"abc\",42,true]}";
200
201 -static char *pretty_inline1 =
201 +static const char *pretty_inline1 =
202 ("{\n"
203 " \"obj1\": {\n"
204 " \"a\": \"abc\",\n"
@@ -236,10 +236,10 @@ static void make_inline1(int pretty)
236 jw_end(&inline1);
237 }
238
239 -static char *expect_inline2 =
239 +static const char *expect_inline2 =
240 "[[1,2],[3,4],{\"a\":\"abc\"}]";
241
242 -static char *pretty_inline2 =
242 +static const char *pretty_inline2 =
243 ("[\n"
244 " [\n"
245 " 1,\n"
t/helper/test-regex.c
+2 -2
@@ -20,8 +20,8 @@ static struct reg_flag reg_flags[] = {
20
21 static int test_regex_bug(void)
22 {
23 - char *pat = "[^={} \t]+";
24 - char *str = "={}\nfred";
23 + const char *pat = "[^={} \t]+";
24 + const char *str = "={}\nfred";
25 regex_t r;
26 regmatch_t m[1];
27
t/helper/test-rot13-filter.c
+3 -2
@@ -136,7 +136,7 @@ static void free_delay_entries(void)
136 strmap_clear(&delay, 0);
137 }
138
139 -static void add_delay_entry(char *pathname, int count, int requested)
139 +static void add_delay_entry(const char *pathname, int count, int requested)
140 {
141 struct delay_entry *entry = xcalloc(1, sizeof(*entry));
142 entry->count = count;
@@ -189,7 +189,8 @@ static void reply_list_available_blobs_cmd(void)
189 static void command_loop(void)
190 {
191 for (;;) {
192 - char *buf, *output;
192 + char *buf;
193 + const char *output;
194 char *pathname;
195 struct delay_entry *entry;
196 struct strbuf input = STRBUF_INIT;
t/unit-tests/t-strbuf.c
+6 -4
@@ -2,7 +2,8 @@
2 #include "strbuf.h"
3
4 /* wrapper that supplies tests with an empty, initialized strbuf */
5 -static void setup(void (*f)(struct strbuf*, void*), void *data)
5 +static void setup(void (*f)(struct strbuf*, const void*),
6 + const void *data)
7 {
8 struct strbuf buf = STRBUF_INIT;
9
@@ -13,7 +14,8 @@ static void setup(void (*f)(struct strbuf*, void*), void *data)
14 }
15
16 /* wrapper that supplies tests with a populated, initialized strbuf */
16 -static void setup_populated(void (*f)(struct strbuf*, void*), char *init_str, void *data)
17 +static void setup_populated(void (*f)(struct strbuf*, const void*),
18 + const char *init_str, const void *data)
19 {
20 struct strbuf buf = STRBUF_INIT;
21
@@ -64,7 +66,7 @@ static void t_dynamic_init(void)
66 strbuf_release(&buf);
67 }
68
67 -static void t_addch(struct strbuf *buf, void *data)
69 +static void t_addch(struct strbuf *buf, const void *data)
70 {
71 const char *p_ch = data;
72 const char ch = *p_ch;
@@ -83,7 +85,7 @@ static void t_addch(struct strbuf *buf, void *data)
85 check_char(buf->buf[buf->len], ==, '\0');
86 }
87
86 -static void t_addstr(struct strbuf *buf, void *data)
88 +static void t_addstr(struct strbuf *buf, const void *data)
89 {
90 const char *text = data;
91 size_t len = strlen(text);
trailer.c
+1 -1
@@ -63,7 +63,7 @@ struct arg_item {
63
64 static LIST_HEAD(conf_head);
65
66 -static char *separators = ":";
66 +static const char *separators = ":";
67
68 static int configured;
69
wt-status.c
+1 -1
@@ -2408,7 +2408,7 @@ static void wt_porcelain_v2_print_unmerged_entry(
2408 int mode;
2409 struct object_id oid;
2410 } stages[3];
2411 - char *key;
2411 + const char *key;
2412 char submodule_token[5];
2413 char unmerged_prefix = 'u';
2414 char eol_char = s->null_termination ? '\0' : '\n';