Skip to content

Commit e94e711

Browse files
Make more data const to move it to .rodata
1 parent 85b6b2b commit e94e711

File tree

13 files changed

+48
-51
lines changed

13 files changed

+48
-51
lines changed

applications/main/gpio/usb_uart_bridge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void usb_uart_vcp_init(UsbUartBridge* usb_uart, uint8_t vcp_ch) {
113113
furi_check(furi_hal_usb_set_config(&usb_cdc_dual, NULL) == true);
114114
cli_vcp_enable(usb_uart->cli_vcp);
115115
}
116-
furi_hal_cdc_set_callbacks(vcp_ch, (CdcCallbacks*)&cdc_cb, usb_uart);
116+
furi_hal_cdc_set_callbacks(vcp_ch, &cdc_cb, usb_uart);
117117
}
118118

119119
static void usb_uart_vcp_deinit(UsbUartBridge* usb_uart, uint8_t vcp_ch) {

applications/main/subghz/views/subghz_read_raw.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,12 @@ void subghz_read_raw_update_sin(SubGhzReadRAW* instance) {
146146
}
147147

148148
static int8_t subghz_read_raw_tab_sin(uint8_t x) {
149-
const uint8_t tab_sin[64] = {0, 3, 6, 9, 12, 16, 19, 22, 25, 28, 31, 34, 37,
150-
40, 43, 46, 49, 51, 54, 57, 60, 63, 65, 68, 71, 73,
151-
76, 78, 81, 83, 85, 88, 90, 92, 94, 96, 98, 100, 102,
152-
104, 106, 107, 109, 111, 112, 113, 115, 116, 117, 118, 120, 121,
153-
122, 122, 123, 124, 125, 125, 126, 126, 126, 127, 127, 127};
149+
static const uint8_t tab_sin[64] = {0, 3, 6, 9, 12, 16, 19, 22, 25, 28, 31,
150+
34, 37, 40, 43, 46, 49, 51, 54, 57, 60, 63,
151+
65, 68, 71, 73, 76, 78, 81, 83, 85, 88, 90,
152+
92, 94, 96, 98, 100, 102, 104, 106, 107, 109, 111,
153+
112, 113, 115, 116, 117, 118, 120, 121, 122, 122, 123,
154+
124, 125, 125, 126, 126, 126, 127, 127, 127};
154155

155156
int8_t r = tab_sin[((x & 0x40) ? -x - 1 : x) & 0x3f];
156157
if(x & 0x80) return -r;

applications/services/cli/cli_vcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void cli_vcp_cdc_ctrl_line_callback(void* context, CdcCtrlLine ctrl_lines
130130
}
131131
}
132132

133-
static CdcCallbacks cdc_callbacks = {
133+
static const CdcCallbacks cdc_callbacks = {
134134
.tx_ep_callback = cli_vcp_cdc_tx_done,
135135
.rx_ep_callback = cli_vcp_cdc_rx,
136136
.state_callback = cli_vcp_cdc_state_callback,

lib/lfrfid/protocols/protocol_nexwatch.c

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,6 @@
1515
#define NEXWATCH_US_PER_BIT (255)
1616
#define NEXWATCH_ENCODER_PULSES_PER_BIT (16)
1717

18-
typedef struct {
19-
uint8_t magic;
20-
char desc[13];
21-
uint8_t chk;
22-
} ProtocolNexwatchMagic;
23-
24-
static ProtocolNexwatchMagic magic_items[] = {
25-
{0xBE, "Quadrakey", 0},
26-
{0x88, "Nexkey", 0},
27-
{0x86, "Honeywell", 0}};
28-
2918
typedef struct {
3019
uint8_t data_index;
3120
uint8_t bit_clock_index;
@@ -143,10 +132,10 @@ static bool protocol_nexwatch_decoder_feed_internal(bool polarity, uint32_t time
143132
return result;
144133
}
145134

146-
static void protocol_nexwatch_descramble(uint32_t* id, uint32_t* scrambled) {
135+
static void protocol_nexwatch_descramble(uint32_t* id, const uint32_t* scrambled) {
147136
// 255 = Not used/Unknown other values are the bit offset in the ID/FC values
148-
const uint8_t hex_2_id[] = {31, 27, 23, 19, 15, 11, 7, 3, 30, 26, 22, 18, 14, 10, 6, 2,
149-
29, 25, 21, 17, 13, 9, 5, 1, 28, 24, 20, 16, 12, 8, 4, 0};
137+
static const uint8_t hex_2_id[] = {31, 27, 23, 19, 15, 11, 7, 3, 30, 26, 22, 18, 14, 10, 6, 2,
138+
29, 25, 21, 17, 13, 9, 5, 1, 28, 24, 20, 16, 12, 8, 4, 0};
150139

151140
*id = 0;
152141
for(uint8_t idx = 0; idx < 32; idx++) {
@@ -264,27 +253,33 @@ LevelDuration protocol_nexwatch_encoder_yield(ProtocolNexwatch* protocol) {
264253
}
265254

266255
static void protocol_nexwatch_render_data_internal(
267-
ProtocolNexwatch* protocol,
256+
const ProtocolNexwatch* protocol,
268257
FuriString* result,
269258
bool brief) {
270259
uint32_t id = 0;
271-
uint32_t scrambled = bit_lib_get_bits_32(protocol->data, 8, 32);
260+
const uint32_t scrambled = bit_lib_get_bits_32(protocol->data, 8, 32);
272261
protocol_nexwatch_descramble(&id, &scrambled);
273262

274-
uint8_t m_idx;
275-
uint8_t mode = bit_lib_get_bits(protocol->data, 40, 4);
276-
uint8_t parity = bit_lib_get_bits(protocol->data, 44, 4);
277-
uint8_t chk = bit_lib_get_bits(protocol->data, 48, 8);
263+
const uint8_t mode = bit_lib_get_bits(protocol->data, 40, 4);
264+
const uint8_t parity = bit_lib_get_bits(protocol->data, 44, 4);
265+
const uint8_t chk = bit_lib_get_bits(protocol->data, 48, 8);
278266

279-
for(m_idx = 0; m_idx < COUNT_OF(magic_items); m_idx++) {
280-
magic_items[m_idx].chk = protocol_nexwatch_checksum(magic_items[m_idx].magic, id, parity);
281-
if(magic_items[m_idx].chk == chk) {
267+
typedef struct {
268+
const char* desc;
269+
uint8_t magic;
270+
} ProtocolNexwatchMagic;
271+
272+
static const ProtocolNexwatchMagic magic_items[] = {
273+
{"Quadrakey", 0xBE}, {"Nexkey", 0x88}, {"Honeywell", 0x86}};
274+
275+
const char* type = "Unknown";
276+
for(size_t idx = 0; idx < COUNT_OF(magic_items); idx++) {
277+
if(protocol_nexwatch_checksum(magic_items[idx].magic, id, parity) == chk) {
278+
type = magic_items[idx].desc;
282279
break;
283280
}
284281
}
285282

286-
const char* type = m_idx < COUNT_OF(magic_items) ? magic_items[m_idx].desc : "Unknown";
287-
288283
if(brief) {
289284
furi_string_printf(
290285
result,

lib/toolbox/cli/shell/cli_shell.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ typedef enum {
2525
CliShellComponentMAX, //<! do not use
2626
} CliShellComponent;
2727

28-
CliShellKeyComboSet* component_key_combo_sets[] = {
28+
static const CliShellKeyComboSet* const component_key_combo_sets[] = {
2929
[CliShellComponentCompletions] = &cli_shell_completions_key_combo_set,
3030
[CliShellComponentLine] = &cli_shell_line_key_combo_set,
3131
};
@@ -213,8 +213,9 @@ void cli_shell_execute_command(CliShell* cli_shell, FuriString* command) {
213213
if(!(command_data.flags & CliCommandFlagParallelSafe)) {
214214
loader_locked = loader_lock(loader);
215215
if(!loader_locked) {
216-
printf(ANSI_FG_RED
217-
"this command cannot be run while an application is open" ANSI_RESET);
216+
printf(
217+
ANSI_FG_RED
218+
"this command cannot be run while an application is open" ANSI_RESET);
218219
break;
219220
}
220221
}
@@ -299,7 +300,7 @@ static void
299300
if(key_combo.key == CliKeyUnrecognized) return;
300301

301302
for(size_t i = 0; i < CliShellComponentMAX; i++) { // -V1008
302-
CliShellKeyComboSet* set = component_key_combo_sets[i];
303+
const CliShellKeyComboSet* set = component_key_combo_sets[i];
303304
void* component_context = cli_shell->components[i];
304305

305306
for(size_t j = 0; j < set->count; j++) {

lib/toolbox/cli/shell/cli_shell_completions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static bool key_combo_esc(CliKeyCombo combo, void* context) {
351351
return true;
352352
}
353353

354-
CliShellKeyComboSet cli_shell_completions_key_combo_set = {
354+
const CliShellKeyComboSet cli_shell_completions_key_combo_set = {
355355
.fallback = hide_if_open_and_continue_handling,
356356
.count = 7,
357357
.records =

lib/toolbox/cli/shell/cli_shell_completions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CliShellCompletions*
1818

1919
void cli_shell_completions_free(CliShellCompletions* completions);
2020

21-
extern CliShellKeyComboSet cli_shell_completions_key_combo_set;
21+
extern const CliShellKeyComboSet cli_shell_completions_key_combo_set;
2222

2323
#ifdef __cplusplus
2424
}

lib/toolbox/cli/shell/cli_shell_line.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static bool cli_shell_line_input_normal(CliKeyCombo combo, void* context) {
355355
return true;
356356
}
357357

358-
CliShellKeyComboSet cli_shell_line_key_combo_set = {
358+
const CliShellKeyComboSet cli_shell_line_key_combo_set = {
359359
.fallback = cli_shell_line_input_normal,
360360
.count = 14,
361361
.records =

lib/toolbox/cli/shell/cli_shell_line.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void cli_shell_line_ensure_not_overwriting_history(CliShellLine* line);
3535

3636
void cli_shell_line_set_about_to_exit(CliShellLine* line);
3737

38-
extern CliShellKeyComboSet cli_shell_line_key_combo_set;
38+
extern const CliShellKeyComboSet cli_shell_line_key_combo_set;
3939

4040
#ifdef __cplusplus
4141
}

targets/f18/api_symbols.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
entry,status,name,type,params
2-
Version,+,87.0,,
2+
Version,+,88.0,,
33
Header,+,applications/services/bt/bt_service/bt.h,,
44
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
55
Header,+,applications/services/cli/cli.h,,
@@ -1227,8 +1227,8 @@ Function,+,furi_hal_bus_reset,void,FuriHalBus
12271227
Function,+,furi_hal_cdc_get_ctrl_line_state,uint8_t,uint8_t
12281228
Function,+,furi_hal_cdc_get_port_settings,usb_cdc_line_coding*,uint8_t
12291229
Function,+,furi_hal_cdc_receive,int32_t,"uint8_t, uint8_t*, uint16_t"
1230-
Function,+,furi_hal_cdc_send,void,"uint8_t, uint8_t*, uint16_t"
1231-
Function,+,furi_hal_cdc_set_callbacks,void,"uint8_t, CdcCallbacks*, void*"
1230+
Function,+,furi_hal_cdc_send,void,"uint8_t, const uint8_t*, uint16_t"
1231+
Function,+,furi_hal_cdc_set_callbacks,void,"uint8_t, const CdcCallbacks*, void*"
12321232
Function,-,furi_hal_clock_deinit_early,void,
12331233
Function,-,furi_hal_clock_init,void,
12341234
Function,-,furi_hal_clock_init_early,void,

0 commit comments

Comments
 (0)