Commit fda3525ecfaa5f1d603ab52254172b68ad177ed1

Stefan Sperling 2021-09-25T10:23:12

mark some function parameters as 'const', as they should be; patch by Omar Polo

diff --git a/lib/gitconfig.c b/lib/gitconfig.c
index 9b99340..a5c2c23 100644
--- a/lib/gitconfig.c
+++ b/lib/gitconfig.c
@@ -103,7 +103,7 @@ struct got_gitconfig {
 };
 
 static __inline__ u_int8_t
-conf_hash(char *s)
+conf_hash(const char *s)
 {
 	u_int8_t hash = 0;
 
@@ -438,8 +438,8 @@ fail:
  * if that tag does not exist.
  */
 int
-got_gitconfig_get_num(struct got_gitconfig *conf, char *section, char *tag,
-    int def)
+got_gitconfig_get_num(struct got_gitconfig *conf, const char *section,
+    const char *tag, int def)
 {
 	char	*value = got_gitconfig_get_str(conf, section, tag);
 
@@ -477,7 +477,8 @@ got_gitconfig_match_num(struct got_gitconfig *conf, char *section, char *tag,
 
 /* Return the string value denoted by TAG in section SECTION.  */
 char *
-got_gitconfig_get_str(struct got_gitconfig *conf, char *section, char *tag)
+got_gitconfig_get_str(struct got_gitconfig *conf, const char *section,
+    const char *tag)
 {
 	struct got_gitconfig_binding *cb;
 
@@ -605,7 +606,7 @@ cleanup:
 }
 
 struct got_gitconfig_list *
-got_gitconfig_get_tag_list(struct got_gitconfig *conf, char *section)
+got_gitconfig_get_tag_list(struct got_gitconfig *conf, const char *section)
 {
 	struct got_gitconfig_list *list = 0;
 	struct got_gitconfig_list_node *node = 0;
diff --git a/lib/got_lib_gitconfig.h b/lib/got_lib_gitconfig.h
index 615d269..7bfbb24 100644
--- a/lib/got_lib_gitconfig.h
+++ b/lib/got_lib_gitconfig.h
@@ -43,11 +43,12 @@ const struct got_error *got_gitconfig_get_section_list(
     struct got_gitconfig_list **, struct got_gitconfig *);
 struct got_gitconfig_list *got_gitconfig_get_list(struct got_gitconfig *,
     char *, char *);
-struct got_gitconfig_list *got_gitconfig_get_tag_list(struct got_gitconfig *, char *);
-int got_gitconfig_get_num(struct got_gitconfig *, char *, char *,
+struct got_gitconfig_list *got_gitconfig_get_tag_list(struct got_gitconfig *,
+    const char *);
+int got_gitconfig_get_num(struct got_gitconfig *, const char *, const char *,
     int);
-char *got_gitconfig_get_str(struct got_gitconfig *, char *,
-    char *);
+char *got_gitconfig_get_str(struct got_gitconfig *, const char *,
+    const char *);
 const struct got_error *got_gitconfig_open(struct got_gitconfig **, int);
 void got_gitconfig_close(struct got_gitconfig *);
 int      got_gitconfig_match_num(struct got_gitconfig *, char *, char *, int);
diff --git a/libexec/got-read-gitconfig/got-read-gitconfig.c b/libexec/got-read-gitconfig/got-read-gitconfig.c
index 3ce93f0..a7d8b89 100644
--- a/libexec/got-read-gitconfig/got-read-gitconfig.c
+++ b/libexec/got-read-gitconfig/got-read-gitconfig.c
@@ -59,7 +59,7 @@ send_gitconfig_int(struct imsgbuf *ibuf, int value)
 
 static const struct got_error *
 gitconfig_num_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig,
-    char *section, char *tag, int def)
+    const char *section, const char *tag, int def)
 {
 	int value;
 
@@ -84,7 +84,7 @@ send_gitconfig_str(struct imsgbuf *ibuf, const char *value)
 
 static const struct got_error *
 gitconfig_str_request(struct imsgbuf *ibuf, struct got_gitconfig *gitconfig,
-    char *section, char *tag)
+    const char *section, const char *tag)
 {
 	char *value;