diff mbox series

[BlueZ,03/15] shared/gatt-client: Fix uninitialised variable usage

Message ID 20240516090340.61417-4-hadess@hadess.net
State New
Headers show
Series Fix a number of static analysis issues #2 | expand

Commit Message

Bastien Nocera May 16, 2024, 9:03 a.m. UTC
Error: UNINIT (CWE-457): [#def44] [important]
bluez-5.75/src/shared/gatt-client.c:1669:2: var_decl: Declaring variable "value" without initializer.
bluez-5.75/src/shared/gatt-client.c:1686:2: uninit_use_in_call: Using uninitialized value "value" when calling "bt_gatt_client_write_value".
1684|		}
1685|
1686|->		att_id = bt_gatt_client_write_value(notify_data->client,
1687|							notify_data->chrc->ccc_handle,
1688|							(void *)&value, sizeof(value),
---
 src/shared/gatt-client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index dcf6f0211a67..8e4ae7e5e230 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -1666,7 +1666,7 @@  static bool notify_data_write_ccc(struct notify_data *notify_data, bool enable,
 					bt_gatt_client_callback_t callback)
 {
 	unsigned int att_id;
-	uint16_t value;
+	uint16_t value = 0x0000;
 	uint16_t properties = notify_data->chrc->properties;
 
 	assert(notify_data->chrc->ccc_handle);