1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-10-25 03:34:00 +03:00

Detect heap allocation failure; factor out some duplication.

* qemud/qemud.c (tls_port, tcp_port, mdns_name, tls_allowed_ip_list):
  (tls_allowed_dn_list): Remove "const", now that we free these.
  (unix_sock_rw_mask): Rename from unix_sock_rw_perms, so that
  the latter name can be used as a local string variable, so that the
  variable name matches the config attribute name.
  (unix_sock_ro_mask): Rename from unix_sock_ro_perms, likewise.
  (remoteCheckDN, remoteCheckAccess): Adapt to const removal.
  (qemudDispatchServer): Check for heap allocation failure.
  (remoteConfigGetStringList): New function, based on code from Dan Berrangé.
  (CHECK_TYPE): Remove macro.
  (checkType): New function.
  (GET_CONF_INT, GET_CONF_STR): New macros.
  (remoteReadConfigFile): Use new macros to avoid duplication and to
  check for allocation failure.
* src/conf.h (virConfTypeName): New static inline function.
This commit is contained in:
Jim Meyering
2007-11-30 15:43:42 +00:00
parent 2ac691d60e
commit c3c80a183e
3 changed files with 270 additions and 156 deletions

View File

@@ -1,7 +1,7 @@
/**
* conf.h: parser for a subset of the Python encoded Xen configuration files
*
* Copyright (C) 2006 Red Hat, Inc.
* Copyright (C) 2006, 2007 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -28,6 +28,21 @@ typedef enum {
VIR_CONF_LIST = 3 /* a list */
} virConfType;
static inline const char *
virConfTypeName (virConfType t)
{
switch (t) {
case VIR_CONF_LONG:
return "long";
case VIR_CONF_STRING:
return "string";
case VIR_CONF_LIST:
return "list";
default:
return "*unexpected*";
}
}
/**
* virConfValue:
* a value from the configuration file
@@ -80,3 +95,12 @@ int __virConfWriteMem (char *memory,
}
#endif
#endif /* __VIR_CONF_H__ */
/*
* Local variables:
* indent-tabs-mode: nil
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/