summaryrefslogtreecommitdiff
path: root/HACKING
diff options
context:
space:
mode:
authorBlue Swirl <blauwirbel@gmail.com>2010-09-10 18:53:11 +0000
committerBlue Swirl <blauwirbel@gmail.com>2010-09-10 18:53:11 +0000
commite6985a361bc691eee57995c1c8554a80ba1e24e3 (patch)
tree79b78b7c4eb2c37fca040d0bb9f7e5fb6513188c /HACKING
parent335eb601bd0a7b9132b71787a5aafb8983215eb9 (diff)
downloadqemu-e6985a361bc691eee57995c1c8554a80ba1e24e3.tar.gz
qemu-e6985a361bc691eee57995c1c8554a80ba1e24e3.tar.bz2
qemu-e6985a361bc691eee57995c1c8554a80ba1e24e3.zip
HACKING: add rules for printf-like functions
Add rules for printf-like functions, based on libvirt HACKING. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'HACKING')
-rw-r--r--HACKING13
1 files changed, 13 insertions, 0 deletions
diff --git a/HACKING b/HACKING
index 3ad87aa362..6ba9d7e740 100644
--- a/HACKING
+++ b/HACKING
@@ -110,3 +110,16 @@ so instead of e.g. isalnum you should use qemu_isalnum.
Because of the memory management rules, you must use qemu_strdup/qemu_strndup
instead of plain strdup/strndup.
+
+5. Printf-style functions
+
+Whenever you add a new printf-style function, i.e., one with a format
+string argument and following "..." in its prototype, be sure to use
+gcc's printf attribute directive in the prototype.
+
+This makes it so gcc's -Wformat and -Wformat-security options can do
+their jobs and cross-check format strings with the number and types
+of arguments.
+
+Currently many functions in QEMU are not following this rule but
+patches to add the attribute would be very much appreciated.