diff mbox series

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

Message ID 20240516090340.61417-4-hadess@hadess.net (mailing list archive)
State Accepted
Commit 75eda690c4af2bf67b026696f504a11d71582884
Headers show
Series Fix a number of static analysis issues #2 | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 4: B1 Line exceeds max length (101>80): "bluez-5.75/src/shared/gatt-client.c:1669:2: var_decl: Declaring variable "value" without initializer." 5: B1 Line exceeds max length (140>80): "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"." 6: B3 Line contains hard tab characters (\t): "1684| }" 8: B3 Line contains hard tab characters (\t): "1686|-> att_id = bt_gatt_client_write_value(notify_data->client," 9: B3 Line contains hard tab characters (\t): "1687| notify_data->chrc->ccc_handle," 10: B3 Line contains hard tab characters (\t): "1688| (void *)&value, sizeof(value),"
tedd_an/IncrementalBuild success Incremental Build PASS

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);