[libvirt] [PATCH 03/28] global: consistently use IP rather than Ip in identifiers

John Ferlan jferlan at redhat.com
Thu Jun 23 20:25:51 UTC 2016



On 06/22/2016 01:37 PM, Laine Stump wrote:
> I'm tired of mistyping this all the time, so let's do it the same all
> the time (similar to how we changed all "Pci" to "PCI" awhile back).
> 
> (NB: I've left alone some things in the esx and vbox drivers because
> I'm unable to compile them and they weren't obviously *not* a part of
> some API. I also didn't change a couple of variables named,
> e.g. "somethingIptables", because they were derived from the name of
> the "iptables" command)
> ---
>  src/conf/domain_conf.c                    | 24 +++++-----
>  src/conf/domain_conf.h                    | 12 ++---
>  src/conf/interface_conf.c                 | 38 +++++++--------
>  src/conf/interface_conf.h                 |  8 ++--
>  src/conf/network_conf.c                   | 80 +++++++++++++++----------------
>  src/conf/network_conf.h                   | 20 ++++----
>  src/conf/networkcommon_conf.c             |  6 +--
>  src/esx/esx_driver.c                      | 44 ++++++++---------
>  src/esx/esx_interface_driver.c            |  4 +-
>  src/esx/esx_vi.c                          |  4 +-
>  src/esx/esx_vi.h                          |  2 +-
>  src/libvirt_private.syms                  | 10 ++--
>  src/lxc/lxc_container.c                   |  2 +-
>  src/lxc/lxc_native.c                      |  4 +-
>  src/network/bridge_driver.c               | 74 ++++++++++++++--------------
>  src/network/bridge_driver_linux.c         | 70 +++++++++++++--------------
>  src/nwfilter/nwfilter_ebiptables_driver.c | 24 +++++-----
>  src/openvz/openvz_conf.c                  |  2 +-
>  src/qemu/qemu_driver.c                    |  2 +-
>  src/util/virsocketaddr.c                  |  4 +-
>  src/util/virsocketaddr.h                  |  2 +-
>  src/vbox/vbox_network.c                   |  8 ++--
>  src/xenconfig/xen_common.c                |  2 +-
>  src/xenconfig/xen_sxpr.c                  |  4 +-
>  24 files changed, 225 insertions(+), 225 deletions(-)
> 

It's a type "A" type change ;-)

I think I am going to need that eye exam after all...

[...]


> diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
> index 26e55cc..40f1958 100644
> --- a/src/conf/interface_conf.c
> +++ b/src/conf/interface_conf.c
> @@ -45,7 +45,7 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def,
>                           virInterfaceType parentIfType);
>  
>  static
> -void virInterfaceIpDefFree(virInterfaceIpDefPtr def)
> +void virInterfaceIPDefFree(virInterfaceIPDefPtr def)
>  {
>      if (def == NULL)
>          return;
> @@ -61,7 +61,7 @@ void virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def)
>      if (def == NULL)
>          return;
>      for (i = 0; i < def->nips; i++)
> -        virInterfaceIpDefFree(def->ips[i]);
> +        virInterfaceIPDefFree(def->ips[i]);
>      VIR_FREE(def->ips);
>      VIR_FREE(def->family);
>      VIR_FREE(def->gateway);
> @@ -281,7 +281,7 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def,
>  }
>  
>  static int
> -virInterfaceDefParseIp(virInterfaceIpDefPtr def,
> +virInterfaceDefParseIP(virInterfaceIPDefPtr def,
>                         xmlXPathContextPtr ctxt)
>  {
>      int ret = 0;
> @@ -310,7 +310,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
>  {
>      xmlNodePtr dhcp;
>      xmlNodePtr *ipNodes = NULL;
> -    int nIpNodes, ret = -1;
> +    int nIPNodes, ret = -1;

You changed a variable name here which while I suppose is correct leads
me to wonder why "ipNodes" wasn't changed as well.

In the long run though, in whatever manner "ip" is used, it should be
consistent between "n[ip|IP]Nodes" and [ip|IP]Nodes... I'd lean towards
ipNodes and nipNodes...


>      size_t i;
>      char *tmp;
>  
> @@ -323,26 +323,26 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
>              return -1;
>      }
>  
> -    nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);
> -    if (nIpNodes < 0)
> +    nIPNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);
> +    if (nIPNodes < 0)
>          return -1;
>      if (ipNodes == NULL)
>          return 0;
>  
> -    if (VIR_ALLOC_N(def->ips, nIpNodes) < 0)
> +    if (VIR_ALLOC_N(def->ips, nIPNodes) < 0)
>          goto error;
>  
>      def->nips = 0;
> -    for (i = 0; i < nIpNodes; i++) {
> +    for (i = 0; i < nIPNodes; i++) {
>  
> -        virInterfaceIpDefPtr ip;
> +        virInterfaceIPDefPtr ip;
>  
>          if (VIR_ALLOC(ip) < 0)
>              goto error;
>  
>          ctxt->node = ipNodes[i];
> -        if (virInterfaceDefParseIp(ip, ctxt) < 0) {
> -            virInterfaceIpDefFree(ip);
> +        if (virInterfaceDefParseIP(ip, ctxt) < 0) {
> +            virInterfaceIPDefFree(ip);
>              goto error;
>          }
>          def->ips[def->nips++] = ip;
> @@ -361,7 +361,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
>  {
>      xmlNodePtr dhcp, autoconf;
>      xmlNodePtr *ipNodes = NULL;
> -    int nIpNodes, ret = -1;
> +    int nIPNodes, ret = -1;

Same here.

>      size_t i;
>      char *tmp;
>  
> @@ -378,26 +378,26 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
>              return -1;
>      }
>  
> -    nIpNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);
> -    if (nIpNodes < 0)
> +    nIPNodes = virXPathNodeSet("./ip", ctxt, &ipNodes);
> +    if (nIPNodes < 0)
>          return -1;
>      if (ipNodes == NULL)
>          return 0;
>  
> -    if (VIR_ALLOC_N(def->ips, nIpNodes) < 0)
> +    if (VIR_ALLOC_N(def->ips, nIPNodes) < 0)
>          goto error;
>  
>      def->nips = 0;
> -    for (i = 0; i < nIpNodes; i++) {
> +    for (i = 0; i < nIPNodes; i++) {
>  
> -        virInterfaceIpDefPtr ip;
> +        virInterfaceIPDefPtr ip;
>  
>          if (VIR_ALLOC(ip) < 0)
>              goto error;
>  
>          ctxt->node = ipNodes[i];
> -        if (virInterfaceDefParseIp(ip, ctxt) < 0) {
> -            virInterfaceIpDefFree(ip);
> +        if (virInterfaceDefParseIP(ip, ctxt) < 0) {
> +            virInterfaceIPDefFree(ip);
>              goto error;
>          }
>          def->ips[def->nips++] = ip;

[...]


> diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
> index 02b8cd7..5ae2bdf 100644
> --- a/src/conf/network_conf.c
> +++ b/src/conf/network_conf.c

[...]


>  
> @@ -2050,7 +2050,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>      xmlNodePtr *ipNodes = NULL;
>      xmlNodePtr *routeNodes = NULL;
>      xmlNodePtr *portGroupNodes = NULL;
> -    int nIps, nPortGroups, nRoutes;
> +    int nips, nPortGroups, nRoutes;

nips "could be" nipNodes

Your call - since you're here anyway dealing with consistency.

ACK - w/ at least the other one changed - if it causes too much of a
ripple effect later on (I haven't peeked ahead)...

John

>      xmlNodePtr dnsNode = NULL;
>      xmlNodePtr virtPortNode = NULL;
>      xmlNodePtr forwardNode = NULL;
> @@ -2227,18 +2227,18 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>      }
>      VIR_FREE(portGroupNodes);
>  
> -    nIps = virXPathNodeSet("./ip", ctxt, &ipNodes);
> -    if (nIps < 0)
> +    nips = virXPathNodeSet("./ip", ctxt, &ipNodes);
> +    if (nips < 0)
>          goto error;
>  
> -    if (nIps > 0) {
> +    if (nips > 0) {
>          size_t i;
>  
>          /* allocate array to hold all the addrs */
> -        if (VIR_ALLOC_N(def->ips, nIps) < 0)
> +        if (VIR_ALLOC_N(def->ips, nips) < 0)
>              goto error;
>          /* parse each addr */
> -        for (i = 0; i < nIps; i++) {
> +        for (i = 0; i < nips; i++) {
>              if (virNetworkIPDefParseXML(def->name,
>                                          ipNodes[i],
>                                          ctxt,
> @@ -2278,7 +2278,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>           * is directly reachable from this bridge.
>           */
>          nRoutes = def->nroutes;
> -        nIps = def->nips;
> +        nips = def->nips;
>          for (i = 0; i < nRoutes; i++) {
>              size_t j;
>              virSocketAddr testAddr, testGw;
> @@ -2286,13 +2286,13 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
>              virNetworkRouteDefPtr gwdef = def->routes[i];
>              virSocketAddrPtr gateway = virNetworkRouteDefGetGateway(gwdef);
>              addrMatch = false;
> -            for (j = 0; j < nIps; j++) {
> -                virNetworkIpDefPtr def2 = &def->ips[j];
> +            for (j = 0; j < nips; j++) {
> +                virNetworkIPDefPtr def2 = &def->ips[j];
>                  if (VIR_SOCKET_ADDR_FAMILY(gateway)
>                      != VIR_SOCKET_ADDR_FAMILY(&def2->address)) {
>                      continue;
>                  }
> -                int prefix = virNetworkIpDefPrefix(def2);
> +                int prefix = virNetworkIPDefPrefix(def2);
>                  virSocketAddrMaskByPrefix(&def2->address, prefix, &testAddr);
>                  virSocketAddrMaskByPrefix(gateway, prefix, &testGw);
>                  if (VIR_SOCKET_ADDR_VALID(&testAddr) &&


[...]




More information about the libvir-list mailing list