ACK: [PATCH] Add GNU printf format attribute specifier for make_message()
Colin Ian King
colin.king at canonical.com
Fri Mar 20 00:15:43 UTC 2020
On 19/03/2020 23:33, Alex Hung wrote:
> I found this breaks on 32bit (both PC & ARM) systems...
Apologies for that. Let's just ignore (or revert) this one and I'll work
on a V2 for the next release.
Colin
>
> On Wed, Mar 18, 2020 at 6:50 PM Alex Hung <alex.hung at canonical.com
> <mailto:alex.hung at canonical.com>> wrote:
>
> On 2020-03-18 5:59 p.m., Colin King wrote:
> > From: Colin Ian King <colin.king at canonical.com
> <mailto:colin.king at canonical.com>>
> >
> > Use the printf format attribute specifier to add a little more
> > type checking. Wrap this with a FWTS_FORMAT macro so that we
> > can no-op this for older compilers that don't support this
> > feature.
> >
> > Signed-off-by: Colin Ian King <colin.king at canonical.com
> <mailto:colin.king at canonical.com>>
> > ---
> > src/lib/include/fwts.h | 8 ++++++++
> > src/opal/reserv_mem.c | 2 ++
> > 2 files changed, 10 insertions(+)
> >
> > diff --git a/src/lib/include/fwts.h b/src/lib/include/fwts.h
> > index 7a05befc..7effe818 100644
> > --- a/src/lib/include/fwts.h
> > +++ b/src/lib/include/fwts.h
> > @@ -142,6 +142,14 @@
> > #define OPTIMIZE0
> > #endif
> >
> > +/* print format attribute */
> > +#if ((defined(__GNUC__) && NEED_GNUC(3,2,0)) || \
> > + (defined(__clang__) && NEED_CLANG(3, 7, 0)))
> > +#define FWTS_FORMAT(func, a, b) __attribute__((format(func, a, b)))
> > +#else
> > +#define FWTS_FORMAT(func, a, b)
> > +#endif
> > +
> > #define FWTS_UNUSED(var) (void)var
> >
> > #define FWTS_JSON_DATA_PATH DATAROOTDIR "/fwts"
> > diff --git a/src/opal/reserv_mem.c b/src/opal/reserv_mem.c
> > index f243fb2e..82293c91 100644
> > --- a/src/opal/reserv_mem.c
> > +++ b/src/opal/reserv_mem.c
> > @@ -87,6 +87,8 @@ static int get_config(fwts_framework *fw,
> > return FWTS_OK;
> > }
> >
> > +static char *make_message(const char *fmt, ...)
> FWTS_FORMAT(printf, 1, 2);
> > +
> > static char *make_message(const char *fmt, ...)
> > {
> > char *p;
> >
>
> Acked-by: Alex Hung <alex.hung at canonical.com
> <mailto:alex.hung at canonical.com>>
>
>
>
> --
> Cheers,
> Alex Hung
>
More information about the fwts-devel
mailing list