Apply __attribute__((format(printf..))) to internal __dlog_print() 81/194581/2 submit/tizen/20181207.015822
authorHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 6 Dec 2018 04:42:39 +0000 (13:42 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 7 Dec 2018 01:53:58 +0000 (10:53 +0900)
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 <hyotaek.shim@samsung.com>
include/dlog-internal.h

index 7d5a327..b52e2e9 100644 (file)
@@ -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