summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-09-21 14:52:53 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-09-21 16:36:23 -0700
commit40a90f4e98fe0f2fa2da68b99ae136947d3d5189 (patch)
tree59f12e7f01ea8dee298fbd82d2955d57c43f4c3c
parent31b32daf529204313be3da08e1809dc916a37864 (diff)
downloadbluez-40a90f4e98fe0f2fa2da68b99ae136947d3d5189.tar.gz
shared/gatt-db: Fix scan-build warnings
This fixes the following warnings: src/shared/gatt-db.c:1339:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn] return data.num_of_res; ^~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-db.c:725:5: warning: Access to field 'handle' results in a dereference of a null pointer service->attributes[0]->handle == handle) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-rw-r--r--src/shared/gatt-db.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 32cbf6cdc..ba47c75ff 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -709,21 +709,24 @@ struct gatt_db_attribute *gatt_db_insert_service(struct gatt_db *db,
if (service) {
const bt_uuid_t *type;
bt_uuid_t value;
+ struct gatt_db_attribute *attr = service->attributes[0];
+
+ if (!attr)
+ return NULL;
if (primary)
type = &primary_service_uuid;
else
type = &secondary_service_uuid;
- gatt_db_attribute_get_service_uuid(service->attributes[0],
- &value);
+ gatt_db_attribute_get_service_uuid(attr, &value);
/* Check if service match */
- if (!bt_uuid_cmp(&service->attributes[0]->uuid, type) &&
+ if (!bt_uuid_cmp(&attr->uuid, type) &&
!bt_uuid_cmp(&value, uuid) &&
service->num_handles == num_handles &&
- service->attributes[0]->handle == handle)
- return service->attributes[0];
+ attr->handle == handle)
+ return attr;
return NULL;
}
@@ -1328,6 +1331,7 @@ unsigned int gatt_db_find_by_type_value(struct gatt_db *db,
{
struct find_by_type_value_data data;
+ memset(&data, 0, sizeof(data));
data.func = func;
data.user_data = user_data;
data.value = value;