[PATCH 16/25] squash into 'network: convert local pointers to g_auto*'

Laine Stump posted 25 patches 5 years, 7 months ago
[PATCH 16/25] squash into 'network: convert local pointers to g_auto*'
Posted by Laine Stump 5 years, 7 months ago
Signed-off-by: Laine Stump <laine@redhat.com>
---
 src/network/bridge_driver_linux.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
index 0d0ac730f2..7f765bcf99 100644
--- a/src/network/bridge_driver_linux.c
+++ b/src/network/bridge_driver_linux.c
@@ -834,7 +834,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
 {
     size_t i;
     virNetworkIPDefPtr ipdef;
-    g_autoptr(virFirewall) fw = NULL;
+    g_autoptr(virFirewall) fw = virFirewallNew();
 
     if (virOnce(&createdOnce, networkSetupPrivateChains) < 0)
         return -1;
@@ -920,8 +920,6 @@ int networkAddFirewallRules(virNetworkDefPtr def)
         }
     }
 
-    fw = virFirewallNew();
-
     virFirewallStartTransaction(fw, 0);
 
     networkAddGeneralFirewallRules(fw, def);
@@ -946,10 +944,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
     virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS);
     networkAddChecksumFirewallRules(fw, def);
 
-    if (virFirewallApply(fw) < 0)
-        return -1;
-
-    return 0;
+    return virFirewallApply(fw);
 }
 
 /* Remove all rules for all ip addresses (and general rules) on a network */
-- 
2.25.4

Re: [PATCH 16/25] squash into 'network: convert local pointers to g_auto*'
Posted by Laine Stump 5 years, 7 months ago
OOPS!!

I meant to squash this into patch 10 before posting. If you want to just 
review it separately I can squash it in before push. Or if you want to 
be pedantic I can squash it in and resend :-)

On 6/24/20 11:34 PM, Laine Stump wrote:
> Signed-off-by: Laine Stump <laine@redhat.com>
> ---
>   src/network/bridge_driver_linux.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
> index 0d0ac730f2..7f765bcf99 100644
> --- a/src/network/bridge_driver_linux.c
> +++ b/src/network/bridge_driver_linux.c
> @@ -834,7 +834,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>   {
>       size_t i;
>       virNetworkIPDefPtr ipdef;
> -    g_autoptr(virFirewall) fw = NULL;
> +    g_autoptr(virFirewall) fw = virFirewallNew();
>   
>       if (virOnce(&createdOnce, networkSetupPrivateChains) < 0)
>           return -1;
> @@ -920,8 +920,6 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>           }
>       }
>   
> -    fw = virFirewallNew();
> -
>       virFirewallStartTransaction(fw, 0);
>   
>       networkAddGeneralFirewallRules(fw, def);
> @@ -946,10 +944,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>       virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS);
>       networkAddChecksumFirewallRules(fw, def);
>   
> -    if (virFirewallApply(fw) < 0)
> -        return -1;
> -
> -    return 0;
> +    return virFirewallApply(fw);
>   }
>   
>   /* Remove all rules for all ip addresses (and general rules) on a network */


Re: [PATCH 16/25] squash into 'network: convert local pointers to g_auto*'
Posted by Ján Tomko 5 years, 7 months ago
On a Wednesday in 2020, Laine Stump wrote:
>OOPS!!
>
>I meant to squash this into patch 10 before posting. If you want to 
>just review it separately I can squash it in before push. Or if you 
>want to be pedantic I can squash it in and resend :-)
>

To me, these seem like changes unrelated to patch 10 and deserve their
own commit.

Jano

>On 6/24/20 11:34 PM, Laine Stump wrote:
>>Signed-off-by: Laine Stump <laine@redhat.com>
>>---
>>  src/network/bridge_driver_linux.c | 9 ++-------
>>  1 file changed, 2 insertions(+), 7 deletions(-)
>>
>>diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
>>index 0d0ac730f2..7f765bcf99 100644
>>--- a/src/network/bridge_driver_linux.c
>>+++ b/src/network/bridge_driver_linux.c
>>@@ -834,7 +834,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>>  {
>>      size_t i;
>>      virNetworkIPDefPtr ipdef;
>>-    g_autoptr(virFirewall) fw = NULL;
>>+    g_autoptr(virFirewall) fw = virFirewallNew();
>>      if (virOnce(&createdOnce, networkSetupPrivateChains) < 0)
>>          return -1;
>>@@ -920,8 +920,6 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>>          }
>>      }
>>-    fw = virFirewallNew();
>>-
>>      virFirewallStartTransaction(fw, 0);
>>      networkAddGeneralFirewallRules(fw, def);
>>@@ -946,10 +944,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>>      virFirewallStartTransaction(fw, VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS);
>>      networkAddChecksumFirewallRules(fw, def);
>>-    if (virFirewallApply(fw) < 0)
>>-        return -1;
>>-
>>-    return 0;
>>+    return virFirewallApply(fw);
>>  }
>>  /* Remove all rules for all ip addresses (and general rules) on a network */
>
>
Re: [PATCH 16/25] squash into 'network: convert local pointers to g_auto*'
Posted by Laine Stump 5 years, 7 months ago
On 6/25/20 7:34 PM, Ján Tomko wrote:
> On a Wednesday in 2020, Laine Stump wrote:
>> OOPS!!
>>
>> I meant to squash this into patch 10 before posting. If you want to 
>> just review it separately I can squash it in before push. Or if you 
>> want to be pedantic I can squash it in and resend :-)
>>
>
> To me, these seem like changes unrelated to patch 10 and deserve their
> own commit.


Well, they're all related to the cleanup that naturally follows from 
making a pointer g_autofree - 1) you need to initialize it when you 
define it (and so you might as well initialize it with the first real 
value it's going to get, as long as that value would end up *always* 
being assigned anyway, and 2) code reduction related to removing 
now-empty cleanup: label. But I see you just responded to patch 10 
saying you thought the patch was too long and should be split, so I 
suppose I could make this the 2nd of the 2 that you suggest.


>
> Jano
>
>> On 6/24/20 11:34 PM, Laine Stump wrote:
>>> Signed-off-by: Laine Stump <laine@redhat.com>
>>> ---
>>>  src/network/bridge_driver_linux.c | 9 ++-------
>>>  1 file changed, 2 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/src/network/bridge_driver_linux.c 
>>> b/src/network/bridge_driver_linux.c
>>> index 0d0ac730f2..7f765bcf99 100644
>>> --- a/src/network/bridge_driver_linux.c
>>> +++ b/src/network/bridge_driver_linux.c
>>> @@ -834,7 +834,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>>>  {
>>>      size_t i;
>>>      virNetworkIPDefPtr ipdef;
>>> -    g_autoptr(virFirewall) fw = NULL;
>>> +    g_autoptr(virFirewall) fw = virFirewallNew();
>>>      if (virOnce(&createdOnce, networkSetupPrivateChains) < 0)
>>>          return -1;
>>> @@ -920,8 +920,6 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>>>          }
>>>      }
>>> -    fw = virFirewallNew();
>>> -
>>>      virFirewallStartTransaction(fw, 0);
>>>      networkAddGeneralFirewallRules(fw, def);
>>> @@ -946,10 +944,7 @@ int networkAddFirewallRules(virNetworkDefPtr def)
>>>      virFirewallStartTransaction(fw, 
>>> VIR_FIREWALL_TRANSACTION_IGNORE_ERRORS);
>>>      networkAddChecksumFirewallRules(fw, def);
>>> -    if (virFirewallApply(fw) < 0)
>>> -        return -1;
>>> -
>>> -    return 0;
>>> +    return virFirewallApply(fw);
>>>  }
>>>  /* Remove all rules for all ip addresses (and general rules) on a 
>>> network */
>>
>>