network: Adjust coding style for network conf sources

Alter the format of the code to follow more recent style guidelines of
two empty lines between functions, function decls with "[static] type"
on one line followed by function name with arguments to functions each
on one line.
This commit is contained in:
John Ferlan 2017-03-08 10:41:57 -05:00
parent bddbda99df
commit 0cf145b67e
2 changed files with 151 additions and 39 deletions

View File

@ -80,6 +80,7 @@ virPortGroupDefClear(virPortGroupDefPtr def)
def->bandwidth = NULL;
}
static void
virNetworkForwardIfDefClear(virNetworkForwardIfDefPtr def)
{
@ -87,12 +88,14 @@ virNetworkForwardIfDefClear(virNetworkForwardIfDefPtr def)
VIR_FREE(def->device.dev);
}
static void
virNetworkForwardPfDefClear(virNetworkForwardPfDefPtr def)
{
VIR_FREE(def->dev);
}
static void
virNetworkDHCPHostDefClear(virNetworkDHCPHostDefPtr def)
{
@ -101,6 +104,7 @@ virNetworkDHCPHostDefClear(virNetworkDHCPHostDefPtr def)
VIR_FREE(def->name);
}
static void
virNetworkIPDefClear(virNetworkIPDefPtr def)
{
@ -115,6 +119,7 @@ virNetworkIPDefClear(virNetworkIPDefPtr def)
VIR_FREE(def->bootfile);
}
static void
virNetworkDNSTxtDefClear(virNetworkDNSTxtDefPtr def)
{
@ -122,6 +127,7 @@ virNetworkDNSTxtDefClear(virNetworkDNSTxtDefPtr def)
VIR_FREE(def->value);
}
static void
virNetworkDNSHostDefClear(virNetworkDNSHostDefPtr def)
{
@ -130,6 +136,7 @@ virNetworkDNSHostDefClear(virNetworkDNSHostDefPtr def)
VIR_FREE(def->names);
}
static void
virNetworkDNSSrvDefClear(virNetworkDNSSrvDefPtr def)
{
@ -172,6 +179,7 @@ virNetworkDNSDefClear(virNetworkDNSDefPtr def)
}
}
static void
virNetworkForwardDefClear(virNetworkForwardDefPtr def)
{
@ -187,6 +195,7 @@ virNetworkForwardDefClear(virNetworkForwardDefPtr def)
def->nifs = def->npfs = 0;
}
void
virNetworkDefFree(virNetworkDefPtr def)
{
@ -225,6 +234,7 @@ virNetworkDefFree(virNetworkDefPtr def)
VIR_FREE(def);
}
/*
* virNetworkDefCopy:
* @def: NetworkDef to copy
@ -255,10 +265,12 @@ virNetworkDefCopy(virNetworkDefPtr def, unsigned int flags)
return newDef;
}
/* return ips[index], or NULL if there aren't enough ips */
virNetworkIPDefPtr
virNetworkDefGetIPByIndex(const virNetworkDef *def,
int family, size_t n)
int family,
size_t n)
{
size_t i;
@ -279,10 +291,12 @@ virNetworkDefGetIPByIndex(const virNetworkDef *def,
return NULL;
}
/* return routes[index], or NULL if there aren't enough routes */
virNetDevIPRoutePtr
virNetworkDefGetRouteByIndex(const virNetworkDef *def,
int family, size_t n)
int family,
size_t n)
{
size_t i;
@ -305,16 +319,19 @@ virNetworkDefGetRouteByIndex(const virNetworkDef *def,
return NULL;
}
/* return number of 1 bits in netmask for the network's ipAddress,
* or -1 on error
*/
int virNetworkIPDefPrefix(const virNetworkIPDef *def)
int
virNetworkIPDefPrefix(const virNetworkIPDef *def)
{
return virSocketAddrGetIPPrefix(&def->address,
&def->netmask,
def->prefix);
}
/* Fill in a virSocketAddr with the proper netmask for this
* definition, based on either the definition's netmask, or its
* prefix. Return -1 on error (and set the netmask family to AF_UNSPEC)
@ -374,6 +391,7 @@ virSocketAddrRangeParseXML(const char *networkName,
return ret;
}
static int
virNetworkDHCPHostDefParseXML(const char *networkName,
virNetworkIPDefPtr def,
@ -494,6 +512,7 @@ virNetworkDHCPHostDefParseXML(const char *networkName,
return ret;
}
static int
virNetworkDHCPDefParseXML(const char *networkName,
xmlNodePtr node,
@ -561,6 +580,7 @@ virNetworkDHCPDefParseXML(const char *networkName,
return ret;
}
static int
virNetworkDNSHostDefParseXML(const char *networkName,
xmlNodePtr node,
@ -628,6 +648,7 @@ virNetworkDNSHostDefParseXML(const char *networkName,
return -1;
}
/* This includes all characters used in the names of current
* /etc/services and /etc/protocols files (on Fedora 20), except ".",
* which we can't allow because it would conflict with the use of "."
@ -755,6 +776,7 @@ virNetworkDNSSrvDefParseXML(const char *networkName,
return -1;
}
static int
virNetworkDNSTxtDefParseXML(const char *networkName,
xmlNodePtr node,
@ -795,6 +817,7 @@ virNetworkDNSTxtDefParseXML(const char *networkName,
return -1;
}
static int
virNetworkDNSDefParseXML(const char *networkName,
xmlNodePtr node,
@ -953,6 +976,7 @@ virNetworkDNSDefParseXML(const char *networkName,
return ret;
}
static int
virNetworkIPDefParseXML(const char *networkName,
xmlNodePtr node,
@ -1108,6 +1132,7 @@ virNetworkIPDefParseXML(const char *networkName,
return result;
}
static int
virNetworkPortGroupParseXML(virPortGroupDefPtr def,
xmlNodePtr node,
@ -1179,6 +1204,7 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
return result;
}
static int
virNetworkForwardNatDefParseXML(const char *networkName,
xmlNodePtr node,
@ -1307,6 +1333,7 @@ virNetworkForwardNatDefParseXML(const char *networkName,
return ret;
}
static int
virNetworkForwardDefParseXML(const char *networkName,
xmlNodePtr node,
@ -1555,6 +1582,7 @@ virNetworkForwardDefParseXML(const char *networkName,
return ret;
}
virNetworkDefPtr
virNetworkDefParseXML(xmlXPathContextPtr ctxt)
{
@ -1966,6 +1994,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
return NULL;
}
static virNetworkDefPtr
virNetworkDefParse(const char *xmlStr,
const char *filename)
@ -1983,18 +2012,23 @@ virNetworkDefParse(const char *xmlStr,
return def;
}
virNetworkDefPtr virNetworkDefParseString(const char *xmlStr)
virNetworkDefPtr
virNetworkDefParseString(const char *xmlStr)
{
return virNetworkDefParse(xmlStr, NULL);
}
virNetworkDefPtr virNetworkDefParseFile(const char *filename)
virNetworkDefPtr
virNetworkDefParseFile(const char *filename)
{
return virNetworkDefParse(NULL, filename);
}
virNetworkDefPtr virNetworkDefParseNode(xmlDocPtr xml,
virNetworkDefPtr
virNetworkDefParseNode(xmlDocPtr xml,
xmlNodePtr root)
{
xmlXPathContextPtr ctxt = NULL;
@ -2129,6 +2163,7 @@ virNetworkDNSDefFormat(virBufferPtr buf,
return 0;
}
static int
virNetworkIPDefFormat(virBufferPtr buf,
const virNetworkIPDef *def)
@ -2230,6 +2265,7 @@ virNetworkIPDefFormat(virBufferPtr buf,
return result;
}
static int
virPortGroupDefFormat(virBufferPtr buf,
const virPortGroupDef *def)
@ -2252,6 +2288,7 @@ virPortGroupDefFormat(virBufferPtr buf,
return 0;
}
static int
virNetworkForwardNatDefFormat(virBufferPtr buf,
const virNetworkForwardDef *fwd)
@ -2302,6 +2339,7 @@ virNetworkForwardNatDefFormat(virBufferPtr buf,
return ret;
}
int
virNetworkDefFormatBuf(virBufferPtr buf,
const virNetworkDef *def,
@ -2516,6 +2554,7 @@ virNetworkDefFormatBuf(virBufferPtr buf,
return -1;
}
char *
virNetworkDefFormat(const virNetworkDef *def,
unsigned int flags)
@ -2535,15 +2574,19 @@ virNetworkDefFormat(const virNetworkDef *def,
return NULL;
}
const char *
virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
virNetworkDefForwardIf(const virNetworkDef *def,
size_t n)
{
return ((def->forward.ifs && (def->forward.nifs > n) &&
def->forward.ifs[n].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV)
? def->forward.ifs[n].device.dev : NULL);
}
virPortGroupDefPtr virPortGroupFindByName(virNetworkDefPtr net,
virPortGroupDefPtr
virPortGroupFindByName(virNetworkDefPtr net,
const char *portgroup)
{
size_t i;
@ -2559,7 +2602,9 @@ virPortGroupDefPtr virPortGroupFindByName(virNetworkDefPtr net,
return NULL;
}
int virNetworkSaveXML(const char *configDir,
int
virNetworkSaveXML(const char *configDir,
virNetworkDefPtr def,
const char *xml)
{
@ -2587,7 +2632,9 @@ int virNetworkSaveXML(const char *configDir,
return ret;
}
int virNetworkSaveConfig(const char *configDir,
int
virNetworkSaveConfig(const char *configDir,
virNetworkDefPtr def)
{
int ret = -1;
@ -2605,7 +2652,9 @@ int virNetworkSaveConfig(const char *configDir,
return ret;
}
char *virNetworkConfigFile(const char *dir,
char *
virNetworkConfigFile(const char *dir,
const char *name)
{
char *ret = NULL;
@ -2614,7 +2663,9 @@ char *virNetworkConfigFile(const char *dir,
return ret;
}
void virNetworkSetBridgeMacAddr(virNetworkDefPtr def)
void
virNetworkSetBridgeMacAddr(virNetworkDefPtr def)
{
if (!def->mac_specified) {
/* if the bridge doesn't have a mac address explicitly defined,
@ -2626,6 +2677,7 @@ void virNetworkSetBridgeMacAddr(virNetworkDefPtr def)
}
}
/* NetworkObj backend of the virNetworkUpdate API */
static void
@ -2636,6 +2688,7 @@ virNetworkDefUpdateNoSupport(virNetworkDefPtr def, const char *section)
section, def->name);
}
static void
virNetworkDefUpdateUnknownCommand(unsigned int command)
{
@ -2643,6 +2696,7 @@ virNetworkDefUpdateUnknownCommand(unsigned int command)
_("unrecognized network update command code %d"), command);
}
static int
virNetworkDefUpdateCheckElementName(virNetworkDefPtr def,
xmlNodePtr node,
@ -2658,6 +2712,7 @@ virNetworkDefUpdateCheckElementName(virNetworkDefPtr def,
return 0;
}
static int
virNetworkDefUpdateBridge(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -2670,6 +2725,7 @@ virNetworkDefUpdateBridge(virNetworkDefPtr def,
return -1;
}
static int
virNetworkDefUpdateDomain(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -2682,6 +2738,7 @@ virNetworkDefUpdateDomain(virNetworkDefPtr def,
return -1;
}
static int
virNetworkDefUpdateIP(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -2694,6 +2751,7 @@ virNetworkDefUpdateIP(virNetworkDefPtr def,
return -1;
}
static virNetworkIPDefPtr
virNetworkIPDefByIndex(virNetworkDefPtr def, int parentIndex)
{
@ -2897,6 +2955,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
return ret;
}
static int
virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
unsigned int command,
@ -2998,6 +3057,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def,
return ret;
}
static int
virNetworkDefUpdateForward(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -3010,6 +3070,7 @@ virNetworkDefUpdateForward(virNetworkDefPtr def,
return -1;
}
static int
virNetworkDefUpdateForwardInterface(virNetworkDefPtr def,
unsigned int command,
@ -3104,6 +3165,7 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def,
return ret;
}
static int
virNetworkDefUpdateForwardPF(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -3116,6 +3178,7 @@ virNetworkDefUpdateForwardPF(virNetworkDefPtr def,
return -1;
}
static int
virNetworkDefUpdatePortGroup(virNetworkDefPtr def,
unsigned int command,
@ -3210,6 +3273,7 @@ virNetworkDefUpdatePortGroup(virNetworkDefPtr def,
return ret;
}
static int
virNetworkDefUpdateDNSHost(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -3304,6 +3368,7 @@ virNetworkDefUpdateDNSHost(virNetworkDefPtr def,
return ret;
}
static int
virNetworkDefUpdateDNSSrv(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -3390,6 +3455,7 @@ virNetworkDefUpdateDNSSrv(virNetworkDefPtr def,
return ret;
}
static int
virNetworkDefUpdateDNSTxt(virNetworkDefPtr def,
unsigned int command ATTRIBUTE_UNUSED,
@ -3463,6 +3529,7 @@ virNetworkDefUpdateDNSTxt(virNetworkDefPtr def,
return ret;
}
int
virNetworkDefUpdateSection(virNetworkDefPtr def,
unsigned int command, /* virNetworkUpdateCommand */

View File

@ -48,7 +48,8 @@ static virClassPtr virNetworkObjListClass;
static void virNetworkObjDispose(void *obj);
static void virNetworkObjListDispose(void *obj);
static int virNetworkObjOnceInit(void)
static int
virNetworkObjOnceInit(void)
{
if (!(virNetworkObjClass = virClassNew(virClassForObjectLockable(),
"virNetworkObj",
@ -93,6 +94,7 @@ virNetworkObjNew(void)
return NULL;
}
void
virNetworkObjEndAPI(virNetworkObjPtr *net)
{
@ -104,7 +106,9 @@ virNetworkObjEndAPI(virNetworkObjPtr *net)
*net = NULL;
}
virNetworkObjListPtr virNetworkObjListNew(void)
virNetworkObjListPtr
virNetworkObjListNew(void)
{
virNetworkObjListPtr nets;
@ -122,6 +126,7 @@ virNetworkObjListPtr virNetworkObjListNew(void)
return nets;
}
/**
* virNetworkObjFindByUUIDLocked:
* @nets: list of network objects
@ -146,6 +151,7 @@ virNetworkObjFindByUUIDLocked(virNetworkObjListPtr nets,
return ret;
}
/**
* virNetworkObjFindByUUID:
* @nets: list of network objects
@ -170,6 +176,7 @@ virNetworkObjFindByUUID(virNetworkObjListPtr nets,
return ret;
}
static int
virNetworkObjSearchName(const void *payload,
const void *name ATTRIBUTE_UNUSED,
@ -185,6 +192,7 @@ virNetworkObjSearchName(const void *payload,
return want;
}
/*
* virNetworkObjFindByNameLocked:
* @nets: list of network objects
@ -206,6 +214,7 @@ virNetworkObjFindByNameLocked(virNetworkObjListPtr nets,
return ret;
}
/**
* virNetworkObjFindByName:
* @nets: list of network objects
@ -230,6 +239,7 @@ virNetworkObjFindByName(virNetworkObjListPtr nets,
return ret;
}
bool
virNetworkObjTaint(virNetworkObjPtr obj,
virNetworkTaintFlags taint)
@ -255,6 +265,7 @@ virNetworkObjDispose(void *obj)
virObjectUnref(net->macmap);
}
static void
virNetworkObjListDispose(void *obj)
{
@ -263,6 +274,7 @@ virNetworkObjListDispose(void *obj)
virHashFree(nets->objs);
}
/*
* virNetworkObjAssignDef:
* @network: the network object to update
@ -324,6 +336,7 @@ virNetworkObjAssignDef(virNetworkObjPtr network,
}
}
/*
* If flags & VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE then this will
* refuse updating an existing def if the current def is live
@ -401,6 +414,7 @@ virNetworkAssignDefLocked(virNetworkObjListPtr nets,
return ret;
}
/*
* virNetworkAssignDef:
* @nets: list of all networks
@ -429,6 +443,7 @@ virNetworkAssignDef(virNetworkObjListPtr nets,
return network;
}
/*
* virNetworkObjSetDefTransient:
* @network: network object pointer
@ -444,7 +459,8 @@ virNetworkAssignDef(virNetworkObjListPtr nets,
* Returns 0 on success, -1 on failure
*/
int
virNetworkObjSetDefTransient(virNetworkObjPtr network, bool live)
virNetworkObjSetDefTransient(virNetworkObjPtr network,
bool live)
{
if (!virNetworkObjIsActive(network) && !live)
return 0;
@ -456,6 +472,7 @@ virNetworkObjSetDefTransient(virNetworkObjPtr network, bool live)
return network->newDef ? 0 : -1;
}
/* virNetworkObjUnsetDefTransient:
*
* This *undoes* what virNetworkObjSetDefTransient did.
@ -470,6 +487,7 @@ virNetworkObjUnsetDefTransient(virNetworkObjPtr network)
}
}
/*
* virNetworkObjGetPersistentDef:
* @network: network object pointer
@ -488,6 +506,7 @@ virNetworkObjGetPersistentDef(virNetworkObjPtr network)
return network->def;
}
/*
* virNetworkObjReplacePersistentDef:
* @network: network object pointer
@ -513,6 +532,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
return 0;
}
/*
* virNetworkConfigChangeSetup:
*
@ -525,7 +545,8 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
* Returns 0 on success, -1 on error.
*/
int
virNetworkConfigChangeSetup(virNetworkObjPtr network, unsigned int flags)
virNetworkConfigChangeSetup(virNetworkObjPtr network,
unsigned int flags)
{
bool isActive;
int ret = -1;
@ -557,7 +578,9 @@ virNetworkConfigChangeSetup(virNetworkObjPtr network, unsigned int flags)
return ret;
}
void virNetworkRemoveInactive(virNetworkObjListPtr nets,
void
virNetworkRemoveInactive(virNetworkObjListPtr nets,
virNetworkObjPtr net)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
@ -572,6 +595,7 @@ void virNetworkRemoveInactive(virNetworkObjListPtr nets,
virObjectUnref(net);
}
static char *
virNetworkObjFormat(virNetworkObjPtr net,
unsigned int flags)
@ -611,7 +635,9 @@ virNetworkObjFormat(virNetworkObjPtr net,
return NULL;
}
int virNetworkSaveStatus(const char *statusDir,
int
virNetworkSaveStatus(const char *statusDir,
virNetworkObjPtr network)
{
int ret = -1;
@ -630,6 +656,7 @@ int virNetworkSaveStatus(const char *statusDir,
return ret;
}
virNetworkObjPtr
virNetworkLoadState(virNetworkObjListPtr nets,
const char *stateDir,
@ -754,7 +781,9 @@ virNetworkLoadState(virNetworkObjListPtr nets,
goto cleanup;
}
virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets,
virNetworkObjPtr
virNetworkLoadConfig(virNetworkObjListPtr nets,
const char *configDir,
const char *autostartDir,
const char *name)
@ -843,7 +872,8 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
}
int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
int
virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
const char *configDir,
const char *autostartDir)
{
@ -874,7 +904,9 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
return ret;
}
int virNetworkDeleteConfig(const char *configDir,
int
virNetworkDeleteConfig(const char *configDir,
const char *autostartDir,
virNetworkObjPtr net)
{
@ -906,6 +938,7 @@ int virNetworkDeleteConfig(const char *configDir,
return ret;
}
struct virNetworkBridgeInUseHelperData {
const char *bridge;
const char *skipname;
@ -936,7 +969,9 @@ virNetworkBridgeInUseHelper(const void *payload,
return ret;
}
int virNetworkBridgeInUse(virNetworkObjListPtr nets,
int
virNetworkBridgeInUse(virNetworkObjListPtr nets,
const char *bridge,
const char *skipname)
{
@ -1037,6 +1072,7 @@ virNetworkObjUpdate(virNetworkObjPtr network,
return ret;
}
#define MATCH(FLAG) (flags & (FLAG))
static bool
virNetworkMatch(virNetworkObjPtr netobj,
@ -1070,6 +1106,7 @@ virNetworkMatch(virNetworkObjPtr netobj,
}
#undef MATCH
struct virNetworkObjListData {
virConnectPtr conn;
virNetworkPtr *nets;
@ -1117,6 +1154,7 @@ virNetworkObjListPopulate(void *payload,
return 0;
}
int
virNetworkObjListExport(virConnectPtr conn,
virNetworkObjListPtr netobjs,
@ -1153,6 +1191,7 @@ virNetworkObjListExport(virConnectPtr conn,
return ret;
}
struct virNetworkObjListForEachHelperData {
virNetworkObjListIterator callback;
void *opaque;
@ -1171,6 +1210,7 @@ virNetworkObjListForEachHelper(void *payload,
return 0;
}
/**
* virNetworkObjListForEach:
* @nets: a list of network objects
@ -1196,6 +1236,7 @@ virNetworkObjListForEach(virNetworkObjListPtr nets,
return data.ret;
}
struct virNetworkObjListGetHelperData {
virConnectPtr conn;
virNetworkObjListFilter filter;
@ -1242,6 +1283,7 @@ virNetworkObjListGetHelper(void *payload,
return 0;
}
int
virNetworkObjListGetNames(virNetworkObjListPtr nets,
bool active,
@ -1271,6 +1313,7 @@ virNetworkObjListGetNames(virNetworkObjListPtr nets,
return ret;
}
int
virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
bool active,
@ -1287,6 +1330,7 @@ virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets,
return data.got;
}
struct virNetworkObjListPruneHelperData {
unsigned int flags;
};
@ -1306,6 +1350,7 @@ virNetworkObjListPruneHelper(const void *payload,
return want;
}
/**
* virNetworkObjListPrune:
* @nets: a list of network objects