diff mbox series

[03/27] lib: fwts_framework: argument 'arg' should not be const

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

Commit Message

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

The argument 'arg' is currently const which is not correct as it
can be modified by strtok. Remove this unwanted keyword.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_framework.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 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>
> 
> The argument 'arg' is currently const which is not correct as it
> can be modified by strtok. Remove this unwanted keyword.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_framework.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 47299ef4..bedc1ee9 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -999,12 +999,12 @@ static fwts_framework_test *fwts_framework_skip_test(fwts_framework_test *test)
>    *  fwts_framework_skip_test_parse()
>    *	parse optarg of comma separated list of tests to skip
>    */
> -static int fwts_framework_skip_test_parse(const char *arg)
> +static int fwts_framework_skip_test_parse(char *arg)
>   {
>   	char *str;
>   	char *token;
>   
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		fwts_framework_test *test;
>   
>   		if ((test = fwts_framework_test_find(token)) == NULL) {
> @@ -1017,12 +1017,12 @@ static int fwts_framework_skip_test_parse(const char *arg)
>   	return FWTS_OK;
>   }
>   
> -static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
> +static int fwts_framework_filter_error_parse(char *arg, fwts_list *list)
>   {
>   	char *str;
>   	char *token;
>   
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		if (fwts_list_append(list, token) == NULL) {
>   			fprintf(stderr, "Out of memory parsing argument %s\n", arg);
>   			fwts_list_free_items(list, NULL);
> @@ -1037,14 +1037,14 @@ static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
>    *  fwts_framework_log_type_parse()
>    *	parse optarg of comma separated log types
>    */
> -static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
> +static int fwts_framework_log_type_parse(fwts_framework *fw, char *arg)
>   {
>   	char *str;
>   	char *token;
>   
>   	fw->log_type = 0;
>   
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		if (!strcmp(token, "plaintext"))
>   			fw->log_type |= LOG_TYPE_PLAINTEXT;
>   		else if (!strcmp(token, "json"))
> @@ -1069,14 +1069,14 @@ static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
>    *  fwts_framework_acpica_parse()
>    *	parse optarg of comma separated acpica mode flags
>    */
> -static int fwts_framework_acpica_parse(fwts_framework *fw, const char *arg)
> +static int fwts_framework_acpica_parse(fwts_framework *fw, char *arg)
>   {
>   	char *str;
>   	char *token;
>   
>   	fw->acpica_mode = 0;
>   
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>   		if (!strcmp(token, "serialized"))
>   			fw->acpica_mode |= FWTS_ACPICA_MODE_SERIALIZED;
>   		else if (!strcmp(token, "slack"))
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu Aug. 16, 2018, 9:11 a.m. UTC | #2
On 08/15/2018 09:11 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The argument 'arg' is currently const which is not correct as it
> can be modified by strtok. Remove this unwanted keyword.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_framework.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
> index 47299ef4..bedc1ee9 100644
> --- a/src/lib/src/fwts_framework.c
> +++ b/src/lib/src/fwts_framework.c
> @@ -999,12 +999,12 @@ static fwts_framework_test *fwts_framework_skip_test(fwts_framework_test *test)
>   *  fwts_framework_skip_test_parse()
>   *	parse optarg of comma separated list of tests to skip
>   */
> -static int fwts_framework_skip_test_parse(const char *arg)
> +static int fwts_framework_skip_test_parse(char *arg)
>  {
>  	char *str;
>  	char *token;
>  
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>  		fwts_framework_test *test;
>  
>  		if ((test = fwts_framework_test_find(token)) == NULL) {
> @@ -1017,12 +1017,12 @@ static int fwts_framework_skip_test_parse(const char *arg)
>  	return FWTS_OK;
>  }
>  
> -static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
> +static int fwts_framework_filter_error_parse(char *arg, fwts_list *list)
>  {
>  	char *str;
>  	char *token;
>  
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>  		if (fwts_list_append(list, token) == NULL) {
>  			fprintf(stderr, "Out of memory parsing argument %s\n", arg);
>  			fwts_list_free_items(list, NULL);
> @@ -1037,14 +1037,14 @@ static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
>   *  fwts_framework_log_type_parse()
>   *	parse optarg of comma separated log types
>   */
> -static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
> +static int fwts_framework_log_type_parse(fwts_framework *fw, char *arg)
>  {
>  	char *str;
>  	char *token;
>  
>  	fw->log_type = 0;
>  
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>  		if (!strcmp(token, "plaintext"))
>  			fw->log_type |= LOG_TYPE_PLAINTEXT;
>  		else if (!strcmp(token, "json"))
> @@ -1069,14 +1069,14 @@ static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
>   *  fwts_framework_acpica_parse()
>   *	parse optarg of comma separated acpica mode flags
>   */
> -static int fwts_framework_acpica_parse(fwts_framework *fw, const char *arg)
> +static int fwts_framework_acpica_parse(fwts_framework *fw, char *arg)
>  {
>  	char *str;
>  	char *token;
>  
>  	fw->acpica_mode = 0;
>  
> -	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
> +	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
>  		if (!strcmp(token, "serialized"))
>  			fw->acpica_mode |= FWTS_ACPICA_MODE_SERIALIZED;
>  		else if (!strcmp(token, "slack"))
Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index 47299ef4..bedc1ee9 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -999,12 +999,12 @@  static fwts_framework_test *fwts_framework_skip_test(fwts_framework_test *test)
  *  fwts_framework_skip_test_parse()
  *	parse optarg of comma separated list of tests to skip
  */
-static int fwts_framework_skip_test_parse(const char *arg)
+static int fwts_framework_skip_test_parse(char *arg)
 {
 	char *str;
 	char *token;
 
-	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
+	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
 		fwts_framework_test *test;
 
 		if ((test = fwts_framework_test_find(token)) == NULL) {
@@ -1017,12 +1017,12 @@  static int fwts_framework_skip_test_parse(const char *arg)
 	return FWTS_OK;
 }
 
-static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
+static int fwts_framework_filter_error_parse(char *arg, fwts_list *list)
 {
 	char *str;
 	char *token;
 
-	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
+	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
 		if (fwts_list_append(list, token) == NULL) {
 			fprintf(stderr, "Out of memory parsing argument %s\n", arg);
 			fwts_list_free_items(list, NULL);
@@ -1037,14 +1037,14 @@  static int fwts_framework_filter_error_parse(const char *arg, fwts_list *list)
  *  fwts_framework_log_type_parse()
  *	parse optarg of comma separated log types
  */
-static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
+static int fwts_framework_log_type_parse(fwts_framework *fw, char *arg)
 {
 	char *str;
 	char *token;
 
 	fw->log_type = 0;
 
-	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
+	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
 		if (!strcmp(token, "plaintext"))
 			fw->log_type |= LOG_TYPE_PLAINTEXT;
 		else if (!strcmp(token, "json"))
@@ -1069,14 +1069,14 @@  static int fwts_framework_log_type_parse(fwts_framework *fw, const char *arg)
  *  fwts_framework_acpica_parse()
  *	parse optarg of comma separated acpica mode flags
  */
-static int fwts_framework_acpica_parse(fwts_framework *fw, const char *arg)
+static int fwts_framework_acpica_parse(fwts_framework *fw, char *arg)
 {
 	char *str;
 	char *token;
 
 	fw->acpica_mode = 0;
 
-	for (str = (char*)arg; (token = strtok(str, ",")) != NULL; str = NULL) {
+	for (str = arg; (token = strtok(str, ",")) != NULL; str = NULL) {
 		if (!strcmp(token, "serialized"))
 			fw->acpica_mode |= FWTS_ACPICA_MODE_SERIALIZED;
 		else if (!strcmp(token, "slack"))