From 831f7e073b7ff8dd01e87495c6dc15e31fe8a387 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 9 Feb 2020 07:17:08 -0800 Subject: [PATCH] config: Constify the public interface. The two methods, config_create_interface and config_read, never modify the strings passed in. This patch adds the const keyword to ensure these functions stay that way. Signed-off-by: Richard Cochran Reviewed-by: Jacob Keller --- config.c | 4 ++-- config.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 12eb1f9..65afa70 100644 --- a/config.c +++ b/config.c @@ -710,7 +710,7 @@ static struct option *config_alloc_longopts(void) return opts; } -int config_read(char *name, struct config *cfg) +int config_read(const char *name, struct config *cfg) { enum config_section current_section = UNKNOWN_SECTION; enum parser_result parser_res; @@ -817,7 +817,7 @@ parse_error: return -2; } -struct interface *config_create_interface(char *name, struct config *cfg) +struct interface *config_create_interface(const char *name, struct config *cfg) { struct interface *iface; diff --git a/config.h b/config.h index f237fb2..e27d3e2 100644 --- a/config.h +++ b/config.h @@ -60,8 +60,8 @@ struct config { STAILQ_HEAD(ucmtab_head, unicast_master_table) unicast_master_tables; }; -int config_read(char *name, struct config *cfg); -struct interface *config_create_interface(char *name, struct config *cfg); +int config_read(const char *name, struct config *cfg); +struct interface *config_create_interface(const char *name, struct config *cfg); void config_destroy(struct config *cfg); /* New, hash table based methods: */