Skip to content

Commit

Permalink
bluetooth: gatt: Fix value returned by db_hash_commit
Browse files Browse the repository at this point in the history
Change fixes value returned by db_hash_commit. Returning positive
value leads to settings load failure.

Signed-off-by: Marek Pieta <[email protected]>
  • Loading branch information
MarekPieta authored and carlescufi committed Aug 11, 2022
1 parent 5563459 commit 3a1d973
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions subsys/bluetooth/host/gatt.c
Original file line number Diff line number Diff line change
Expand Up @@ -5826,16 +5826,28 @@ static int db_hash_set(const char *name, size_t len_rd,

static int db_hash_commit(void)
{
int err;

atomic_set_bit(gatt_sc.flags, DB_HASH_LOAD);
/* Reschedule work to calculate and compare against the Hash value
* loaded from flash.
*/
if (IS_ENABLED(CONFIG_BT_LONG_WQ)) {
return bt_long_wq_reschedule(&db_hash.work, K_NO_WAIT);
err = bt_long_wq_reschedule(&db_hash.work, K_NO_WAIT);
} else {
return k_work_reschedule(&db_hash.work, K_NO_WAIT);
err = k_work_reschedule(&db_hash.work, K_NO_WAIT);
}

/* Settings commit uses non-zero value to indicate failure. */
if (err > 0) {
err = 0;
}

if (err) {
BT_ERR("Unable to reschedule database hash process (err %d)", err);
}

return err;
}

SETTINGS_STATIC_HANDLER_DEFINE(bt_hash, "bt/hash", NULL, db_hash_set,
Expand Down

0 comments on commit 3a1d973

Please sign in to comment.