ACK: [PATCH 08/27] lib: fwts_stringextras: fix some missing constifictions

ivanhu ivan.hu at canonical.com
Thu Aug 16 09:13:51 UTC 2018



On 08/15/2018 09:11 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Fix up const pointer build warnings
>
> Signed-off-by: Colin Ian King <colin.king at 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 at canonical.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20180816/fc7ab180/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20180816/fc7ab180/attachment.sig>


More information about the fwts-devel mailing list