[CLEANUP] add a few "const char *" where appropriate
As suggested by Markus Elfring, a few "const char *" have replaced
some "char *" declarations where a function is not expected to
modify a value. It does not change the code but it helps detecting
coding errors.
diff --git a/include/common/cfgparse.h b/include/common/cfgparse.h
index 591f172..e21c4c5 100644
--- a/include/common/cfgparse.h
+++ b/include/common/cfgparse.h
@@ -32,9 +32,9 @@
extern int cfg_maxpconn;
extern int cfg_maxconn;
-int cfg_parse_global(char *file, int linenum, char **args);
-int cfg_parse_listen(char *file, int linenum, char **args);
-int readcfgfile(char *file);
+int cfg_parse_global(const char *file, int linenum, char **args);
+int cfg_parse_listen(const char *file, int linenum, char **args);
+int readcfgfile(const char *file);
#endif /* _COMMON_CFGPARSE_H */
diff --git a/include/common/regex.h b/include/common/regex.h
index 05eae6b..bf51a0d 100644
--- a/include/common/regex.h
+++ b/include/common/regex.h
@@ -41,16 +41,17 @@
struct hdr_exp {
struct hdr_exp *next;
- regex_t *preg; /* expression to look for */
+ const regex_t *preg; /* expression to look for */
int action; /* ACT_ALLOW, ACT_REPLACE, ACT_REMOVE, ACT_DENY */
- char *replace; /* expression to set instead */
+ const char *replace; /* expression to set instead */
};
extern regmatch_t pmatch[MAX_MATCH];
-int exp_replace(char *dst, char *src, char *str, regmatch_t *matches);
-char *check_replace_string(char *str);
-char *chain_regex(struct hdr_exp **head, regex_t *preg, int action, char *replace);
+int exp_replace(char *dst, char *src, const char *str, const regmatch_t *matches);
+const char *check_replace_string(const char *str);
+const char *chain_regex(struct hdr_exp **head, const regex_t *preg,
+ int action, const char *replace);
#endif /* _COMMON_REGEX_H */
diff --git a/include/common/time.h b/include/common/time.h
index 7661aac..7a68a15 100644
--- a/include/common/time.h
+++ b/include/common/time.h
@@ -39,31 +39,31 @@
/*
* adds <ms> ms to <from>, set the result to <tv> and returns a pointer <tv>
*/
-struct timeval *tv_delayfrom(struct timeval *tv, struct timeval *from, int ms);
+struct timeval *tv_delayfrom(struct timeval *tv, const struct timeval *from, int ms);
/*
* compares <tv1> and <tv2> modulo 1ms: returns 0 if equal, -1 if tv1 < tv2, 1 if tv1 > tv2
* Must not be used when either argument is eternity. Use tv_cmp2_ms() for that.
*/
-int tv_cmp_ms(struct timeval *tv1, struct timeval *tv2);
+int tv_cmp_ms(const struct timeval *tv1, const struct timeval *tv2);
/*
* compares <tv1> and <tv2> : returns 0 if equal, -1 if tv1 < tv2, 1 if tv1 > tv2,
* considering that 0 is the eternity.
*/
-int tv_cmp2(struct timeval *tv1, struct timeval *tv2);
+int tv_cmp2(const struct timeval *tv1, const struct timeval *tv2);
/*
* compares <tv1> and <tv2> modulo 1 ms: returns 0 if equal, -1 if tv1 < tv2, 1 if tv1 > tv2,
* considering that 0 is the eternity.
*/
-int tv_cmp2_ms(struct timeval *tv1, struct timeval *tv2);
+int tv_cmp2_ms(const struct timeval *tv1, const struct timeval *tv2);
/*
* returns the remaining time between tv1=now and event=tv2
* if tv2 is passed, 0 is returned.
* Returns TIME_ETERNITY if tv2 is eternity.
*/
-unsigned long tv_remain2(struct timeval *tv1, struct timeval *tv2);
+unsigned long tv_remain2(const struct timeval *tv1, const struct timeval *tv2);
/* sets <tv> to the current time */
@@ -78,7 +78,7 @@
* compares <tv1> and <tv2> : returns 0 if equal, -1 if tv1 < tv2, 1 if tv1 > tv2
* Must not be used when either argument is eternity. Use tv_cmp2() for that.
*/
-static inline int tv_cmp(struct timeval *tv1, struct timeval *tv2)
+static inline int tv_cmp(const struct timeval *tv1, const struct timeval *tv2)
{
if (tv1->tv_sec < tv2->tv_sec)
return -1;
@@ -96,7 +96,7 @@
* returns the difference, in ms, between tv1 and tv2
* Must not be used when either argument is eternity.
*/
-static inline unsigned long tv_diff(struct timeval *tv1, struct timeval *tv2)
+static inline unsigned long tv_diff(const struct timeval *tv1, const struct timeval *tv2)
{
unsigned long ret;
@@ -113,7 +113,7 @@
* if tv2 is passed, 0 is returned.
* Must not be used when either argument is eternity.
*/
-static inline unsigned long tv_remain(struct timeval *tv1, struct timeval *tv2)
+static inline unsigned long tv_remain(const struct timeval *tv1, const struct timeval *tv2)
{
unsigned long ret;
@@ -142,7 +142,7 @@
/*
* returns 1 if tv is null, else 0
*/
-static inline int tv_iseternity(struct timeval *tv)
+static inline int tv_iseternity(const struct timeval *tv)
{
if (tv->tv_sec == 0 && tv->tv_usec == 0)
return 1;
@@ -154,8 +154,9 @@
* returns the first event between tv1 and tv2 into tvmin.
* a zero tv is ignored. tvmin is returned.
*/
-static inline struct timeval *tv_min(struct timeval *tvmin,
- struct timeval *tv1, struct timeval *tv2)
+static inline const struct timeval *tv_min(struct timeval *tvmin,
+ const struct timeval *tv1,
+ const struct timeval *tv2)
{
if (tv_cmp2(tv1, tv2) <= 0)