[Libguestfs] [PATCH 6/13] hivex: Add value_any callback to the visitor.

Richard W.M. Jones rjones at redhat.com
Thu Jan 28 14:27:59 UTC 2010


On Thu, Jan 28, 2010 at 03:21:50PM +0100, Jim Meyering wrote:
> Richard W.M. Jones wrote:
> > Subject: [PATCH 06/13] hivex: Add value_any callback to the visitor.
> >
> > The visitor currently contains lots of value_* callbacks, such as
> > value_string which is called back when the value has type string.
> >
> > This is fine but it makes it complicated to deal with the case where
> > you just want to see 'a value', and don't care about its type.
> >
> > The value_any callback allows visitors to see values generically.
> > ---
> >  hivex/hivex.c   |  178 +++++++++++++++++++++++++++++--------------------------
> >  hivex/hivex.h   |    1 +
> >  hivex/hivex.pod |    5 ++
> >  3 files changed, 101 insertions(+), 83 deletions(-)
> >
> > diff --git a/hivex/hivex.c b/hivex/hivex.c
> > index cb6fc62..81d217b 100644
> > --- a/hivex/hivex.c
> > +++ b/hivex/hivex.c
> > @@ -1421,114 +1421,126 @@ hivex__visit_node (hive_h *h, hive_node_h node,
> >        goto error;
> >      }
> >
> > -    switch (t) {
> > -    case hive_t_none:
> > +    if (vtor->value_any) {
> >        str = hivex_value_value (h, values[i], &t, &len);
> >        if (str == NULL) {
> >          ret = skip_bad ? 0 : -1;
> >          goto error;
> >        }
> > -      if (t != hive_t_none) {
> > -        ret = skip_bad ? 0 : -1;
> > -        goto error;
> > -      }
> > -      if (vtor->value_none &&
> > -          vtor->value_none (h, opaque, node, values[i], t, len, key, str) == -1)
> > +      if (vtor->value_any (h, opaque, node, values[i], t, len, key, str) == -1)
> >          goto error;
> >        free (str); str = NULL;
> > -      break;
> > -
> > -    case hive_t_string:
> > -    case hive_t_expand_string:
> > -    case hive_t_link:
> > -      str = hivex_value_string (h, values[i]);
> > -      if (str == NULL) {
> > -        if (errno != EILSEQ && errno != EINVAL) {
> > +    }
> > +    else {
> > +      switch (t) {
> 
> This looks fine.
> I found it best to review with "git log -B -w -p -1 SHA1"
> since the vast majority is just an indentation change: moving
> the current "switch" stmt into the new else block.

I was playing with git show --patience and other flags like that.  The
patience algorithm (sometimes) improves the output by keeping related
code together.  Is there a recommended way to get better patches for
review from 'git format-patch'?

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