attr.c: tighten constness around "git_attr" structure
authorJunio C Hamano <gitster@pobox.com>
Sat, 28 Jan 2017 02:01:48 +0000 (18:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Feb 2017 21:46:52 +0000 (13:46 -0800)
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>
attr.c
attr.h
diff --git a/attr.c b/attr.c
index e42f931b356d6b5869455f742a62447bdac3ca70..f7cf7ae3060fc401fe3a2c4c44c24c32915d4601 100644 (file)
--- a/attr.c
+++ b/attr.c
@@ -43,7 +43,7 @@ static int cannot_trust_maybe_real;
 static struct git_attr_check *check_all_attr;
 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;
 }
diff --git a/attr.h b/attr.h
index 8b08d33af84ebbb376a69d85f3db6c03eeb78a63..00d7a662c94885ae1cd38f82a351cdfc995f4bb8 100644 (file)
--- a/attr.h
+++ b/attr.h
@@ -25,7 +25,7 @@ extern const char git_attr__false[];
  * Unset one is returned as NULL.
  */
 struct git_attr_check {
-       struct git_attr *attr;
+       const struct git_attr *attr;
        const char *value;
 };
 
@@ -34,7 +34,7 @@ struct git_attr_check {
  * 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.
  */
-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 *);