Re: [Linuxptp-devel] [PATCH RFC 02/30] config: Constify the public interface.

2020-02-18 Thread Jacob Keller
On 2/11/2020 6:03 AM, Richard Cochran wrote:
> 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.
> 


Makes sense. Using const in more places like this is great! It helps
make behavior explicit.

> 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: */
> 


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PATCH RFC 02/30] config: Constify the public interface.

2020-02-11 Thread Richard Cochran
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 
---
 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: */
-- 
2.20.1



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel