All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 5/5] CODING_STYLE: add rules for printf-like functions
@ 2010-08-12 17:51 Blue Swirl
  2010-08-13 19:47 ` [Qemu-devel] " Blue Swirl
  0 siblings, 1 reply; 2+ messages in thread
From: Blue Swirl @ 2010-08-12 17:51 UTC (permalink / raw)
  To: qemu-devel

Add rules for printf-like functions, based on libvirt HACKING.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 CODING_STYLE |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/CODING_STYLE b/CODING_STYLE
index b230a01..f190960 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -180,3 +180,13 @@ 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.
+
+9. 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.
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Qemu-devel] Re: [PATCH 5/5] CODING_STYLE: add rules for printf-like functions
  2010-08-12 17:51 [Qemu-devel] [PATCH 5/5] CODING_STYLE: add rules for printf-like functions Blue Swirl
@ 2010-08-13 19:47 ` Blue Swirl
  0 siblings, 0 replies; 2+ messages in thread
From: Blue Swirl @ 2010-08-13 19:47 UTC (permalink / raw)
  To: qemu-devel

On Thu, Aug 12, 2010 at 5:51 PM, Blue Swirl <blauwirbel@gmail.com> wrote:
> Add rules for printf-like functions, based on libvirt HACKING.
>
> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
> ---
>  CODING_STYLE |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/CODING_STYLE b/CODING_STYLE
> index b230a01..f190960 100644
> --- a/CODING_STYLE
> +++ b/CODING_STYLE
> @@ -180,3 +180,13 @@ 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.
> +
> +9. 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.

This rule would be new, printf attribute is used in very few places,
about 100 cases don't use the attribute.

I think the rule still makes sense and we should convert the codebase
eventually. A note about current status etc. should be added.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-13 19:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-12 17:51 [Qemu-devel] [PATCH 5/5] CODING_STYLE: add rules for printf-like functions Blue Swirl
2010-08-13 19:47 ` [Qemu-devel] " Blue Swirl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.