varnish-cache icon indicating copy to clipboard operation
varnish-cache copied to clipboard

Add a utility macro to allocate mini-objects on the workspace

Open nigoroll opened this issue 3 years ago • 4 comments

isn't this something we would have wanted all along?

This simplifies the common pattern to allocate/initialize a miniobj on the workspace to

	WS_TASK_ALLOC_OBJ(ctx, myobj, MYOBJ_MAGIC);
	if (myobj == NULL)
		return (error);

nigoroll avatar Jun 02 '22 14:06 nigoroll

Not against it.

Any idea how many places in the code it could have been used already ?

bsdphk avatar Jun 07 '22 11:06 bsdphk

Any idea how many places in the code it could have been used already ?

I have pushed a commit changing five places in the tree, but the macro is intended more for use in vmods.

If, however, we changed it (or added a variant not calling VRT_fail()), there were more potential sites like here here here or here

nigoroll avatar Jun 07 '22 12:06 nigoroll

Did you consider a coccinelle patch?

dridi avatar Jun 07 '22 13:06 dridi

Did you consider a coccinelle patch?

Yes, but I deemed the patterns too different - for the given example https://github.com/varnishcache/varnish-cache/pull/3815/commits/afe8b2ca8fce84043b9467753097d519bbb5817e there are three different ways of error handling.

nigoroll avatar Jun 07 '22 14:06 nigoroll