[PATCH] Add __printflike to all printflike functions and fix all that uncovers

Poul-Henning Kamp phk at phk.freebsd.dk
Sat Jan 14 19:48:18 CET 2012


In message <1326563395-8543-1-git-send-email-github at bsdchicks.com>, Rogier 'Doc
Wilco' Mulhuijzen writes:

>diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
>index 4967c82..1b62937 100644
>--- a/bin/varnishd/cache/cache_center.c
>+++ b/bin/varnishd/cache/cache_center.c
>@@ -1655,12 +1655,12 @@ cnt_diag(struct sess *sp, const char *state)
> 	}
> 
> 	if (sp->wrk != NULL) {
>-		WSP(sp, SLT_Debug, "thr %p STP_%s sp %p obj %p vcl %p",
>+		WSP(sp, SLT_Debug, "thr %lx STP_%s sp %p obj %p vcl %p",
> 		    pthread_self(), state, sp, obj, vcl);

Neither %p nor %lx are correct, in fact there is by standard no correct
way to print a pthread_t (thanks POSIX, next time think, OK ?)

We probably need to tag all our threads some way to solve this, or simply
remove printing the pthread_self().  Since we have the sp->vsl_id I think
that's the best compromise.

>@@ -1776,7 +1776,7 @@ cli_debug_srandom(struct cli *cli, const char * const *av, void *priv)
> 		seed = strtoul(av[2], NULL, 0);
> 	srandom(seed);
> 	srand48(random());
>-	VCLI_Out(cli, "Random(3) seeded with %lu", seed);
>+	VCLI_Out(cli, "Random(3) seeded with %u", seed);

This is the wrong fix, both srandom and srand48 takes a (unsigned) long arg.

> 		if (strcmp(x, nm)) {
> 			VCLI_Out(cli, "Loading VMOD %s from %s:\n", nm, path);
>-			VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", x);
>+			VCLI_Out(cli, "File contain wrong VMOD (\"%s\")\n", (char *) x);

Please split elongated lines lines properly at 80char boundary.

>+#include "printflike.h"

I've been thinking of introducing a "vdefs.h" for stuff like this,
to contain compiler and C-dialect dependencies to a single file,
we should use this chance to found that file.

The #include hierarchy would be something like:

	include/vdefs.h

	included from:
		varnishd/common/common.h
		varnishstat/varnishstat.h
		varnishtest/vtc.h
		etc.

So as to minimize the number of #include lines, given that we want
total exposure for this file.

We may want to move AZ(), AN() etc. over there subsequently.


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-dev mailing list