[Libguestfs] [PATCH] NFC: Cleanup iteration over fstab entries in inspect_fs_unix.c

Richard W.M. Jones rjones at redhat.com
Thu Nov 24 19:13:44 UTC 2011


On Thu, Nov 24, 2011 at 02:48:46PM +0000, Matthew Booth wrote:
> Select non-comment labels using an augeas path to return the correct nodes in
> the first instance, rather than applying a regular expression to all results.
> Iterate over returned matches using a char** iterator.
> Use asprintf() to ensure the path string buffer is the correct size.

In general this is an obvious improvement.

> +  for (char **entry = entries; *entry != NULL; entry++) {
> +    if (asprintf (&augpath, "%s/spec", *entry) == -1) g->abort_cb();

We have a safe_asprintf function defined already, and it would be
better to use that.

Is augpath supposed to be freed on the non-error path?

spec and mp should be freed on the error path, but don't seem to be at
the moment.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v




More information about the Libguestfs mailing list