ia64/xen-unstable

changeset 12783:38ad5643aafe

With PERMISSIVE turned on, diagnose missing Enums and Bools, and improve the
diagnosis of missing structure values.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Mon Dec 04 10:20:56 2006 +0000 (2006-12-04)
parents fd28a1b139de
children 4e3a7d82917c
files tools/libxen/src/xen_common.c
line diff
     1.1 --- a/tools/libxen/src/xen_common.c	Mon Dec 04 09:29:26 2006 +0000
     1.2 +++ b/tools/libxen/src/xen_common.c	Mon Dec 04 10:20:56 2006 +0000
     1.3 @@ -518,8 +518,14 @@ static void parse_into(xen_session *s, x
     1.4          xmlChar *string = string_from_value(value_node, "string");
     1.5          if (string == NULL)
     1.6          {
     1.7 +#if PERMISSIVE
     1.8 +            fprintf(stderr,
     1.9 +                    "Expected an Enum from the server, but didn't get one\n");
    1.10 +            ((int *)value)[slot] = 0;
    1.11 +#else
    1.12              server_error(
    1.13                  s, "Expected an Enum from the server, but didn't get one");
    1.14 +#endif
    1.15          }
    1.16          else
    1.17          {
    1.18 @@ -567,8 +573,14 @@ static void parse_into(xen_session *s, x
    1.19          xmlChar *string = string_from_value(value_node, "boolean");
    1.20          if (string == NULL)
    1.21          {
    1.22 +#if PERMISSIVE
    1.23 +            fprintf(stderr,
    1.24 +                    "Expected a Bool from the server, but didn't get one\n");
    1.25 +            ((bool *)value)[slot] = false;
    1.26 +#else
    1.27              server_error(
    1.28                  s, "Expected a Bool from the server, but didn't get one");
    1.29 +#endif
    1.30          }
    1.31          else
    1.32          {
    1.33 @@ -764,7 +776,6 @@ static void parse_into(xen_session *s, x
    1.34                  cur = cur->next;
    1.35              }
    1.36  
    1.37 -#if !PERMISSIVE
    1.38              /* Check that we've filled all fields. */
    1.39              for (size_t i = 0; i < member_count; i++)
    1.40              {
    1.41 @@ -781,15 +792,20 @@ static void parse_into(xen_session *s, x
    1.42  
    1.43                  if (j == seen_count)
    1.44                  {
    1.45 +#if PERMISSIVE
    1.46 +                    fprintf(stderr,
    1.47 +                            "Struct did not contain expected field %s.\n",
    1.48 +                            mem->key);
    1.49 +#else
    1.50                      server_error_2(s,
    1.51                                     "Struct did not contain expected field",
    1.52                                     mem->key);
    1.53                      free(result);
    1.54                      free(checklist);
    1.55                      return;
    1.56 +#endif
    1.57                  }
    1.58              }
    1.59 -#endif
    1.60  
    1.61              free(checklist);
    1.62              ((void **)value)[slot] = result;