Silently ignored flags get in the way of new features that use those flags. Also, an upcoming syntax check will favor unsigned flags. * src/nodeinfo.h (nodeGetCPUStats, nodeGetMemoryStats): Drop unused attribute. * src/interface/netcf_driver.c (interfaceOpenInterface) (interfaceDefineXML, interfaceCreate, interfaceDestroy): Reject unknown flags. * src/network/bridge_driver.c (networkOpenNetwork) (networkGetXMLDesc): Likewise. * src/nwfilter/nwfilter_driver.c (nwfilterOpen): Likewise. * src/secret/secret_driver.c (secretOpen, secretDefineXML) (secretGetXMLDesc, secretSetValue): Likewise. * src/util/logging.c (virLogDefineFilter, virLogDefineOutput) (virLogMessage): Likewise; also use unsigned flags. * src/util/logging.h (virLogDefineFilter, virLogDefineOutput) (virLogMessage): Change signature. * src/util/command.c (virExecWithHook): Likewise. --- v2: rebase, fix driver open bug, and add in a few more instances (same goes for next 15 or so patches) src/interface/netcf_driver.c | 16 ++++++++++++---- src/network/bridge_driver.c | 9 +++++++-- src/nodeinfo.h | 6 +++--- src/nwfilter/nwfilter_driver.c | 4 +++- src/secret/secret_driver.c | 17 +++++++++++++---- src/util/command.c | 16 ++++++++-------- src/util/logging.c | 13 ++++++++++--- src/util/logging.h | 8 +++++--- 8 files changed, 61 insertions(+), 28 deletions(-) diff --git a/src/interface/netcf_driver.c b/src/interface/netcf_driver.c index 8900722..855b5a3 100644 --- a/src/interface/netcf_driver.c +++ b/src/interface/netcf_driver.c @@ -121,10 +121,12 @@ static struct netcf_if *interfaceDriverGetNetcfIF(struct netcf *ncf, virInterfac static virDrvOpenStatus interfaceOpenInterface(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { struct interface_driver *driverState; + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + if (VIR_ALLOC(driverState) < 0) { virReportOOMError(); @@ -387,7 +389,7 @@ cleanup: static virInterfacePtr interfaceDefineXML(virConnectPtr conn, const char *xml, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { struct interface_driver *driver = conn->interfacePrivateData; struct netcf_if *iface = NULL; @@ -395,6 +397,8 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn, virInterfaceDefPtr ifacedef = NULL; virInterfacePtr ret = NULL; + virCheckFlags(0, NULL); + interfaceDriverLock(driver); ifacedef = virInterfaceDefParseString(xml); @@ -461,12 +465,14 @@ cleanup: } static int interfaceCreate(virInterfacePtr ifinfo, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { struct interface_driver *driver = ifinfo->conn->interfacePrivateData; struct netcf_if *iface = NULL; int ret = -1; + virCheckFlags(0, -1); + interfaceDriverLock(driver); iface = interfaceDriverGetNetcfIF(driver->netcf, ifinfo); @@ -493,12 +499,14 @@ cleanup: } static int interfaceDestroy(virInterfacePtr ifinfo, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { struct interface_driver *driver = ifinfo->conn->interfacePrivateData; struct netcf_if *iface = NULL; int ret = -1; + virCheckFlags(0, -1); + interfaceDriverLock(driver); iface = interfaceDriverGetNetcfIF(driver->netcf, ifinfo); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 554a8ac..0a12bc0 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2010,7 +2010,10 @@ cleanup: static virDrvOpenStatus networkOpenNetwork(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags ATTRIBUTE_UNUSED) { + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + if (!driverState) return VIR_DRV_OPEN_DECLINED; @@ -2416,12 +2419,14 @@ cleanup: } static char *networkGetXMLDesc(virNetworkPtr net, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { struct network_driver *driver = net->conn->networkPrivateData; virNetworkObjPtr network; char *ret = NULL; + virCheckFlags(0, NULL); + networkDriverLock(driver); network = virNetworkFindByUUID(&driver->networks, net->uuid); networkDriverUnlock(driver); diff --git a/src/nodeinfo.h b/src/nodeinfo.h index 9b2658f..e5ac1e0 100644 --- a/src/nodeinfo.h +++ b/src/nodeinfo.h @@ -1,7 +1,7 @@ /* * nodeinfo.c: Helper routines for OS specific node information * - * Copyright (C) 2006-2008 Red Hat, Inc. + * Copyright (C) 2006-2008, 2011 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -34,12 +34,12 @@ int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED, int cpuNum, virNodeCPUStatsPtr params, int *nparams, - unsigned int flags ATTRIBUTE_UNUSED); + unsigned int flags); int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED, int cellNum, virNodeMemoryStatsPtr params, int *nparams, - unsigned int flags ATTRIBUTE_UNUSED); + unsigned int flags); int nodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *freeMems, int startCell, diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index bfe7f2f..a735059 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -272,8 +272,10 @@ cleanup: static virDrvOpenStatus nwfilterOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + if (!driverState) return VIR_DRV_OPEN_DECLINED; diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 552b7e4..c45ba51 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -525,7 +525,10 @@ cleanup: static virDrvOpenStatus secretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags ATTRIBUTE_UNUSED) { + unsigned int flags) +{ + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + if (driverState == NULL) return VIR_DRV_OPEN_DECLINED; @@ -667,7 +670,7 @@ cleanup: static virSecretPtr secretDefineXML(virConnectPtr conn, const char *xml, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { virSecretDriverStatePtr driver = conn->secretPrivateData; virSecretPtr ret = NULL; @@ -675,6 +678,8 @@ secretDefineXML(virConnectPtr conn, const char *xml, virSecretDefPtr backup = NULL; virSecretDefPtr new_attrs; + virCheckFlags(0, NULL); + new_attrs = virSecretDefParseString(xml); if (new_attrs == NULL) return NULL; @@ -778,12 +783,14 @@ cleanup: } static char * -secretGetXMLDesc(virSecretPtr obj, unsigned int flags ATTRIBUTE_UNUSED) +secretGetXMLDesc(virSecretPtr obj, unsigned int flags) { virSecretDriverStatePtr driver = obj->conn->secretPrivateData; char *ret = NULL; virSecretEntryPtr secret; + virCheckFlags(0, NULL); + secretDriverLock(driver); secret = secretFindByUUID(driver, obj->uuid); @@ -805,7 +812,7 @@ cleanup: static int secretSetValue(virSecretPtr obj, const unsigned char *value, - size_t value_size, unsigned int flags ATTRIBUTE_UNUSED) + size_t value_size, unsigned int flags) { virSecretDriverStatePtr driver = obj->conn->secretPrivateData; int ret = -1; @@ -813,6 +820,8 @@ secretSetValue(virSecretPtr obj, const unsigned char *value, size_t old_value_size; virSecretEntryPtr secret; + virCheckFlags(0, -1); + if (VIR_ALLOC_N(new_value, value_size) < 0) { virReportOOMError(); return -1; diff --git a/src/util/command.c b/src/util/command.c index eae58b2..6c19cd1 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -285,14 +285,14 @@ getDevNull(int *null) */ static int virExecWithHook(const char *const*argv, - const char *const*envp, - const fd_set *keepfd, - pid_t *retpid, - int infd, int *outfd, int *errfd, - int flags, - virExecHook hook, - void *data, - char *pidfile) + const char *const*envp, + const fd_set *keepfd, + pid_t *retpid, + int infd, int *outfd, int *errfd, + unsigned int flags, + virExecHook hook, + void *data, + char *pidfile) { pid_t pid; int null = -1, i, openmax; diff --git a/src/util/logging.c b/src/util/logging.c index c86fcda..d340f57 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -481,10 +481,13 @@ static int virLogResetFilters(void) { * Returns -1 in case of failure or the filter number if successful */ int virLogDefineFilter(const char *match, int priority, - int flags ATTRIBUTE_UNUSED) { + unsigned int flags) +{ int i; char *mdup = NULL; + virCheckFlags(0, -1); + if ((match == NULL) || (priority < VIR_LOG_DEBUG) || (priority > VIR_LOG_ERROR)) return -1; @@ -579,10 +582,13 @@ static int virLogResetOutputs(void) { */ int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c, void *data, int priority, int dest, const char *name, - int flags ATTRIBUTE_UNUSED) { + unsigned int flags) +{ int ret = -1; char *ndup = NULL; + virCheckFlags(0, -1); + if (f == NULL) return -1; @@ -683,7 +689,8 @@ virLogVersionString(char **msg, * the message may be stored, sent to output or just discarded */ void virLogMessage(const char *category, int priority, const char *funcname, - long long linenr, int flags, const char *fmt, ...) { + long long linenr, unsigned int flags, const char *fmt, ...) +{ static bool logVersionStderr = true; char *str = NULL; char *msg = NULL; diff --git a/src/util/logging.h b/src/util/logging.h index 6683e6f..20c8948 100644 --- a/src/util/logging.h +++ b/src/util/logging.h @@ -105,10 +105,11 @@ extern char *virLogGetOutputs(void); extern int virLogGetDefaultPriority(void); extern int virLogSetDefaultPriority(int priority); extern void virLogSetFromEnv(void); -extern int virLogDefineFilter(const char *match, int priority, int flags); +extern int virLogDefineFilter(const char *match, int priority, + unsigned int flags); extern int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c, void *data, int priority, int dest, const char *name, - int flags); + unsigned int flags); /* * Internal logging API @@ -123,7 +124,8 @@ extern int virLogParseDefaultPriority(const char *priority); extern int virLogParseFilters(const char *filters); extern int virLogParseOutputs(const char *output); extern void virLogMessage(const char *category, int priority, - const char *funcname, long long linenr, int flags, + const char *funcname, long long linenr, + unsigned int flags, const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(6, 7); extern int virLogSetBufferSize(int size); extern void virLogEmergencyDumpAll(int signum); -- 1.7.4.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list