[PATCH 2/3] network: Drop const for forwardIf in pfAddNatFirewallRules()

Michal Privoznik via Devel posted 3 patches 3 weeks, 2 days ago
[PATCH 2/3] network: Drop const for forwardIf in pfAddNatFirewallRules()
Posted by Michal Privoznik via Devel 3 weeks, 2 days ago
From: Michal Privoznik <mprivozn@redhat.com>

The 'forwardIf' variable inside of pfAddNatFirewallRules() is
declared as both g_autofree and const. This makes no sense.
Since the variable is g_strdup()-ed into right in the
declaration, it's not const. Drop that part of variable
declaration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/network/network_pf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network/network_pf.c b/src/network/network_pf.c
index 34e2f60e82..724b82c054 100644
--- a/src/network/network_pf.c
+++ b/src/network/network_pf.c
@@ -165,7 +165,7 @@ pfAddNatFirewallRules(virNetworkDef *def,
      * block log on virbr0
      */
     int prefix = virNetworkIPDefPrefix(ipdef);
-    g_autofree const char *forwardIf = g_strdup(virNetworkDefForwardIf(def, 0));
+    g_autofree char *forwardIf = g_strdup(virNetworkDefForwardIf(def, 0));
     g_auto(virBuffer) pf_rules_buf = VIR_BUFFER_INITIALIZER;
     g_autoptr(virCommand) cmd = virCommandNew(PFCTL);
     g_autoptr(virCommand) flush_cmd = virCommandNew(PFCTL);
-- 
2.52.0
Re: [PATCH 2/3] network: Drop const for forwardIf in pfAddNatFirewallRules()
Posted by Roman Bogorodskiy 3 weeks, 2 days ago
  Michal Privoznik via Devel wrote:

> From: Michal Privoznik <mprivozn@redhat.com>
> 
> The 'forwardIf' variable inside of pfAddNatFirewallRules() is
> declared as both g_autofree and const. This makes no sense.
> Since the variable is g_strdup()-ed into right in the
> declaration, it's not const. Drop that part of variable
> declaration.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/network/network_pf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/network/network_pf.c b/src/network/network_pf.c
> index 34e2f60e82..724b82c054 100644
> --- a/src/network/network_pf.c
> +++ b/src/network/network_pf.c
> @@ -165,7 +165,7 @@ pfAddNatFirewallRules(virNetworkDef *def,
>       * block log on virbr0
>       */
>      int prefix = virNetworkIPDefPrefix(ipdef);
> -    g_autofree const char *forwardIf = g_strdup(virNetworkDefForwardIf(def, 0));
> +    g_autofree char *forwardIf = g_strdup(virNetworkDefForwardIf(def, 0));
>      g_auto(virBuffer) pf_rules_buf = VIR_BUFFER_INITIALIZER;
>      g_autoptr(virCommand) cmd = virCommandNew(PFCTL);
>      g_autoptr(virCommand) flush_cmd = virCommandNew(PFCTL);
> -- 
> 2.52.0
> 

Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>