0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 14:48:03 +03:00

Use memcpy() instead of memmove() when it's possible (two memmove call were kept).

Rename some variable named 'String' (to 'str') which is quite confusing.
This commit is contained in:
Daniel Caujolle-Bert
2023-10-24 11:40:35 +02:00
parent 024c4bb79d
commit 64f19b2d78
12 changed files with 317 additions and 317 deletions

View File

@ -122,7 +122,7 @@ bool DTMF_FindContact(const char *pContact, char *pResult)
if (j == 3)
{
memmove(pResult, Contact, 8);
memcpy(pResult, Contact, 8);
pResult[8] = 0;
return true;
}
@ -354,8 +354,8 @@ void DTMF_HandleRequest(void)
memset(g_dtmf_callee, 0, sizeof(g_dtmf_callee));
memset(g_dtmf_caller, 0, sizeof(g_dtmf_caller));
memmove(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3);
memmove(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3);
memcpy(g_dtmf_callee, g_dtmf_rx + Offset + 0, 3);
memcpy(g_dtmf_caller, g_dtmf_rx + Offset + 4, 3);
DTMF_clear_RX();

View File

@ -785,7 +785,7 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held)
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && IS_NOT_NOAA_CHANNEL(g_tx_vfo->channel_save))
{ // start entering a DTMF string
memmove( g_dtmf_input_box, g_dtmf_string,
memcpy( g_dtmf_input_box, g_dtmf_string,
(sizeof(g_dtmf_input_box) <= (sizeof(g_dtmf_string) - 1)) ? sizeof(g_dtmf_input_box) : sizeof(g_dtmf_string) - 1);
g_dtmf_input_box_index = 0;

View File

@ -535,7 +535,7 @@ void MENU_AcceptSetting(void)
// save the channel name
memset(g_tx_vfo->name, 0, sizeof(g_tx_vfo->name));
memmove(g_tx_vfo->name, g_edit, 10);
memcpy(g_tx_vfo->name, g_edit, 10);
SETTINGS_save_channel(g_sub_menu_selection, g_eeprom.tx_vfo, g_tx_vfo, 3);
g_flag_reconfigure_vfos = true;
return;
@ -742,7 +742,7 @@ void MENU_AcceptSetting(void)
GUI_SelectNextDisplay(DISPLAY_MAIN);
g_dtmf_input_mode = true;
g_dtmf_input_box_index = 3;
memmove(g_dtmf_input_box, g_dtmf_id, 4);
memcpy(g_dtmf_input_box, g_dtmf_id, 4);
g_request_display_screen = DISPLAY_INVALID;
}
return;
@ -1624,7 +1624,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held)
g_edit_index = 0; // 'g_edit_index' is going to be used as the cursor position
// make a copy so we can test for change when exiting the menu item
memmove(g_edit_original, g_edit, sizeof(g_edit_original));
memcpy(g_edit_original, g_edit, sizeof(g_edit_original));
return;
}

View File

@ -209,7 +209,7 @@ static void SendVersion(void)
memset(&reply, 0, sizeof(reply));
reply.Header.ID = 0x0515;
reply.Header.Size = sizeof(reply.Data);
memmove(reply.Data.Version, Version_str, slen);
memcpy(reply.Data.Version, Version_str, slen);
reply.Data.has_custom_aes_key = g_has_custom_aes_key;
reply.Data.password_locked = g_password_locked;
reply.Data.Challenge[0] = g_challenge[0];
@ -420,13 +420,13 @@ static void cmd_052D(const uint8_t *pBuffer)
if (!locked)
{
memmove((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
memcpy((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
locked = IsBadChallenge(g_custom_aes_key, g_challenge, response);
}
if (!locked)
{
memmove((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
memcpy((void *)&response, &pCmd->Response, sizeof(response)); // overcome strict compiler warning settings
locked = IsBadChallenge(g_default_aes_key, g_challenge, response);
if (locked)
try_count++;
@ -546,11 +546,11 @@ bool UART_IsCommandAvailable(void)
if (TailIndex < Index)
{
const uint16_t ChunkSize = sizeof(UART_DMA_Buffer) - Index;
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
memmove(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, ChunkSize);
memcpy(UART_Command.Buffer + ChunkSize, UART_DMA_Buffer, TailIndex);
}
else
memmove(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index);
memcpy(UART_Command.Buffer, UART_DMA_Buffer + Index, TailIndex - Index);
TailIndex = DMA_INDEX(TailIndex, 2);
if (TailIndex < write_index)