From 6c9eb475de4613d9039819c182c5e1b8e3980f28 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Thu, 6 Dec 2018 13:42:39 +0900 Subject: [PATCH] Apply __attribute__((format(printf..))) to internal __dlog_print() to check format even for variable arguments (...) format (printf, string-index, first-to-check) - string-index : format string index (starting from 1) - first-to-check : first argument index to be checked https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Function-Attributes.html#Function-Attributes Change-Id: I70ee2d0687c87b4f15f46dd962c249136d27709f Signed-off-by: Hyotaek Shim --- include/dlog-internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/dlog-internal.h b/include/dlog-internal.h index 7d5a327..b52e2e9 100644 --- a/include/dlog-internal.h +++ b/include/dlog-internal.h @@ -375,7 +375,8 @@ static inline int __dlog_no_print(const char *fmt __attribute__((unused)), ...) __dlog_print(LOG_ID_MAIN, DLOG_INFO, USR_TAG, "you must not use this API directly"); * @endcode */ -int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...); +#pragma GCC diagnostic error "-Wformat" +int __dlog_print(log_id_t log_id, int prio, const char *tag, const char *fmt, ...) __attribute__((format(printf, 4, 5))); /** * @internal -- 2.7.4