ACK: [PATCH 08/27] lib: fwts_stringextras: fix some missing constifictions
Alex Hung
alex.hung at canonical.com
Wed Aug 15 17:55:19 UTC 2018
On 2018-08-15 06:11 AM, 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: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list