Commit d385845
config: store allocated string in non-const pointer
When git-config matches a url, we copy the variable section name and
store it in the "section" member of a urlmatch_config struct. That
member is const, since the url-matcher will not touch it (and other
callers really will have a const string).
But that means that we have only a const pointer to our allocated
string. We have to cast away the constness when we free it, and likewise
when we assign NUL to tie off the "." separating the subsection and key.
This latter happens implicitly via a strchr() call, but recent versions
of glibc have added annotations that let the compiler detect that and
complain.
Let's keep our own "section" pointer for the non-const string, and then
just point config.section at it. That avoids all of the casting, both
explicit and implicit.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 213b213 commit d385845
1 file changed
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
838 | 838 | | |
839 | 839 | | |
840 | 840 | | |
| 841 | + | |
841 | 842 | | |
842 | 843 | | |
843 | 844 | | |
| |||
851 | 852 | | |
852 | 853 | | |
853 | 854 | | |
854 | | - | |
855 | | - | |
| 855 | + | |
| 856 | + | |
856 | 857 | | |
857 | 858 | | |
858 | 859 | | |
| |||
886 | 887 | | |
887 | 888 | | |
888 | 889 | | |
889 | | - | |
| 890 | + | |
890 | 891 | | |
891 | 892 | | |
892 | 893 | | |
| |||
0 commit comments