Bugfix/cppcheck error code fixes (#244)

* Add flawfinder. Add error code for exit status.

* fix errors found by cppcheck

* fix initialization warning in unit test compile

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-03-28 10:29:52 -05:00
committed by GitHub
parent 7b685d0e3d
commit 5b07b484d4
7 changed files with 32 additions and 10 deletions
+6 -4
View File
@@ -946,8 +946,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
ToState = CurrentAV->Ack_notify_data.EventState;
#if PRINT_ENABLED
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance);
fprintf(stderr, "Send Acknotification for (%s,%u).\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE),
(unsigned)object_instance);
#endif /* PRINT_ENABLED */
characterstring_init_ansi(&msgText, "AckNotification");
@@ -1094,8 +1095,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
} /* switch (ToState) */
#if PRINT_ENABLED
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance,
fprintf(stderr, "Event_State for (%s,%u) goes from %s to %s.\n",
bactext_object_type_name(OBJECT_ANALOG_VALUE),
(unsigned)object_instance,
bactext_event_state_name(FromState),
bactext_event_state_name(ToState));
#endif /* PRINT_ENABLED */
+2 -2
View File
@@ -544,7 +544,7 @@ bool bacfile_read_ack_stream_data(
pFilename = bacfile_name(instance);
if (pFilename) {
found = true;
pFile = fopen(pFilename, "rb");
pFile = fopen(pFilename, "rb+");
if (pFile) {
(void)fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
if (fwrite(octetstring_value(&data->fileData[0]),
@@ -574,7 +574,7 @@ bool bacfile_read_ack_record_data(
pFilename = bacfile_name(instance);
if (pFilename) {
found = true;
pFile = fopen(pFilename, "rb");
pFile = fopen(pFilename, "rb+");
if (pFile) {
if (data->type.record.fileStartRecord > 0) {
for (i = 0; i < (uint32_t)data->type.record.fileStartRecord;
+1 -1
View File
@@ -173,7 +173,7 @@ void handler_atomic_read_file(uint8_t *service_request,
#if PRINT_ENABLED
fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n",
(int)data.type.record.fileStartRecord,
(int)data.type.record.RecordCount);
(unsigned)data.type.record.RecordCount);
#endif
len = arf_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
service_data->invoke_id, &data);
+1 -1
View File
@@ -55,7 +55,7 @@ void ge_ack_print_data(
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
printf("DeviceID\tType\tInstance\teventState\n");
printf("--------------- ------- --------------- ---------------\n");
int count = 0;
unsigned int count = 0;
while (act_data) {
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
act_data->objectIdentifier.type,