[SLOF] [PATCH] libc: The arguments of puts() can be marked as "const"

Alexey Kardashevskiy aik at ozlabs.ru
Thu Jun 8 16:12:07 AEST 2017


On 07/06/17 19:41, Thomas Huth wrote:
> puts() does not change the string, so the parameter can be "const".
> 
> Signed-off-by: Thomas Huth <thuth at redhat.com>

Thanks, applied.


While you are fixing stuff like this, I started getting:

/home/aik/p/slof/slof/paflof.c: In function ‘engine’:
/home/aik/p/slof/slof/paflof.c:84:23: warning: array subscript is below
array bounds [-Warray-bounds]
   dp = the_data_stack - 1;
        ~~~~~~~~~~~~~~~^~~
/home/aik/p/slof/slof/paflof.c:85:22: warning: array subscript is below
array bounds [-Warray-bounds]
   rp = handler_stack - 1;
        ~~~~~~~~~~~~~~^~~


with gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1) from Fedora24/BE.

Can you please take a look on this? Thanks.


> ---
>  lib/libc/include/stdio.h | 2 +-
>  lib/libc/stdio/puts.c    | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/libc/include/stdio.h b/lib/libc/include/stdio.h
> index 84cddea..c54528f 100644
> --- a/lib/libc/include/stdio.h
> +++ b/lib/libc/include/stdio.h
> @@ -51,7 +51,7 @@ int setvbuf(FILE *stream, char *buf, int mode , size_t size);
>  
>  int putc(int ch, FILE *stream);
>  int putchar(int ch);
> -int puts(char *str);
> +int puts(const char *str);
>  
>  int scanf(const char *format, ...)  __attribute__((format (scanf, 1, 2)));
>  int fscanf(FILE *stream, const char *format, ...) __attribute__((format (scanf, 2, 3)));
> diff --git a/lib/libc/stdio/puts.c b/lib/libc/stdio/puts.c
> index 3f48dbf..9a93008 100644
> --- a/lib/libc/stdio/puts.c
> +++ b/lib/libc/stdio/puts.c
> @@ -17,7 +17,7 @@
>  
>  
>  int
> -puts(char *str)
> +puts(const char *str)
>  {
>  	int ret;
>  
> 


-- 
Alexey


More information about the SLOF mailing list