forked from mirror/uv-k5-firmware
Prevent potential UB.
This commit is contained in:
parent
159006fdf0
commit
c79c672313
@ -113,7 +113,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
gInputBoxIndex = 0;
|
||||
Channel = (gInputBox[0] * 10) + gInputBox[1];
|
||||
if ((Channel - 1) < 10) {
|
||||
if (Channel >= 1 && Channel <= 10) {
|
||||
Channel += NOAA_CHANNEL_FIRST;
|
||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||
gEeprom.NoaaChannel[Vfo] = Channel;
|
||||
|
@ -72,29 +72,28 @@ const uint16_t StepFrequencyTable[6] = {
|
||||
|
||||
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
|
||||
{
|
||||
if ((Frequency - 5000000) < 2600001) {
|
||||
if (Frequency >= 5000000 && Frequency <= 7600000) {
|
||||
return BAND1_50MHz;
|
||||
}
|
||||
if ((Frequency - 10800000) < 2799991) {
|
||||
if (Frequency >= 10800000 && Frequency <= 13599990) {
|
||||
return BAND2_108MHz;
|
||||
}
|
||||
if ((Frequency - 13600000) < 3799991) {
|
||||
if (Frequency >= 13600000 && Frequency <= 17399990) {
|
||||
return BAND3_136MHz;
|
||||
}
|
||||
if ((Frequency - 17400000) < 17599991) {
|
||||
if (Frequency >= 17400000 && Frequency <= 34999990) {
|
||||
return BAND4_174MHz;
|
||||
}
|
||||
if ((Frequency - 35000000) < 4999991) {
|
||||
if (Frequency >= 35000000 && Frequency <= 39999990) {
|
||||
return BAND5_350MHz;
|
||||
}
|
||||
if ((Frequency - 40000000) < 6999991) {
|
||||
if (Frequency >= 40000000 && Frequency <= 46999990) {
|
||||
return BAND6_400MHz;
|
||||
}
|
||||
if ((Frequency - 47000000) < 13000001) {
|
||||
if (Frequency >= 47000000 && Frequency <= 60000000) {
|
||||
return BAND7_470MHz;
|
||||
}
|
||||
|
||||
// TODO: Double check the assembly
|
||||
return BAND6_400MHz;
|
||||
}
|
||||
|
||||
|
4
radio.c
4
radio.c
@ -320,7 +320,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
|
||||
}
|
||||
pRadio->ConfigRX.Frequency = Frequency;
|
||||
|
||||
if (Frequency - 10800000 < 2799991) {
|
||||
if (Frequency >= 10800000 && Frequency <= 13599990) {
|
||||
gEeprom.VfoInfo[VFO].FREQUENCY_DEVIATION_SETTING = FREQUENCY_DEVIATION_OFF;
|
||||
} else if (!IS_MR_CHANNEL(Channel)) {
|
||||
Frequency = FREQUENCY_FloorToStep(gEeprom.VfoInfo[VFO].FREQUENCY_OF_DEVIATION, gEeprom.VfoInfo[VFO].StepFrequency, 0);
|
||||
@ -344,7 +344,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
|
||||
|
||||
if (!gSetting_350EN) {
|
||||
FREQ_Config_t *pConfig = gEeprom.VfoInfo[VFO].pCurrent;
|
||||
if (pConfig->Frequency - 35000000 < 4999991) {
|
||||
if (pConfig->Frequency >= 35000000 && pConfig->Frequency <= 39999990) {
|
||||
pConfig->Frequency = 41001250;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin
|
||||
Start += (((End - Start) - (Length * Width)) + 1) / 2;
|
||||
}
|
||||
for (i = 0; i < Length; i++) {
|
||||
if (pString[i] - ' ' < 0x5F) {
|
||||
if (pString[i] >= ' ' && pString[i] < 0x7F) {
|
||||
uint8_t Index = pString[i] - ' ';
|
||||
memcpy(gFrameBuffer[Line + 0] + (i * Width) + Start, &gFontBig[Index][0], 8);
|
||||
memcpy(gFrameBuffer[Line + 1] + (i * Width) + Start, &gFontBig[Index][8], 8);
|
||||
|
Loading…
Reference in New Issue
Block a user