Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Oct 2013 09:16:33 -0400
From:      Sean Bruno <sean_bruno@yahoo.com>
To:        Daniel Hartmeier <daniel@benzedrine.cx>
Cc:        freebsd-hackers@freebsd.org, hackers@freebsd.org
Subject:   Re: warning spew from cddl libnvpair.c
Message-ID:  <1382706993.2451.10.camel@localhost>
In-Reply-To: <20131025122643.GC12556@insomnia.benzedrine.cx>
References:  <1382672957.18382.11.camel@localhost> <20131025113946.GA15905@britannica.bec.de> <20131025122643.GC12556@insomnia.benzedrine.cx>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-v4hO0we1ysCy4ncReLec
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

On Fri, 2013-10-25 at 14:26 +0200, Daniel Hartmeier wrote:
> How is that valid?
>=20
> If nvprt_btwnarrfmt contains %, how would
>=20
> 	(void) fprintf(fp, pctl->nvprt_btwnarrfmt); \
>=20
> not crash?
>=20

If someone created a macro (e.g. NVLIST_PRTFUNC) that had % as an
argument, bad things would happen, you would get a "incomplete format
specifier warning on compile in that case.

> And if it may not contain %, why not use
>=20
> 	(void) fprintf(fp, "%s", pctl->nvprt_btwnarrfmt); \
>=20
That would mean writing a C function for each and every variable type to be=
 printed.  right?

> It can be set to arbitrary values with
>=20
>   libnvpair.c nvlist_prtctl_setfmt()
>=20
> That's exactly why the compiler warns, no?

I'm specifically looking at the macros that expand first (ARENDER for
example).  nvlist_prtctl_setfmt() doesn't seem to error check at all,
but I'm not clear how its used outside of the library.
>=20
> If anything in the macro/preprocessor trickery is relevant, I'm not
> seeing it.

sean


--=-v4hO0we1ysCy4ncReLec
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (FreeBSD)

iQEcBAABAgAGBQJSam8uAAoJEBkJRdwI6BaH7WoH/RnBGh1nouuzTZPu8e7kVmXK
tk67Wrs4/QHXjnTAUmRQ0zpRGmMnRHdFhOlc97rwgWm4mAYbTFvR5Tdkt6668cLg
quQlEUvGJk4HV3T48L7lNQeh5oQIo4YnpC40xNJXv4VQS1CTAXzzFkSn5CWqh10Q
u2wMKmfY8+jhlD0Bbe1JWRUZlFL414jvZB1LXn1dkXYCtuNDvUB9rsHjOqAFfkrq
xuvVDuk9Vhiqq8QOgKef6o95crGbxmcnYM0ckgzwFeGoph1qKlhVxCmqdU1p0yHQ
gv18nJ7eFUj9RB4a94/0pNyUmR38JaFoUbuo3xZnOCrXIrYagIGNRfmmb9d38Ug=
=qlTq
-----END PGP SIGNATURE-----

--=-v4hO0we1ysCy4ncReLec--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1382706993.2451.10.camel>