netifd: Activate -Wextra compile warnings
[project/netifd.git] / bonding.c
index 321f819a6f4b9ea0c2845e8a75a76e70840979d5..f4005de059b4d3532a90bed841b47a906f24758d 100644 (file)
--- a/bonding.c
+++ b/bonding.c
@@ -221,10 +221,6 @@ bonding_enable_port(struct bonding_port *bp)
        if (!bp->present)
                return 0;
 
-       ret = bonding_set_active(bdev, true);
-       if (ret)
-               goto error;
-
        /* Disable IPv6 for bonding ports */
        if (!(bp->dev.dev->settings.flags & DEV_OPT_IPV6)) {
                bp->dev.dev->settings.ipv6 = 0;
@@ -233,7 +229,11 @@ bonding_enable_port(struct bonding_port *bp)
 
        ret = device_claim(&bp->dev);
        if (ret < 0)
-               goto error;
+               return ret;
+
+       ret = bonding_set_active(bdev, true);
+       if (ret)
+               goto release;
 
        dev = bp->dev.dev;
        if (dev->settings.auth && !dev->auth_status)
@@ -257,6 +257,7 @@ error:
        bdev->n_failed++;
        bp->present = false;
        bdev->n_present--;
+release:
        device_release(&bp->dev);
 
        return ret;
@@ -395,7 +396,7 @@ bonding_apply_settings(struct bonding_device *bdev, struct blob_attr **tb)
 
        if ((cur = tb[BOND_ATTR_POLICY]) != NULL) {
                const char *policy = blobmsg_get_string(cur);
-               int i;
+               size_t i;
 
                for (i = 0; i < ARRAY_SIZE(bonding_policy_str); i++) {
                        if (strcmp(policy, bonding_policy_str[i]) != 0)
@@ -565,8 +566,6 @@ bonding_free_port(struct bonding_port *bp)
 
        bonding_remove_port(bp);
 
-       device_lock();
-
        device_remove_user(&bp->dev);
 
        /*
@@ -581,8 +580,6 @@ bonding_free_port(struct bonding_port *bp)
                device_set_present(dev, true);
        }
 
-       device_unlock();
-
        free(bp);
 }