From 985f33e42c3626233fdee8b0bfacaa96d2c4d305 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 4 Jan 2021 02:19:45 +0800 Subject: [PATCH] time.h: Sprinkle strftime format attribute Signed-off-by: Xiang Xiao --- include/nuttx/compiler.h | 5 +++++ include/time.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index f6779a7d0e..a42db0352c 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -155,6 +155,7 @@ # define printflike(a, b) __attribute__((__format__ (__printf__, a, b))) # define sysloglike(a, b) __attribute__((__format__ (__syslog__, a, b))) # define scanflike(a, b) __attribute__((__format__ (__scanf__, a, b))) +# define strftimelike(a) __attribute__((__format__ (__strftime__, a, 0))) /* GCC does not use storage classes to qualify addressing */ @@ -374,6 +375,7 @@ # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) +# define strftimelike(a) /* The reentrant attribute informs SDCC that the function * must be reentrant. In this case, SDCC will store input @@ -504,6 +506,7 @@ # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) +# define strftimelike(a) /* REVISIT: */ @@ -607,6 +610,7 @@ # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) +# define strftimelike(a) # define FAR # define NEAR @@ -665,6 +669,7 @@ # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) +# define strftimelike(a) # define FAR # define NEAR diff --git a/include/time.h b/include/time.h index d8c08d1795..7d0e0219b1 100644 --- a/include/time.h +++ b/include/time.h @@ -215,7 +215,7 @@ FAR struct tm *localtime(FAR const time_t *timep); FAR struct tm *localtime_r(FAR const time_t *timep, FAR struct tm *result); size_t strftime(FAR char *s, size_t max, FAR const char *format, - FAR const struct tm *tm); + FAR const struct tm *tm) strftimelike(3); FAR char *asctime(FAR const struct tm *tp); FAR char *asctime_r(FAR const struct tm *tp, FAR char *buf);