[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]