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. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/network_conf.c | 103 ++++++++++++++++++++++++++++++++++++++--------- src/conf/virnetworkobj.c | 87 +++++++++++++++++++++++++++++---------- 2 files changed, 151 insertions(+), 39 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index f3e0622..3ebf67f 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -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,19 +2012,24 @@ 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, - xmlNodePtr root) +virNetworkDefPtr +virNetworkDefParseNode(xmlDocPtr xml, + xmlNodePtr root) { xmlXPathContextPtr ctxt = NULL; virNetworkDefPtr def = 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,16 +2574,20 @@ 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, - const char *portgroup) + +virPortGroupDefPtr +virPortGroupFindByName(virNetworkDefPtr net, + const char *portgroup) { size_t i; for (i = 0; i < net->nPortGroups; i++) { @@ -2559,9 +2602,11 @@ virPortGroupDefPtr virPortGroupFindByName(virNetworkDefPtr net, return NULL; } -int virNetworkSaveXML(const char *configDir, - virNetworkDefPtr def, - const char *xml) + +int +virNetworkSaveXML(const char *configDir, + virNetworkDefPtr def, + const char *xml) { char uuidstr[VIR_UUID_STRING_BUFLEN]; char *configFile = NULL; @@ -2587,8 +2632,10 @@ int virNetworkSaveXML(const char *configDir, return ret; } -int virNetworkSaveConfig(const char *configDir, - virNetworkDefPtr def) + +int +virNetworkSaveConfig(const char *configDir, + virNetworkDefPtr def) { int ret = -1; char *xml; @@ -2605,8 +2652,10 @@ int virNetworkSaveConfig(const char *configDir, return ret; } -char *virNetworkConfigFile(const char *dir, - const char *name) + +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 */ diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index 10cc73b..3b5f27d 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -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) @@ -254,6 +264,7 @@ virNetworkObjDispose(void *obj) virBitmapFree(net->class_id); } + static void virNetworkObjListDispose(void *obj) { @@ -262,6 +273,7 @@ virNetworkObjListDispose(void *obj) virHashFree(nets->objs); } + /* * virNetworkObjAssignDef: * @network: the network object to update @@ -323,6 +335,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 @@ -400,6 +413,7 @@ virNetworkAssignDefLocked(virNetworkObjListPtr nets, return ret; } + /* * virNetworkAssignDef: * @nets: list of all networks @@ -428,6 +442,7 @@ virNetworkAssignDef(virNetworkObjListPtr nets, return network; } + /* * virNetworkObjSetDefTransient: * @network: network object pointer @@ -443,7 +458,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; @@ -455,6 +471,7 @@ virNetworkObjSetDefTransient(virNetworkObjPtr network, bool live) return network->newDef ? 0 : -1; } + /* virNetworkObjUnsetDefTransient: * * This *undoes* what virNetworkObjSetDefTransient did. @@ -469,6 +486,7 @@ virNetworkObjUnsetDefTransient(virNetworkObjPtr network) } } + /* * virNetworkObjGetPersistentDef: * @network: network object pointer @@ -487,6 +505,7 @@ virNetworkObjGetPersistentDef(virNetworkObjPtr network) return network->def; } + /* * virNetworkObjReplacePersistentDef: * @network: network object pointer @@ -512,6 +531,7 @@ virNetworkObjReplacePersistentDef(virNetworkObjPtr network, return 0; } + /* * virNetworkConfigChangeSetup: * @@ -524,7 +544,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; @@ -556,8 +577,10 @@ virNetworkConfigChangeSetup(virNetworkObjPtr network, unsigned int flags) return ret; } -void virNetworkRemoveInactive(virNetworkObjListPtr nets, - virNetworkObjPtr net) + +void +virNetworkRemoveInactive(virNetworkObjListPtr nets, + virNetworkObjPtr net) { char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -571,6 +594,7 @@ void virNetworkRemoveInactive(virNetworkObjListPtr nets, virObjectUnref(net); } + static char * virNetworkObjFormat(virNetworkObjPtr net, unsigned int flags) @@ -610,8 +634,10 @@ virNetworkObjFormat(virNetworkObjPtr net, return NULL; } -int virNetworkSaveStatus(const char *statusDir, - virNetworkObjPtr network) + +int +virNetworkSaveStatus(const char *statusDir, + virNetworkObjPtr network) { int ret = -1; int flags = 0; @@ -629,6 +655,7 @@ int virNetworkSaveStatus(const char *statusDir, return ret; } + virNetworkObjPtr virNetworkLoadState(virNetworkObjListPtr nets, const char *stateDir, @@ -753,10 +780,12 @@ virNetworkLoadState(virNetworkObjListPtr nets, goto cleanup; } -virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets, - const char *configDir, - const char *autostartDir, - const char *name) + +virNetworkObjPtr +virNetworkLoadConfig(virNetworkObjListPtr nets, + const char *configDir, + const char *autostartDir, + const char *name) { char *configFile = NULL, *autostartLink = NULL; virNetworkDefPtr def = NULL; @@ -842,9 +871,10 @@ virNetworkLoadAllState(virNetworkObjListPtr nets, } -int virNetworkLoadAllConfigs(virNetworkObjListPtr nets, - const char *configDir, - const char *autostartDir) +int +virNetworkLoadAllConfigs(virNetworkObjListPtr nets, + const char *configDir, + const char *autostartDir) { DIR *dir; struct dirent *entry; @@ -873,9 +903,11 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets, return ret; } -int virNetworkDeleteConfig(const char *configDir, - const char *autostartDir, - virNetworkObjPtr net) + +int +virNetworkDeleteConfig(const char *configDir, + const char *autostartDir, + virNetworkObjPtr net) { char *configFile = NULL; char *autostartLink = NULL; @@ -905,6 +937,7 @@ int virNetworkDeleteConfig(const char *configDir, return ret; } + struct virNetworkBridgeInUseHelperData { const char *bridge; const char *skipname; @@ -935,9 +968,11 @@ virNetworkBridgeInUseHelper(const void *payload, return ret; } -int virNetworkBridgeInUse(virNetworkObjListPtr nets, - const char *bridge, - const char *skipname) + +int +virNetworkBridgeInUse(virNetworkObjListPtr nets, + const char *bridge, + const char *skipname) { virNetworkObjPtr obj; struct virNetworkBridgeInUseHelperData data = {bridge, skipname}; @@ -1036,6 +1071,7 @@ virNetworkObjUpdate(virNetworkObjPtr network, return ret; } + #define MATCH(FLAG) (flags & (FLAG)) static bool virNetworkMatch(virNetworkObjPtr netobj, @@ -1069,6 +1105,7 @@ virNetworkMatch(virNetworkObjPtr netobj, } #undef MATCH + struct virNetworkObjListData { virConnectPtr conn; virNetworkPtr *nets; @@ -1116,6 +1153,7 @@ virNetworkObjListPopulate(void *payload, return 0; } + int virNetworkObjListExport(virConnectPtr conn, virNetworkObjListPtr netobjs, @@ -1152,6 +1190,7 @@ virNetworkObjListExport(virConnectPtr conn, return ret; } + struct virNetworkObjListForEachHelperData { virNetworkObjListIterator callback; void *opaque; @@ -1170,6 +1209,7 @@ virNetworkObjListForEachHelper(void *payload, return 0; } + /** * virNetworkObjListForEach: * @nets: a list of network objects @@ -1195,6 +1235,7 @@ virNetworkObjListForEach(virNetworkObjListPtr nets, return data.ret; } + struct virNetworkObjListGetHelperData { virConnectPtr conn; virNetworkObjListFilter filter; @@ -1241,6 +1282,7 @@ virNetworkObjListGetHelper(void *payload, return 0; } + int virNetworkObjListGetNames(virNetworkObjListPtr nets, bool active, @@ -1270,6 +1312,7 @@ virNetworkObjListGetNames(virNetworkObjListPtr nets, return ret; } + int virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets, bool active, @@ -1286,6 +1329,7 @@ virNetworkObjListNumOfNetworks(virNetworkObjListPtr nets, return data.got; } + struct virNetworkObjListPruneHelperData { unsigned int flags; }; @@ -1305,6 +1349,7 @@ virNetworkObjListPruneHelper(const void *payload, return want; } + /** * virNetworkObjListPrune: * @nets: a list of network objects -- 2.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list