[systemd-devel] [PATCH 0/4] looking at _cleanup_free_ usage

Andreas Henriksson andreas at fatal.se
Fri Jun 13 10:25:37 PDT 2014


Hello Tom Gundersen.

Thanks for all your interesting feedback and your quick review!

For anyone interested in following up with more work on the
same topic here, I'll add that I have not looked at any
files named test* or files under src/test/.

I have also not looked at cases which did not match my
simple grep, eg. you might want to look for cases like:
	_cleanup_free_ char *foo, *bar, *quux = NULL;


On Fri, Jun 13, 2014 at 07:04:44PM +0200, Tom Gundersen wrote:
[...]
> We should (IMHO) always initialize the _cleanup_ variables when 
> declaring them, even if it so happens that they would anyway later get
> initialized. Introducing bugs later on is too easy other wise.
[...]
> We try to avoid calling functions when declaring variables, so I'd just do:
> 
> _cleanup_free_ char *myptr = NULL;
> 
> myptr = strdup("example");
[...]

If Toms suggestions (which I agree with) are the general consensus, someone
might also want to look at putting this in CODING_STYLE and also cleaning
up the existing code to look like this.
(There are both occurances of function calls directly at declarations
and not-initialized-when-declared-but-directly-after in the code now.)

Regards,
Andreas Henriksson


More information about the systemd-devel mailing list