Fix warnings and errors found by the new cppcheck provided static code analysis.

pull/1469/head
Dean Camera 13 years ago
parent b762780343
commit bb85d083a7

@ -801,6 +801,7 @@ int read_intel_hex(const char *filename)
if (*buf) {
if (parse_hex_line(buf) == 0) {
//printf("Warning, parse error line %d\n", lineno);
fclose(fp);
return -2;
}
}

@ -18,6 +18,6 @@ EXCLUDE_LIST = HostLoaderApp/ FATFs/ PetiteFATFs/ uip/
MESSAGE_TEMPLATE = "{file}({line}): {severity} ({id}): {message}"
all:
cppcheck -q -f --error-exitcode=1 --template $(MESSAGE_TEMPLATE) --enable=style --suppress=variableScope $(EXCLUDE_LIST:%=-i%) $(LUFA_ROOT_PATH)
cppcheck -q -f --error-exitcode=1 --inline-suppr --enable=style --suppress=variableScope --template $(MESSAGE_TEMPLATE) $(EXCLUDE_LIST:%=-i%) $(LUFA_ROOT_PATH)
%:

@ -473,8 +473,8 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
ResponsePacket.SignalCommandHeader.Length = sizeof(ResponsePacket.ConnectionResponse);
/* Fill out the Connection Response in the response packet */
ResponsePacket.ConnectionResponse.DestinationChannel = ChannelData->LocalNumber;
ResponsePacket.ConnectionResponse.SourceChannel = ChannelData->RemoteNumber;
ResponsePacket.ConnectionResponse.DestinationChannel = (ChannelData != NULL) ? ChannelData->LocalNumber : 0;
ResponsePacket.ConnectionResponse.SourceChannel = (ChannelData != NULL) ? ChannelData->RemoteNumber : 0;
ResponsePacket.ConnectionResponse.Result = ChannelStatus;
ResponsePacket.ConnectionResponse.Status = 0x00;
@ -576,7 +576,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
ResponsePacket.SignalCommandHeader.Length = sizeof(ResponsePacket.ConfigurationResponse);
/* Fill out the Configuration Response in the response packet */
ResponsePacket.ConfigurationResponse.SourceChannel = ChannelData->RemoteNumber;
ResponsePacket.ConfigurationResponse.SourceChannel = (ChannelData != NULL) ? ChannelData->RemoteNumber : 0;
ResponsePacket.ConfigurationResponse.Flags = 0x00;
ResponsePacket.ConfigurationResponse.Result = (ChannelData != NULL) ? BT_CONFIGURATION_SUCCESSFUL : BT_CONFIGURATION_REJECTED;
@ -681,8 +681,8 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c
ResponsePacket.SignalCommandHeader.Length = sizeof(ResponsePacket.DisconnectionResponse);
/* Fill out the Disconnection Response in the response packet */
ResponsePacket.DisconnectionResponse.DestinationChannel = ChannelData->RemoteNumber;
ResponsePacket.DisconnectionResponse.SourceChannel = ChannelData->LocalNumber;
ResponsePacket.DisconnectionResponse.DestinationChannel = (ChannelData != NULL) ? ChannelData->RemoteNumber : 0;
ResponsePacket.DisconnectionResponse.SourceChannel = (ChannelData != NULL) ? ChannelData->LocalNumber : 0;
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);

File diff suppressed because one or more lines are too long

@ -40,7 +40,7 @@ struct
bool ProgrammerConfig_ProcessConfiguration(void)
{
memset(&ProgrammerConfig, sizeof(ProgrammerConfig), 0x00);
memset(&ProgrammerConfig, 0x00, sizeof(ProgrammerConfig));
if (!(pf_open("CONF.txt") == FR_OK))
{
@ -61,8 +61,8 @@ bool ProgrammerConfig_ProcessConfiguration(void)
&ProgrammerConfig.SigBytes[1],
&ProgrammerConfig.SigBytes[2],
&ProgrammerConfig.SigBytes[3]);
sscanf(CurrentLine, "SPEED = %lu", &ProgrammerConfig.ProgrammingSpeed);
sscanf(CurrentLine, "SPEED = %08lu", &ProgrammerConfig.ProgrammingSpeed);
}
} while (CurrentLine);

@ -114,18 +114,15 @@ int main(void)
{
Programmer_Task();
#if defined(USB_CAN_BE_HOST)
if (USB_CurrentMode == USB_MODE_Host)
{
#if defined(USB_CAN_BE_HOST)
DiskHost_USBTask();
#endif
}
else
{
#if defined(USB_CAN_BE_DEVICE)
DiskDevice_USBTask();
#endif
}
DiskHost_USBTask();
#endif
#if defined(USB_CAN_BE_DEVICE)
if (USB_CurrentMode == USB_MODE_Device)
DiskDevice_USBTask();
#endif
USB_USBTask();
}

@ -9,10 +9,7 @@
bool DS1307_SetTimeDate(const TimeDate_t* NewTimeDate)
{
#if defined(DUMMY_RTC)
return true;
#endif
#if !defined(DUMMY_RTC)
DS1307_DateTimeRegs_t NewRegValues;
const uint8_t WriteAddress = 0;
@ -41,6 +38,7 @@ bool DS1307_SetTimeDate(const TimeDate_t* NewTimeDate)
{
return false;
}
#endif
return true;
}
@ -55,10 +53,7 @@ bool DS1307_GetTimeDate(TimeDate_t* const TimeDate)
TimeDate->Day = 1;
TimeDate->Month = 1;
TimeDate->Year = 1;
return true;
#endif
#else
DS1307_DateTimeRegs_t CurrentRegValues;
const uint8_t ReadAddress = 0;
@ -78,6 +73,7 @@ bool DS1307_GetTimeDate(TimeDate_t* const TimeDate)
TimeDate->Day = (CurrentRegValues.Byte5.Fields.TenDay * 10) + CurrentRegValues.Byte5.Fields.Day;
TimeDate->Month = (CurrentRegValues.Byte6.Fields.TenMonth * 10) + CurrentRegValues.Byte6.Fields.Month;
TimeDate->Year = (CurrentRegValues.Byte7.Fields.TenYear * 10) + CurrentRegValues.Byte7.Fields.Year;
#endif
return true;
}

Loading…
Cancel
Save