[04/27] lib: fwts_log: remove const arg in fwts_log_set_field_filter
diff mbox series

Message ID 20180815131129.24146-5-colin.king@canonical.com
State Accepted
Headers show
Series
  • [01/27] lib: fwts_framework: ensure src pointer is const
Related show

Commit Message

Colin King Aug. 15, 2018, 1:11 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Argument str should not be const as strtok_r can modify it; remove
the const.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/include/fwts_log.h | 2 +-
 src/lib/src/fwts_log.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Alex Hung Aug. 15, 2018, 5:54 p.m. UTC | #1
On 2018-08-15 06:11 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Argument str should not be const as strtok_r can modify it; remove
> the const.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_log.h | 2 +-
>   src/lib/src/fwts_log.c     | 4 ++--
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lib/include/fwts_log.h b/src/lib/include/fwts_log.h
> index 0ddcf76f..e9da27b3 100644
> --- a/src/lib/include/fwts_log.h
> +++ b/src/lib/include/fwts_log.h
> @@ -129,7 +129,7 @@ int       fwts_log_printf(const fwts_framework *fw, const fwts_log_field field,
>   	__attribute__((format(printf, 7, 8)));
>   void      fwts_log_newline(fwts_log *log);
>   void      fwts_log_underline(fwts_log *log, const int ch);
> -void      fwts_log_set_field_filter(const char *str);
> +void      fwts_log_set_field_filter(char *str);
>   int       fwts_log_set_owner(fwts_log *log, const char *owner);
>   void      fwts_log_set_format(const char *str);
>   void      fwts_log_print_fields(void);
> diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
> index 32406f30..5a7151ec 100644
> --- a/src/lib/src/fwts_log.c
> +++ b/src/lib/src/fwts_log.c
> @@ -274,7 +274,7 @@ void fwts_log_filter_unset_field(const fwts_log_field filter)
>    *	list of field names. ~ or ^ prefix to a field name
>    *	clears a bit.
>    */
> -void fwts_log_set_field_filter(const char *str)
> +void fwts_log_set_field_filter(char *str)
>   {
>   	char *saveptr;
>   	fwts_log_field field;
> @@ -282,7 +282,7 @@ void fwts_log_set_field_filter(const char *str)
>   	for (;; str=NULL) {
>   		char *token;
>   
> -		if ((token = strtok_r((char*)str, ",|", &saveptr)) == NULL)
> +		if ((token = strtok_r(str, ",|", &saveptr)) == NULL)
>   			break;
>   		if (*token == '^' || *token == '~') {
>   			field = fwts_log_str_to_field(token+1);
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Aug. 16, 2018, 9:12 a.m. UTC | #2
On 08/15/2018 09:11 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Argument str should not be const as strtok_r can modify it; remove
> the const.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts_log.h | 2 +-
>  src/lib/src/fwts_log.c     | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/include/fwts_log.h b/src/lib/include/fwts_log.h
> index 0ddcf76f..e9da27b3 100644
> --- a/src/lib/include/fwts_log.h
> +++ b/src/lib/include/fwts_log.h
> @@ -129,7 +129,7 @@ int       fwts_log_printf(const fwts_framework *fw, const fwts_log_field field,
>  	__attribute__((format(printf, 7, 8)));
>  void      fwts_log_newline(fwts_log *log);
>  void      fwts_log_underline(fwts_log *log, const int ch);
> -void      fwts_log_set_field_filter(const char *str);
> +void      fwts_log_set_field_filter(char *str);
>  int       fwts_log_set_owner(fwts_log *log, const char *owner);
>  void      fwts_log_set_format(const char *str);
>  void      fwts_log_print_fields(void);
> diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
> index 32406f30..5a7151ec 100644
> --- a/src/lib/src/fwts_log.c
> +++ b/src/lib/src/fwts_log.c
> @@ -274,7 +274,7 @@ void fwts_log_filter_unset_field(const fwts_log_field filter)
>   *	list of field names. ~ or ^ prefix to a field name
>   *	clears a bit.
>   */
> -void fwts_log_set_field_filter(const char *str)
> +void fwts_log_set_field_filter(char *str)
>  {
>  	char *saveptr;
>  	fwts_log_field field;
> @@ -282,7 +282,7 @@ void fwts_log_set_field_filter(const char *str)
>  	for (;; str=NULL) {
>  		char *token;
>  
> -		if ((token = strtok_r((char*)str, ",|", &saveptr)) == NULL)
> +		if ((token = strtok_r(str, ",|", &saveptr)) == NULL)
>  			break;
>  		if (*token == '^' || *token == '~') {
>  			field = fwts_log_str_to_field(token+1);

Acked-by: Ivan Hu <ivan.hu@canonical.com>

Patch
diff mbox series

diff --git a/src/lib/include/fwts_log.h b/src/lib/include/fwts_log.h
index 0ddcf76f..e9da27b3 100644
--- a/src/lib/include/fwts_log.h
+++ b/src/lib/include/fwts_log.h
@@ -129,7 +129,7 @@  int       fwts_log_printf(const fwts_framework *fw, const fwts_log_field field,
 	__attribute__((format(printf, 7, 8)));
 void      fwts_log_newline(fwts_log *log);
 void      fwts_log_underline(fwts_log *log, const int ch);
-void      fwts_log_set_field_filter(const char *str);
+void      fwts_log_set_field_filter(char *str);
 int       fwts_log_set_owner(fwts_log *log, const char *owner);
 void      fwts_log_set_format(const char *str);
 void      fwts_log_print_fields(void);
diff --git a/src/lib/src/fwts_log.c b/src/lib/src/fwts_log.c
index 32406f30..5a7151ec 100644
--- a/src/lib/src/fwts_log.c
+++ b/src/lib/src/fwts_log.c
@@ -274,7 +274,7 @@  void fwts_log_filter_unset_field(const fwts_log_field filter)
  *	list of field names. ~ or ^ prefix to a field name
  *	clears a bit.
  */
-void fwts_log_set_field_filter(const char *str)
+void fwts_log_set_field_filter(char *str)
 {
 	char *saveptr;
 	fwts_log_field field;
@@ -282,7 +282,7 @@  void fwts_log_set_field_filter(const char *str)
 	for (;; str=NULL) {
 		char *token;
 
-		if ((token = strtok_r((char*)str, ",|", &saveptr)) == NULL)
+		if ((token = strtok_r(str, ",|", &saveptr)) == NULL)
 			break;
 		if (*token == '^' || *token == '~') {
 			field = fwts_log_str_to_field(token+1);