From c32cc5a08fbfef655dbffddf319869884b17215b Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Fri, 19 Jan 2018 20:11:33 +0100 Subject: [PATCH] Provide __{printf,scanf,strfmon,strftime}like() for builtin functions too. We want our formats checked in -fno-builtin builds as well. --- include/monetary.h | 3 ++- include/stdio.h | 24 +++++++++++++++--------- include/time.h | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/monetary.h b/include/monetary.h index 80464514be..aff85770c7 100644 --- a/include/monetary.h +++ b/include/monetary.h @@ -44,7 +44,8 @@ typedef __ssize_t ssize_t; __BEGIN_DECLS #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE -ssize_t strfmon(char * __restrict, size_t, const char * __restrict, ...); +ssize_t strfmon(char * __restrict, size_t, const char * __restrict, ...) + __strfmonlike(3, 4); #endif #if __POSIX_VISIBLE >= 200809 || defined(_XLOCALE_H_) diff --git a/include/stdio.h b/include/stdio.h index 9ccef53b34..05bb31257f 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -196,13 +196,15 @@ int fgetc(FILE *); int fgetpos(FILE * __restrict, fpos_t * __restrict); char *fgets(char * __restrict, int, FILE * __restrict); FILE *fopen(const char * __restrict, const char * __restrict); -int fprintf(FILE * __restrict, const char * __restrict, ...); +int fprintf(FILE * __restrict, const char * __restrict, ...) + __printflike(2, 3); int fputc(int, FILE *); int fputs(const char * __restrict, FILE * __restrict); size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict); -int fscanf(FILE * __restrict, const char * __restrict, ...); +int fscanf(FILE * __restrict, const char * __restrict, ...) + __scanflike(2, 3); int fseek(FILE *, long, int); int fsetpos(FILE *, const fpos_t *); long ftell(FILE *); @@ -211,24 +213,28 @@ int getc(FILE *); int getchar(void); char *gets(char *); void perror(const char *); -int printf(const char * __restrict, ...); +int printf(const char * __restrict, ...) __printflike(1, 2); int putc(int, FILE *); int putchar(int); int puts(const char *); int remove(const char *); int rename(const char *, const char *); void rewind(FILE *); -int scanf(const char * __restrict, ...); +int scanf(const char * __restrict, ...) __scanflike(1, 2); void setbuf(FILE * __restrict, char * __restrict); int setvbuf(FILE * __restrict, char * __restrict, int, size_t); -int sprintf(char * __restrict, const char * __restrict, ...); -int sscanf(const char * __restrict, const char * __restrict, ...); +int sprintf(char * __restrict, const char * __restrict, ...) + __printflike(2, 3); +int sscanf(const char * __restrict, const char * __restrict, ...) + __scanflike(2, 3); FILE *tmpfile(void); char *tmpnam(char *); int ungetc(int, FILE *); -int vfprintf(FILE * __restrict, const char * __restrict, __va_list); -int vprintf(const char * __restrict, __va_list); -int vsprintf(char * __restrict, const char * __restrict, __va_list); +int vfprintf(FILE * __restrict, const char * __restrict, __va_list) + __printflike(2, 0); +int vprintf(const char * __restrict, __va_list) __printflike(1, 0); +int vsprintf(char * __restrict, const char * __restrict, __va_list) + __printflike(2, 0); #if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500 int snprintf(char * __restrict, size_t, const char * __restrict, ...) diff --git a/include/time.h b/include/time.h index 94c2fd7863..63e6ae790f 100644 --- a/include/time.h +++ b/include/time.h @@ -165,7 +165,7 @@ struct tm *gmtime(const time_t *); struct tm *localtime(const time_t *); time_t mktime(struct tm *); size_t strftime(char * __restrict, size_t, const char * __restrict, - const struct tm * __restrict); + const struct tm * __restrict) __strftimelike(3, 0); time_t time(time_t *); #if __POSIX_VISIBLE -- 2.41.0