summaryrefslogtreecommitdiff
path: root/commit.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-06-07 08:39:03 +0200
committerJunio C Hamano <gitster@pobox.com>2024-06-07 10:30:53 -0700
commita3da6948c3b6c272bf7a381b86df9a60bdf2b052 (patch)
tree46e9d2f2133e5958dc3c4f2a9d1dd94fe5565b22 /commit.h
parent5bd0851d97be732470eab8cb8d7255c7050ef384 (diff)
remote-curl: avoid assigning string constant to non-const variable
When processing remote options, we split the option line into two by searching for a space. If there is one, we replace the space with '\0', otherwise we implicitly assume that the value is "true" and thus assign a string constant. As the return value of strchr(3P) weirdly enough is a `char *` even though it gets a `const char *` as input, the assigned-to variable also is a non-constant. This is fine though because the argument is in fact an allocated string, and thus we are allowed to modify it. But this will break once we enable `-Wwrite-strings`. Refactor the code stop splitting the fields with '\0' altogether. Instead, we can pass the length of the option name to `set_option()` and then use strncmp(3P) instead of strcmp(3P). Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.h')
0 files changed, 0 insertions, 0 deletions