attr.c: tighten constness around "git_attr" structure

It holds an interned string, and git_attr_name() is a way to peek
into it.  Make sure the involved pointer types are pointer-to-const.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2017-01-27 18:01:48 -08:00
parent 4b0c696167
commit ec4d77aa50
2 changed files with 3 additions and 3 deletions

2
attr.c
View File

@ -43,7 +43,7 @@ static int cannot_trust_maybe_real;
static struct git_attr_check *check_all_attr; static struct git_attr_check *check_all_attr;
static struct git_attr *(git_attr_hash[HASHSIZE]); static struct git_attr *(git_attr_hash[HASHSIZE]);
char *git_attr_name(struct git_attr *attr) const char *git_attr_name(const struct git_attr *attr)
{ {
return attr->name; return attr->name;
} }

4
attr.h
View File

@ -25,7 +25,7 @@ extern const char git_attr__false[];
* Unset one is returned as NULL. * Unset one is returned as NULL.
*/ */
struct git_attr_check { struct git_attr_check {
struct git_attr *attr; const struct git_attr *attr;
const char *value; const char *value;
}; };
@ -34,7 +34,7 @@ struct git_attr_check {
* return value is a pointer to a null-delimited string that is part * return value is a pointer to a null-delimited string that is part
* of the internal data structure; it should not be modified or freed. * of the internal data structure; it should not be modified or freed.
*/ */
char *git_attr_name(struct git_attr *); extern const char *git_attr_name(const struct git_attr *);
int git_check_attr(const char *path, int, struct git_attr_check *); int git_check_attr(const char *path, int, struct git_attr_check *);