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

Thomas Huth thuth at redhat.com
Wed Jun 7 19:41:39 AEST 2017


puts() does not change the string, so the parameter can be "const".

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 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;
 
-- 
1.8.3.1



More information about the SLOF mailing list