Bluetooth: Fix warning of potentially uninitialized adv_instance variable
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 18 Jun 2015 18:05:31 +0000 (21:05 +0300)
committerJohan Hedberg <johan.hedberg@intel.com>
Thu, 18 Jun 2015 18:05:31 +0000 (21:05 +0300)
Rework the logic of checking for a valid adv_instance for non-zero
cp->instance values. Without this change we may get (false positive)
warnings as follows:

>> net/bluetooth/mgmt.c:7294:29: warning: 'adv_instance' may be used
uninitialized in this function [-Wuninitialized]

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
net/bluetooth/mgmt.c

index 2fe6f3bfc5793660a8b2257f0e6550e8ef0244c1..7998fb27916568da087b2734a017355158044a75 100644 (file)
@@ -7280,19 +7280,15 @@ static int remove_advertising(struct sock *sk, struct hci_dev *hdev,
 {
        struct mgmt_cp_remove_advertising *cp = data;
        struct mgmt_rp_remove_advertising rp;
-       struct adv_info *adv_instance;
-       int err;
        struct mgmt_pending_cmd *cmd;
        struct hci_request req;
+       int err;
 
        BT_DBG("%s", hdev->name);
 
        hci_dev_lock(hdev);
 
-       if (cp->instance)
-               adv_instance = hci_find_adv_instance(hdev, cp->instance);
-
-       if (!(cp->instance == 0x00 || adv_instance)) {
+       if (cp->instance && !hci_find_adv_instance(hdev, cp->instance)) {
                err = mgmt_cmd_status(sk, hdev->id,
                                      MGMT_OP_REMOVE_ADVERTISING,
                                      MGMT_STATUS_INVALID_PARAMS);