diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-07-21 03:50:06 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-07-21 06:59:38 -0400 |
commit | 27f70f3e628c82362def60eb0af79d2129a51da2 (patch) | |
tree | 30789593d0d8af060492f8dc2a1994f4b41032bb /net/bluetooth | |
parent | 0a961a440d693f0f74d3185728b13b8a11fc5860 (diff) |
Bluetooth: Prefer sizeof(*ptr) when allocating memory
It's safer practice to use sizeof(*ptr) instead of sizeof(ptr_type) when
allocating memory in case the type changes. This also fixes the
following style of warnings from static analyzers:
CHECK: Prefer kzalloc(sizeof(*ie)...) over kzalloc(sizeof(struct inquiry_entry)...)
+ ie = kzalloc(sizeof(struct inquiry_entry), GFP_KERNEL);
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_conn.c | 4 | ||||
-rw-r--r-- | net/bluetooth/hci_core.c | 6 | ||||
-rw-r--r-- | net/bluetooth/l2cap_core.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 1ac9f7f52acd..b50dabb3f86a 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -428,7 +428,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst, | |||
428 | 428 | ||
429 | BT_DBG("%s dst %pMR", hdev->name, dst); | 429 | BT_DBG("%s dst %pMR", hdev->name, dst); |
430 | 430 | ||
431 | conn = kzalloc(sizeof(struct hci_conn), GFP_KERNEL); | 431 | conn = kzalloc(sizeof(*conn), GFP_KERNEL); |
432 | if (!conn) | 432 | if (!conn) |
433 | return NULL; | 433 | return NULL; |
434 | 434 | ||
@@ -1282,7 +1282,7 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn) | |||
1282 | 1282 | ||
1283 | BT_DBG("%s hcon %p", hdev->name, conn); | 1283 | BT_DBG("%s hcon %p", hdev->name, conn); |
1284 | 1284 | ||
1285 | chan = kzalloc(sizeof(struct hci_chan), GFP_KERNEL); | 1285 | chan = kzalloc(sizeof(*chan), GFP_KERNEL); |
1286 | if (!chan) | 1286 | if (!chan) |
1287 | return NULL; | 1287 | return NULL; |
1288 | 1288 | ||
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index f82a6cf1aaa8..cfcb6055ced8 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2088,7 +2088,7 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, | |||
2088 | } | 2088 | } |
2089 | 2089 | ||
2090 | /* Entry not in the cache. Add new one. */ | 2090 | /* Entry not in the cache. Add new one. */ |
2091 | ie = kzalloc(sizeof(struct inquiry_entry), GFP_KERNEL); | 2091 | ie = kzalloc(sizeof(*ie), GFP_KERNEL); |
2092 | if (!ie) { | 2092 | if (!ie) { |
2093 | flags |= MGMT_DEV_FOUND_CONFIRM_NAME; | 2093 | flags |= MGMT_DEV_FOUND_CONFIRM_NAME; |
2094 | goto done; | 2094 | goto done; |
@@ -3492,7 +3492,7 @@ int hci_bdaddr_list_add(struct list_head *list, bdaddr_t *bdaddr, u8 type) | |||
3492 | if (hci_bdaddr_list_lookup(list, bdaddr, type)) | 3492 | if (hci_bdaddr_list_lookup(list, bdaddr, type)) |
3493 | return -EEXIST; | 3493 | return -EEXIST; |
3494 | 3494 | ||
3495 | entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL); | 3495 | entry = kzalloc(sizeof(*entry), GFP_KERNEL); |
3496 | if (!entry) | 3496 | if (!entry) |
3497 | return -ENOMEM; | 3497 | return -ENOMEM; |
3498 | 3498 | ||
@@ -3897,7 +3897,7 @@ struct hci_dev *hci_alloc_dev(void) | |||
3897 | { | 3897 | { |
3898 | struct hci_dev *hdev; | 3898 | struct hci_dev *hdev; |
3899 | 3899 | ||
3900 | hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL); | 3900 | hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); |
3901 | if (!hdev) | 3901 | if (!hdev) |
3902 | return NULL; | 3902 | return NULL; |
3903 | 3903 | ||
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index f3fb61c9f96f..46547b920f88 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -6985,7 +6985,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon) | |||
6985 | if (!hchan) | 6985 | if (!hchan) |
6986 | return NULL; | 6986 | return NULL; |
6987 | 6987 | ||
6988 | conn = kzalloc(sizeof(struct l2cap_conn), GFP_KERNEL); | 6988 | conn = kzalloc(sizeof(*conn), GFP_KERNEL); |
6989 | if (!conn) { | 6989 | if (!conn) { |
6990 | hci_chan_del(hchan); | 6990 | hci_chan_del(hchan); |
6991 | return NULL; | 6991 | return NULL; |