Apply __attribute__((format(printf..))) to Public dlog_print() 43/194943/1
authorHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 10 Dec 2018 03:01:35 +0000 (12:01 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 10 Dec 2018 03:01:39 +0000 (12:01 +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: I852fcea60109517e50e26e3ee1a8064fd9bb649f
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
include/dlog.h

index 922c45f..7446bee 100644 (file)
@@ -134,7 +134,9 @@ int main(void)
 }
  * @endcode
  */
-int dlog_print(log_priority prio, const char *tag, const char *fmt, ...);
+
+#pragma GCC diagnostic warning "-Wformat"
+int dlog_print(log_priority prio, const char *tag, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
 
 
 /**