mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
maint: avoid useless "if (foo) free(foo)" pattern
The free() and g_free() functions both happily accept NULL on any platform QEMU builds on. As such putting a conditional 'if (foo)' check before calls to 'free(foo)' merely serves to bloat the lines of code. Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
4595a48a10
commit
ef1e1e0782
20 changed files with 39 additions and 93 deletions
|
@ -1151,8 +1151,7 @@ static void bt_hci_reset(struct bt_hci_s *hci)
|
|||
hci->event_mask[7] = 0x00;
|
||||
hci->device.inquiry_scan = 0;
|
||||
hci->device.page_scan = 0;
|
||||
if (hci->device.lmp_name)
|
||||
g_free((void *) hci->device.lmp_name);
|
||||
g_free((void *) hci->device.lmp_name);
|
||||
hci->device.lmp_name = NULL;
|
||||
hci->device.class[0] = 0x00;
|
||||
hci->device.class[1] = 0x00;
|
||||
|
@ -1829,8 +1828,7 @@ static void bt_submit_hci(struct HCIInfo *info,
|
|||
case cmd_opcode_pack(OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME):
|
||||
LENGTH_CHECK(change_local_name);
|
||||
|
||||
if (hci->device.lmp_name)
|
||||
g_free((void *) hci->device.lmp_name);
|
||||
g_free((void *) hci->device.lmp_name);
|
||||
hci->device.lmp_name = g_strndup(PARAM(change_local_name, name),
|
||||
sizeof(PARAM(change_local_name, name)));
|
||||
bt_hci_event_complete_status(hci, HCI_SUCCESS);
|
||||
|
@ -2231,8 +2229,7 @@ static void bt_hci_done(struct HCIInfo *info)
|
|||
|
||||
bt_device_done(&hci->device);
|
||||
|
||||
if (hci->device.lmp_name)
|
||||
g_free((void *) hci->device.lmp_name);
|
||||
g_free((void *) hci->device.lmp_name);
|
||||
|
||||
/* Be gentle and send DISCONNECT to all connected peers and those
|
||||
* currently waiting for us to accept or reject a connection request.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue