Re: [PATCH V2 1/2] maint: define a macro for IPv4 loopback address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/19/2017 11:33 PM, Jim Fehlig wrote:
> Use a macro instead of hardcoding "127.0.0.1" throughout the
> sources.
> 
> Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>

Reviewed-by: Joao Martins <joao.m.martins@xxxxxxxxxx>

> ---
>  src/internal.h           | 2 ++
>  src/qemu/qemu_conf.c     | 4 ++--
>  src/util/virsocketaddr.c | 4 ++--
>  src/vz/vz_sdk.c          | 2 +-
>  4 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/src/internal.h b/src/internal.h
> index 9e7ef553d..03a973ccd 100644
> --- a/src/internal.h
> +++ b/src/internal.h
> @@ -79,6 +79,8 @@
>  #  define INET_ADDRSTRLEN 16
>  # endif
>  
> +# define VIR_LOOPBACK_IPV4_ADDR "127.0.0.1"
> +
>  /* String equality tests, suggested by Jim Meyering. */
>  # define STREQ(a, b) (strcmp(a, b) == 0)
>  # define STRCASEEQ(a, b) (c_strcasecmp(a, b) == 0)
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 1b704daa5..19ddf787d 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -250,10 +250,10 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
>                     SYSCONFDIR "/pki/qemu") < 0)
>          goto error;
>  
> -    if (VIR_STRDUP(cfg->vncListen, "127.0.0.1") < 0)
> +    if (VIR_STRDUP(cfg->vncListen, VIR_LOOPBACK_IPV4_ADDR) < 0)
>          goto error;
>  
> -    if (VIR_STRDUP(cfg->spiceListen, "127.0.0.1") < 0)
> +    if (VIR_STRDUP(cfg->spiceListen, VIR_LOOPBACK_IPV4_ADDR) < 0)
>          goto error;
>  
>      /*
> diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
> index 41f75d5c2..9dffbc736 100644
> --- a/src/util/virsocketaddr.c
> +++ b/src/util/virsocketaddr.c
> @@ -383,11 +383,11 @@ virSocketAddrFormatFull(const virSocketAddr *addr,
>       * nicely for UNIX sockets */
>      if (addr->data.sa.sa_family == AF_UNIX) {
>          if (withService) {
> -            if (virAsprintf(&addrstr, "127.0.0.1%s0",
> +            if (virAsprintf(&addrstr, VIR_LOOPBACK_IPV4_ADDR"%s0",
>                              separator ? separator : ":") < 0)
>                  goto error;
>          } else {
> -            if (VIR_STRDUP(addrstr, "127.0.0.1") < 0)
> +            if (VIR_STRDUP(addrstr, VIR_LOOPBACK_IPV4_ADDR) < 0)
>                  goto error;
>          }
>          return addrstr;
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index 4d2c6b0f1..4fab3b9bf 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -3084,7 +3084,7 @@ static int prlsdkApplyGraphicsParams(PRL_HANDLE sdkdom,
>  
>      glisten = virDomainGraphicsGetListen(gr, 0);
>      pret = PrlVmCfg_SetVNCHostName(sdkdom, glisten && glisten->address ?
> -                                           glisten->address : "127.0.0.1");
> +                                           glisten->address : VIR_LOOPBACK_IPV4_ADDR);
>      prlsdkCheckRetGoto(pret, cleanup);
>  
>      ret = 0;
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux