Message ID | AANLkTinVg=ZKyC=r2QEGUnNwoOBmyc13BFgqxp-EeJFb@mail.gmail.com |
---|---|
State | New |
Headers | show |
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.
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.
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(-)