warning spew from cddl libnvpair.c

Sean Bruno sean_bruno at yahoo.com
Fri Oct 25 13:22:23 UTC 2013


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

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
> 
> 	(void) fprintf(fp, "%s", pctl->nvprt_btwnarrfmt); \
> 
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
> 
>   libnvpair.c nvlist_prtctl_setfmt()
> 
> 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.
> 
> If anything in the macro/preprocessor trickery is relevant, I'm not
> seeing it.

sean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20131025/85ca713c/attachment.sig>


More information about the freebsd-hackers mailing list