[libvirt] [PATCHv2 4/5] util: netdevbridge: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE

Shi Lei shi_lei at massclouds.com
Thu Sep 13 01:12:23 UTC 2018


On 2018-09-12 at 23:38, Michal Privoznik wrote:
>On 09/12/2018 11:46 AM, Shi Lei wrote:
>> Signed-off-by: Shi Lei <shi_lei at massclouds.com>
>> ---
>>  src/util/virnetdevbridge.c | 120 ++++++++++++-------------------------
>>  1 file changed, 37 insertions(+), 83 deletions(-)
>>
>> diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
>> index ed2db27..e058898 100644
>> --- a/src/util/virnetdevbridge.c
>> +++ b/src/util/virnetdevbridge.c
>
>
>> @@ -723,19 +687,14 @@ int virNetDevBridgeRemovePort(const char *brname,
>>  int virNetDevBridgeSetSTPDelay(const char *brname,
>>                                 int delay)
>>  {
>> -    int fd = -1;
>> -    int ret = -1;
>>      struct ifreq ifr;
>> +    VIR_AUTOCLOSE fd = -1;
>> 
>>      if ((fd = virNetDevSetupControl(brname, &ifr)) < 0)
>> -        goto cleanup;
>> +        return -1;
>> 
>> -    ret = virNetDevBridgeSet(brname, "forward_delay", MS_TO_JIFFIES(delay),
>> +    return virNetDevBridgeSet(brname, "forward_delay", MS_TO_JIFFIES(delay),
>>                               fd, &ifr);
>
>Misaligned arguments. 

Sorry for it!

>
>> -
>> - cleanup:
>> -    VIR_FORCE_CLOSE(fd);
>> -    return ret;
>>  }
>> 
>> 
>> @@ -776,19 +735,14 @@ int virNetDevBridgeGetSTPDelay(const char *brname,
>>  int virNetDevBridgeSetSTP(const char *brname,
>>                            bool enable)
>>  {
>> -    int fd = -1;
>> -    int ret = -1;
>>      struct ifreq ifr;
>> +    VIR_AUTOCLOSE fd = -1;
>> 
>>      if ((fd = virNetDevSetupControl(brname, &ifr)) < 0)
>> -        goto cleanup;
>> +        return -1;
>> 
>> -    ret = virNetDevBridgeSet(brname, "stp_state", enable ? 1 : 0,
>> +    return virNetDevBridgeSet(brname, "stp_state", enable ? 1 : 0,
>>                               fd, &ifr);
>> -
>
>And again. 

Sorry. I would pay attention.

>
>Michal 


Thanks,

Shi Lei




More information about the libvir-list mailing list