/*
* virconf.c: parser for a subset of the Python encoded Xen configuration files
*
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*/
static virConfPtr
virConfParse(const char *filename, const char *content, int len,
- unsigned int flags) {
+ unsigned int flags)
+{
virConfParserCtxt ctxt;
ctxt.filename = filename;
/*
* virdbus.c: helper for using DBus
*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
}
-static void virDBusWatchFree(void *data) {
+static void virDBusWatchFree(void *data)
+{
struct virDBusWatch *info = data;
VIR_FREE(info);
}
DBUS_TYPE_SIGNATURE,
};
-static bool virDBusIsBasicType(char c) {
+static bool virDBusIsBasicType(char c)
+{
return !!memchr(virDBusBasicTypes, c, ARRAY_CARDINALITY(virDBusBasicTypes));
}
void *virUserData = NULL; /* associated data */
virErrorLogPriorityFunc virErrorLogPriorityFilter = NULL;
-static virLogPriority virErrorLevelPriority(virErrorLevel level) {
+static virLogPriority virErrorLevelPriority(virErrorLevel level)
+{
switch (level) {
case VIR_ERR_NONE:
return VIR_LOG_INFO;
/*
* vireventpoll.c: Poll based event loop for monitoring file handles
*
- * Copyright (C) 2007, 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2007, 2010-2014 Red Hat, Inc.
* Copyright (C) 2007 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
int virEventPollAddHandle(int fd, int events,
virEventHandleCallback cb,
void *opaque,
- virFreeCallback ff) {
+ virFreeCallback ff)
+{
int watch;
virMutexLock(&eventLoop.lock);
if (eventLoop.handlesCount == eventLoop.handlesAlloc) {
return watch;
}
-void virEventPollUpdateHandle(int watch, int events) {
+void virEventPollUpdateHandle(int watch, int events)
+{
size_t i;
bool found = false;
PROBE(EVENT_POLL_UPDATE_HANDLE,
* For this reason we only ever set a flag in the existing list.
* Actual deletion will be done out-of-band
*/
-int virEventPollRemoveHandle(int watch) {
+int virEventPollRemoveHandle(int watch)
+{
size_t i;
PROBE(EVENT_POLL_REMOVE_HANDLE,
"watch=%d",
* For this reason we only ever set a flag in the existing list.
* Actual deletion will be done out-of-band
*/
-int virEventPollRemoveTimeout(int timer) {
+int virEventPollRemoveTimeout(int timer)
+{
size_t i;
PROBE(EVENT_POLL_REMOVE_TIMEOUT,
"timer=%d",
* no timeout is pending
* returns: 0 on success, -1 on error
*/
-static int virEventPollCalculateTimeout(int *timeout) {
+static int virEventPollCalculateTimeout(int *timeout)
+{
unsigned long long then = 0;
size_t i;
EVENT_DEBUG("Calculate expiry of %zu timers", eventLoop.timeoutsCount);
*
* Returns 0 upon success, -1 if an error occurred
*/
-static int virEventPollDispatchHandles(int nfds, struct pollfd *fds) {
+static int virEventPollDispatchHandles(int nfds, struct pollfd *fds)
+{
size_t i, n;
VIR_DEBUG("Dispatch %d", nfds);
* were previously marked as deleted. This asynchronous
* cleanup is needed to make dispatch re-entrant safe.
*/
-static void virEventPollCleanupTimeouts(void) {
+static void virEventPollCleanupTimeouts(void)
+{
size_t i;
size_t gap;
VIR_DEBUG("Cleanup %zu", eventLoop.timeoutsCount);
* were previously marked as deleted. This asynchronous
* cleanup is needed to make dispatch re-entrant safe.
*/
-static void virEventPollCleanupHandles(void) {
+static void virEventPollCleanupHandles(void)
+{
size_t i;
size_t gap;
VIR_DEBUG("Cleanup %zu", eventLoop.handlesCount);
* Run a single iteration of the event loop, blocking until
* at least one file handle has an event, or a timer expires
*/
-int virEventPollRunOnce(void) {
+int virEventPollRunOnce(void)
+{
struct pollfd *fds = NULL;
int ret, timeout, nfds;
/*
* virhook.c: implementation of the synchronous hooks support
*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2010 Daniel Veillard
*
* This library is free software; you can redistribute it and/or
* Returns 1 if found, 0 if not found, and -1 in case of error
*/
static int
-virHookCheck(int no, const char *driver) {
+virHookCheck(int no, const char *driver)
+{
char *path;
int ret;
* Returns the number of hooks found or -1 in case of failure
*/
int
-virHookInitialize(void) {
+virHookInitialize(void)
+{
size_t i;
int res, ret = 0;
* Returns 1 if present, 0 otherwise
*/
int
-virHookPresent(int driver) {
+virHookPresent(int driver)
+{
if ((driver < VIR_HOOK_DRIVER_DAEMON) ||
(driver >= VIR_HOOK_DRIVER_LAST))
return 0;
/*
- * Copyright (C) 2009-2013 Red Hat, Inc.
+ * Copyright (C) 2009-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
};
static uint32_t
-virNetDevVPortProfileGetLldpadPid(void) {
+virNetDevVPortProfileGetLldpadPid(void)
+{
int fd;
uint32_t pid = 0;
/*
- * Copyright (C) 2012-2013 Red Hat, Inc.
+ * Copyright (C) 2012-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
int
virRandomGenerateWWN(char **wwn,
- const char *virt_type) {
+ const char *virt_type)
+{
const char *oui = NULL;
if (!virt_type) {
/*
- * Copyright (C) 2009-2013 Red Hat, Inc.
+ * Copyright (C) 2009-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
*
* Returns the length of the network address or -1 in case of error.
*/
-int virSocketAddrParse(virSocketAddrPtr addr, const char *val, int family) {
+int virSocketAddrParse(virSocketAddrPtr addr, const char *val, int family)
+{
int len;
struct addrinfo *res;
* Returns the length of the network address or -1 in case of error.
*/
int
-virSocketAddrParseIPv4(virSocketAddrPtr addr, const char *val) {
+virSocketAddrParseIPv4(virSocketAddrPtr addr, const char *val)
+{
return virSocketAddrParse(addr, val, AF_INET);
}
* Returns the length of the network address or -1 in case of error.
*/
int
-virSocketAddrParseIPv6(virSocketAddrPtr addr, const char *val) {
+virSocketAddrParseIPv6(virSocketAddrPtr addr, const char *val)
+{
return virSocketAddrParse(addr, val, AF_INET6);
}
* Returns 0 on success, -1 on failure
*/
int
-virSocketAddrSetPort(virSocketAddrPtr addr, int port) {
+virSocketAddrSetPort(virSocketAddrPtr addr, int port)
+{
if (addr == NULL)
return -1;
* Returns -1 if @addr is invalid
*/
int
-virSocketAddrGetPort(virSocketAddrPtr addr) {
+virSocketAddrGetPort(virSocketAddrPtr addr)
+{
if (addr == NULL)
return -1;
*
* Returns 0 in case of success and -1 in case of error
*/
-int virSocketAddrIsNetmask(virSocketAddrPtr netmask) {
+int virSocketAddrIsNetmask(virSocketAddrPtr netmask)
+{
int n = virSocketAddrGetNumNetmaskBits(netmask);
if (n < 0)
return -1;
* -1 in case of error
*/
int virSocketAddrCheckNetmask(virSocketAddrPtr addr1, virSocketAddrPtr addr2,
- virSocketAddrPtr netmask) {
+ virSocketAddrPtr netmask)
+{
size_t i;
if ((addr1 == NULL) || (addr2 == NULL) || (netmask == NULL))
*
* Returns the size of the range or -1 in case of failure
*/
-int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end) {
+int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end)
+{
int ret = 0;
size_t i;
/* virSysinfoRead for PowerPC
* Gathers sysinfo data from /proc/cpuinfo */
virSysinfoDefPtr
-virSysinfoRead(void) {
+virSysinfoRead(void)
+{
virSysinfoDefPtr ret = NULL;
char *outbuf = NULL;
/* virSysinfoRead for ARMv7
* Gathers sysinfo data from /proc/cpuinfo */
virSysinfoDefPtr
-virSysinfoRead(void) {
+virSysinfoRead(void)
+{
virSysinfoDefPtr ret = NULL;
char *outbuf = NULL;
/* virSysinfoRead for s390x
* Gathers sysinfo data from /proc/sysinfo and /proc/cpuinfo */
virSysinfoDefPtr
-virSysinfoRead(void) {
+virSysinfoRead(void)
+{
virSysinfoDefPtr ret = NULL;
char *outbuf = NULL;
defined(__aarch64__) || \
defined(__powerpc__))
virSysinfoDefPtr
-virSysinfoRead(void) {
+virSysinfoRead(void)
+{
/*
* this can probably be extracted from Windows using API or registry
* http://www.microsoft.com/whdc/system/platform/firmware/SMBIOS.mspx
}
virSysinfoDefPtr
-virSysinfoRead(void) {
+virSysinfoRead(void)
+{
char *path;
virSysinfoDefPtr ret = NULL;
char *outbuf = NULL;
/*
* virthread.c: basic thread synchronization primitives
*
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2010, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
pthread_mutex_destroy(&m->lock);
}
-void virMutexLock(virMutexPtr m){
+void virMutexLock(virMutexPtr m)
+{
pthread_mutex_lock(&m->lock);
}
/*
* virutil.c: common, generic utility functions
*
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
* Copyright (C) 2006, 2007 Binary Karma
* Copyright (C) 2006 Shuveb Hussain
#ifndef WIN32
-int virSetInherit(int fd, bool inherit) {
+int virSetInherit(int fd, bool inherit)
+{
int fflags;
if ((fflags = fcntl(fd, F_GETFD)) < 0)
return -1;
#endif /* WIN32 */
-int virSetBlocking(int fd, bool blocking) {
+int virSetBlocking(int fd, bool blocking)
+{
return set_nonblocking_flag(fd, !blocking);
}
-int virSetNonBlock(int fd) {
+int virSetNonBlock(int fd)
+{
return virSetBlocking(fd, false);
}
* @param name The name of the device
* @return name's index, or -1 on failure
*/
-int virDiskNameToIndex(const char *name) {
+int virDiskNameToIndex(const char *name)
+{
const char *ptr = NULL;
int idx = 0;
static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd", "ubd"};
{}
}
#else
-void virFileWaitForDevices(void) {}
+void virFileWaitForDevices(void)
+{}
#endif
#if HAVE_LIBDEVMAPPER_H
#endif
bool
-virValidateWWN(const char *wwn) {
+virValidateWWN(const char *wwn)
+{
size_t i;
const char *p = wwn;
/* No-op workarounds for functionality missing in mingw. */
# ifndef HAVE_GETUID
-static inline int getuid(void) { return 0; }
+static inline int getuid(void)
+{ return 0; }
# endif
# ifndef HAVE_GETEUID
-static inline int geteuid(void) { return 0; }
+static inline int geteuid(void)
+{ return 0; }
# endif
# ifndef HAVE_GETGID
-static inline int getgid(void) { return 0; }
+static inline int getgid(void)
+{ return 0; }
# endif
# ifndef HAVE_GETEGID
-static inline int getegid(void) { return 0; }
+static inline int getegid(void)
+{ return 0; }
# endif
# ifdef FUNC_PTHREAD_SIGMASK_BROKEN
/*
* viruuid.c: helper APIs for dealing with UUIDs
*
- * Copyright (C) 2007-2013 Red Hat, Inc.
+ * Copyright (C) 2007-2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Returns 0 in case of success and -1 in case of error.
*/
int
-virUUIDParse(const char *uuidstr, unsigned char *uuid) {
+virUUIDParse(const char *uuidstr, unsigned char *uuid)
+{
const char *cur;
size_t i;