[08/27] lib: fwts_stringextras: fix some missing constifictions
diff mbox series

Message ID 20180815131129.24146-9-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>

Fix up const pointer build warnings

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

Comments

Alex Hung Aug. 15, 2018, 5:55 p.m. UTC | #1
On 2018-08-15 06:11 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Fix up const pointer build warnings
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/include/fwts_stringextras.h | 2 +-
>   src/lib/src/fwts_stringextras.c     | 8 ++++----
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/lib/include/fwts_stringextras.h b/src/lib/include/fwts_stringextras.h
> index fba6688f..cd5fa822 100644
> --- a/src/lib/include/fwts_stringextras.h
> +++ b/src/lib/include/fwts_stringextras.h
> @@ -24,7 +24,7 @@
>   
>   void fwts_chop_newline(char *str);
>   char *fwts_realloc_strcat(char *orig, const char *newstr);
> -char *fwts_string_endswith(const char *str, const char *postfix);
> +const char *fwts_string_endswith(const char *str, const char *postfix);
>   void fwts_memcpy_unaligned(void *dst, const void *src, size_t n);
>   
>   #endif
> diff --git a/src/lib/src/fwts_stringextras.c b/src/lib/src/fwts_stringextras.c
> index a9b4c7cd..1f22224d 100644
> --- a/src/lib/src/fwts_stringextras.c
> +++ b/src/lib/src/fwts_stringextras.c
> @@ -80,7 +80,7 @@ char *fwts_realloc_strcat(char *orig, const char *newstr)
>    * see if str ends with postfix
>    * return NULL if fails, otherwise return the matched substring
>    */
> -char* fwts_string_endswith(const char *str, const char *postfix)
> +const char *fwts_string_endswith(const char *str, const char *postfix)
>   {
>   	size_t sl, pl;
>   
> @@ -88,7 +88,7 @@ char* fwts_string_endswith(const char *str, const char *postfix)
>   	pl = strlen(postfix);
>   
>   	if (pl == 0)
> -		return (char*) str + sl;
> +		return str + sl;
>   
>   	if (sl < pl)
>   		return NULL;
> @@ -96,7 +96,7 @@ char* fwts_string_endswith(const char *str, const char *postfix)
>   	if (memcmp(str + sl - pl, postfix, pl) != 0)
>   		return NULL;
>   
> -	return (char*) str + sl - pl;
> +	return str + sl - pl;
>   }
>   
>   /*
> @@ -111,5 +111,5 @@ void fwts_memcpy_unaligned(void *dst, const void *src, size_t n)
>   		return;
>   
>   	while (i--)
> -		((uint8_t*)dst)[i] = ((uint8_t*)src)[i];
> +		((uint8_t *)dst)[i] = ((const uint8_t *)src)[i];
>   }
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
ivanhu Aug. 16, 2018, 9:13 a.m. UTC | #2
On 08/15/2018 09:11 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Fix up const pointer build warnings
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/include/fwts_stringextras.h | 2 +-
>  src/lib/src/fwts_stringextras.c     | 8 ++++----
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/lib/include/fwts_stringextras.h b/src/lib/include/fwts_stringextras.h
> index fba6688f..cd5fa822 100644
> --- a/src/lib/include/fwts_stringextras.h
> +++ b/src/lib/include/fwts_stringextras.h
> @@ -24,7 +24,7 @@
>  
>  void fwts_chop_newline(char *str);
>  char *fwts_realloc_strcat(char *orig, const char *newstr);
> -char *fwts_string_endswith(const char *str, const char *postfix);
> +const char *fwts_string_endswith(const char *str, const char *postfix);
>  void fwts_memcpy_unaligned(void *dst, const void *src, size_t n);
>  
>  #endif
> diff --git a/src/lib/src/fwts_stringextras.c b/src/lib/src/fwts_stringextras.c
> index a9b4c7cd..1f22224d 100644
> --- a/src/lib/src/fwts_stringextras.c
> +++ b/src/lib/src/fwts_stringextras.c
> @@ -80,7 +80,7 @@ char *fwts_realloc_strcat(char *orig, const char *newstr)
>   * see if str ends with postfix
>   * return NULL if fails, otherwise return the matched substring
>   */
> -char* fwts_string_endswith(const char *str, const char *postfix)
> +const char *fwts_string_endswith(const char *str, const char *postfix)
>  {
>  	size_t sl, pl;
>  
> @@ -88,7 +88,7 @@ char* fwts_string_endswith(const char *str, const char *postfix)
>  	pl = strlen(postfix);
>  
>  	if (pl == 0)
> -		return (char*) str + sl;
> +		return str + sl;
>  
>  	if (sl < pl)
>  		return NULL;
> @@ -96,7 +96,7 @@ char* fwts_string_endswith(const char *str, const char *postfix)
>  	if (memcmp(str + sl - pl, postfix, pl) != 0)
>  		return NULL;
>  
> -	return (char*) str + sl - pl;
> +	return str + sl - pl;
>  }
>  
>  /*
> @@ -111,5 +111,5 @@ void fwts_memcpy_unaligned(void *dst, const void *src, size_t n)
>  		return;
>  
>  	while (i--)
> -		((uint8_t*)dst)[i] = ((uint8_t*)src)[i];
> +		((uint8_t *)dst)[i] = ((const uint8_t *)src)[i];
>  }

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

Patch
diff mbox series

diff --git a/src/lib/include/fwts_stringextras.h b/src/lib/include/fwts_stringextras.h
index fba6688f..cd5fa822 100644
--- a/src/lib/include/fwts_stringextras.h
+++ b/src/lib/include/fwts_stringextras.h
@@ -24,7 +24,7 @@ 
 
 void fwts_chop_newline(char *str);
 char *fwts_realloc_strcat(char *orig, const char *newstr);
-char *fwts_string_endswith(const char *str, const char *postfix);
+const char *fwts_string_endswith(const char *str, const char *postfix);
 void fwts_memcpy_unaligned(void *dst, const void *src, size_t n);
 
 #endif
diff --git a/src/lib/src/fwts_stringextras.c b/src/lib/src/fwts_stringextras.c
index a9b4c7cd..1f22224d 100644
--- a/src/lib/src/fwts_stringextras.c
+++ b/src/lib/src/fwts_stringextras.c
@@ -80,7 +80,7 @@  char *fwts_realloc_strcat(char *orig, const char *newstr)
  * see if str ends with postfix
  * return NULL if fails, otherwise return the matched substring
  */
-char* fwts_string_endswith(const char *str, const char *postfix)
+const char *fwts_string_endswith(const char *str, const char *postfix)
 {
 	size_t sl, pl;
 
@@ -88,7 +88,7 @@  char* fwts_string_endswith(const char *str, const char *postfix)
 	pl = strlen(postfix);
 
 	if (pl == 0)
-		return (char*) str + sl;
+		return str + sl;
 
 	if (sl < pl)
 		return NULL;
@@ -96,7 +96,7 @@  char* fwts_string_endswith(const char *str, const char *postfix)
 	if (memcmp(str + sl - pl, postfix, pl) != 0)
 		return NULL;
 
-	return (char*) str + sl - pl;
+	return str + sl - pl;
 }
 
 /*
@@ -111,5 +111,5 @@  void fwts_memcpy_unaligned(void *dst, const void *src, size_t n)
 		return;
 
 	while (i--)
-		((uint8_t*)dst)[i] = ((uint8_t*)src)[i];
+		((uint8_t *)dst)[i] = ((const uint8_t *)src)[i];
 }