mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-22 05:33:53 -04:00
bluez5: fix some coverity issues
Missing null pointer checks, wrong array indices, uninitialized/unused variables.
This commit is contained in:
parent
26b09b0ee3
commit
7f2bdab8ea
5 changed files with 7 additions and 9 deletions
|
|
@ -549,8 +549,9 @@ static bool rfcomm_hw_volume_enabled(struct rfcomm *rfcomm)
|
||||||
static void rfcomm_emit_volume_changed(struct rfcomm *rfcomm, int id, int hw_volume)
|
static void rfcomm_emit_volume_changed(struct rfcomm *rfcomm, int id, int hw_volume)
|
||||||
{
|
{
|
||||||
struct spa_bt_transport_volume *t_volume;
|
struct spa_bt_transport_volume *t_volume;
|
||||||
|
bool valid_volume = (id == SPA_BT_VOLUME_ID_RX || id == SPA_BT_VOLUME_ID_TX);
|
||||||
|
|
||||||
if ((id == SPA_BT_VOLUME_ID_RX || id == SPA_BT_VOLUME_ID_TX) && hw_volume >= 0) {
|
if (valid_volume && hw_volume >= 0) {
|
||||||
rfcomm->volumes[id].active = true;
|
rfcomm->volumes[id].active = true;
|
||||||
rfcomm->volumes[id].hw_volume = hw_volume;
|
rfcomm->volumes[id].hw_volume = hw_volume;
|
||||||
}
|
}
|
||||||
|
|
@ -571,7 +572,7 @@ static void rfcomm_emit_volume_changed(struct rfcomm *rfcomm, int id, int hw_vol
|
||||||
spa_bt_transport_emit_volume_changed(rfcomm->transport);
|
spa_bt_transport_emit_volume_changed(rfcomm->transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rfcomm->telephony_ag) {
|
if (rfcomm->telephony_ag && valid_volume) {
|
||||||
rfcomm->telephony_ag->volume[id] = hw_volume;
|
rfcomm->telephony_ag->volume[id] = hw_volume;
|
||||||
telephony_ag_notify_updated_props(rfcomm->telephony_ag);
|
telephony_ag_notify_updated_props(rfcomm->telephony_ag);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4204,7 +4204,7 @@ static int transport_set_delay(void *data, int64_t delay_nsec)
|
||||||
if (!(transport->profile & SPA_BT_PROFILE_A2DP_DUPLEX))
|
if (!(transport->profile & SPA_BT_PROFILE_A2DP_DUPLEX))
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
||||||
value = SPA_CLAMP(delay_nsec / (100 * SPA_NSEC_PER_USEC), 0, 10 * UINT16_MAX);
|
value = SPA_CLAMP(delay_nsec / (100 * SPA_NSEC_PER_USEC), 0, UINT16_MAX);
|
||||||
|
|
||||||
if (transport->delay_us == 100 * value)
|
if (transport->delay_us == 100 * value)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -4362,7 +4362,7 @@ static bool codec_switch_check_endpoint(struct spa_bt_remote_endpoint *ep,
|
||||||
spa_autofree char *path = NULL;
|
spa_autofree char *path = NULL;
|
||||||
uint32_t ep_profile;
|
uint32_t ep_profile;
|
||||||
|
|
||||||
if (!ep->uuid || !ep->device)
|
if (!ep || !ep->uuid || !ep->device)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ep_profile = spa_bt_profile_from_uuid(ep->uuid);
|
ep_profile = spa_bt_profile_from_uuid(ep->uuid);
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ static int codec_start_decode (void *data,
|
||||||
const void *src, size_t src_size, uint16_t *seqnum, uint32_t *timestamp)
|
const void *src, size_t src_size, uint16_t *seqnum, uint32_t *timestamp)
|
||||||
{
|
{
|
||||||
struct impl *this = data;
|
struct impl *this = data;
|
||||||
size_t consumed;
|
size_t consumed = 0;
|
||||||
|
|
||||||
if (is_zero_packet(src, src_size))
|
if (is_zero_packet(src, src_size))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
||||||
|
|
@ -158,7 +158,7 @@ static int codec_start_decode (void *data,
|
||||||
const void *src, size_t src_size, uint16_t *seqnum, uint32_t *timestamp)
|
const void *src, size_t src_size, uint16_t *seqnum, uint32_t *timestamp)
|
||||||
{
|
{
|
||||||
struct impl *this = data;
|
struct impl *this = data;
|
||||||
size_t consumed;
|
size_t consumed = 0;
|
||||||
|
|
||||||
if (is_zero_packet(src, src_size))
|
if (is_zero_packet(src, src_size))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,6 @@ static gboolean chr_handle_acquire(Bluez5GattCharacteristic1 *object,
|
||||||
int res;
|
int res;
|
||||||
GUnixFDList *fd_list = NULL;
|
GUnixFDList *fd_list = NULL;
|
||||||
GVariant *fd_handle = NULL;
|
GVariant *fd_handle = NULL;
|
||||||
GError *err = NULL;
|
|
||||||
|
|
||||||
if ((write && (impl->cb->acquire_write == NULL)) ||
|
if ((write && (impl->cb->acquire_write == NULL)) ||
|
||||||
(!write && (impl->cb->acquire_notify == NULL))) {
|
(!write && (impl->cb->acquire_notify == NULL))) {
|
||||||
|
|
@ -230,8 +229,6 @@ fail:
|
||||||
if (fds[1] >= 0)
|
if (fds[1] >= 0)
|
||||||
close(fds[1]);
|
close(fds[1]);
|
||||||
|
|
||||||
if (err)
|
|
||||||
g_error_free(err);
|
|
||||||
g_clear_pointer(&fd_handle, g_variant_unref);
|
g_clear_pointer(&fd_handle, g_variant_unref);
|
||||||
g_clear_object(&fd_list);
|
g_clear_object(&fd_list);
|
||||||
g_dbus_method_invocation_return_dbus_error(invocation,
|
g_dbus_method_invocation_return_dbus_error(invocation,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue