Print this page
2249 libbrand suppresses libxml2 errors
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Eric Shrock <eric.schrock@delphix.com>
Reviewed by: Milan Jurik <milan.jurik@xylab.cz>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libbrand/common/libbrand.c
          +++ new/usr/src/lib/libbrand/common/libbrand.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright (c) 2012 Nexenta Systems, Inc.  All rights reserved.
  24   25   */
  25   26  
  26   27  #include <assert.h>
  27   28  #include <dirent.h>
  28   29  #include <errno.h>
  29   30  #include <fnmatch.h>
  30   31  #include <signal.h>
  31   32  #include <stdlib.h>
  32   33  #include <unistd.h>
  33   34  #include <strings.h>
↓ open down ↓ 61 lines elided ↑ open up ↑
  95   96  #define DTD_ATTR_TYPE           ((const xmlChar *) "type")
  96   97  
  97   98  #define DTD_ENTITY_TRUE         "true"
  98   99  
  99  100  static volatile boolean_t       libbrand_initialized = B_FALSE;
 100  101  static char                     i_curr_arch[MAXNAMELEN];
 101  102  static char                     i_curr_zone[ZONENAME_MAX];
 102  103  
 103  104  /*ARGSUSED*/
 104  105  static void
 105      -brand_error_func(void *ctx, const char *msg, ...)
      106 +brand_warning_func(void *ctx, const char *msg, ...)
 106  107  {
 107  108          /*
 108      -         * Ignore error messages from libxml
      109 +         * Ignore warning messages from libxml
 109  110           */
 110  111  }
 111  112  
      113 +/*ARGSUSED*/
      114 +static void
      115 +brand_error_func(void *ctx, const char *msg, ...)
      116 +{
      117 +        va_list args;
      118 +
      119 +        va_start(args, msg);
      120 +        (void) vfprintf(stderr, msg, args);
      121 +        va_end(args);
      122 +}
      123 +
 112  124  static boolean_t
 113  125  libbrand_initialize()
 114  126  {
 115  127          static mutex_t initialize_lock = DEFAULTMUTEX;
 116  128  
 117  129          (void) mutex_lock(&initialize_lock);
 118  130  
 119  131          if (libbrand_initialized) {
 120  132                  (void) mutex_unlock(&initialize_lock);
 121  133                  return (B_TRUE);
↓ open down ↓ 73 lines elided ↑ open up ↑
 195  207                  return (NULL);
 196  208  
 197  209          /*
 198  210           * Validate the file
 199  211           */
 200  212          if ((cvp = xmlNewValidCtxt()) == NULL) {
 201  213                  xmlFreeDoc(doc);
 202  214                  return (NULL);
 203  215          }
 204  216          cvp->error = brand_error_func;
 205      -        cvp->warning = brand_error_func;
      217 +        cvp->warning = brand_warning_func;
 206  218          valid = xmlValidateDocument(cvp, doc);
 207  219          xmlFreeValidCtxt(cvp);
 208  220          if (valid == 0) {
 209  221                  xmlFreeDoc(doc);
 210  222                  return (NULL);
 211  223          }
 212  224  
 213  225          return (doc);
 214  226  }
 215  227  /*
↓ open down ↓ 801 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX