Skip to content

Commit 2334ef7

Browse files
committed
Memory Optimization: Change the bluetooth bt_tool storage tool module to const for reduce the ram size.
bug:v/84978 Rootcause: To reduce RAM resource consumption, the `set_options`, 'delete_options', 'g_storage_tables', in the bt_tools storage tool module must be marked with the `const` modifier. This ensures it is compiled and linked into Flash memory instead of RAM. Signed-off-by: huangyulong3 <huangyulong3@xiaomi.com>
1 parent a865fae commit 2334ef7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/storage_update/storage_tool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static char* bt_storage_update_version_str[BT_STORAGE_VERSION_MAX] = {
4545
"v5_0_2",
4646
};
4747

48-
static struct option set_options[] = {
48+
static const struct option set_options[] = {
4949
{ "default", no_argument, 0, 'D' },
5050
{ "version", required_argument, 0, 'v' },
5151
{ "scanmode", required_argument, 0, 's' },
@@ -57,7 +57,7 @@ static struct option set_options[] = {
5757
{ 0, 0, 0, 0 }
5858
};
5959

60-
static struct option delete_options[] = {
60+
static const struct option delete_options[] = {
6161
{ "scanmode", required_argument, 0, 's' },
6262
{ "iocap", required_argument, 0, 'i' },
6363
{ "name", required_argument, 0, 'n' },
@@ -69,7 +69,7 @@ static struct option delete_options[] = {
6969
#define SET_IOCAP_USAGE "set io capability (0:displayonly, 1:yes&no, 2:keyboardonly, 3:no-in/no-out 4:keyboard&display)"
7070
#define SET_CLASS_USAGE "set local class of device, range in 0x0-0xFFFFFC, the 2 least significant shall be 0b00, example: 0x00640404"
7171

72-
static bt_command_t g_storage_tables[] = {
72+
static const bt_command_t g_storage_tables[] = {
7373
{ "add", storage_add_cmd, 0, "\"add storage information :<version_idx><storage_info(1:btbond,2:blebond,3:whitelist(accept list))><num>\"" },
7474
{ "clear", storage_clear_cmd, 0, "clear storage information \n" },
7575
{ "set", storage_set_cmd, 1, "set adapter information(only for V5_0_2 version and above),"
@@ -480,7 +480,7 @@ int storage_command_exec(void* handle, int argc, char* argv[])
480480
int ret = CMD_USAGE_FAULT;
481481

482482
if (argc > 0)
483-
ret = execute_command_in_table_offset(handle, g_storage_tables, ARRAY_SIZE(g_storage_tables), argc, argv, 0);
483+
ret = execute_command_in_table_offset(handle, (bt_command_t*)g_storage_tables, ARRAY_SIZE(g_storage_tables), argc, argv, 0);
484484

485485
if (ret < 0)
486486
usage();

0 commit comments

Comments
 (0)