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:
@@ -34,6 +34,20 @@ jobs:
|
|||||||
make clean
|
make clean
|
||||||
make cppcheck
|
make cppcheck
|
||||||
|
|
||||||
|
flawfinder:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Create Build Environment
|
||||||
|
run: |
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get install -qq flawfinder
|
||||||
|
- name: cppcheck
|
||||||
|
run: |
|
||||||
|
flawfinder --version
|
||||||
|
make clean
|
||||||
|
make flawfinder
|
||||||
|
|
||||||
codespell:
|
codespell:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
@@ -222,10 +222,16 @@ lint:
|
|||||||
CPPCHECK_OPTIONS = --enable=warning,portability
|
CPPCHECK_OPTIONS = --enable=warning,portability
|
||||||
CPPCHECK_OPTIONS += --template=gcc
|
CPPCHECK_OPTIONS += --template=gcc
|
||||||
CPPCHECK_OPTIONS += --suppress=selfAssignment
|
CPPCHECK_OPTIONS += --suppress=selfAssignment
|
||||||
|
CPPCHECK_OPTIONS += --suppress=integerOverflow
|
||||||
|
CPPCHECK_OPTIONS += --error-exitcode=1
|
||||||
.PHONY: cppcheck
|
.PHONY: cppcheck
|
||||||
cppcheck:
|
cppcheck:
|
||||||
cppcheck $(CPPCHECK_OPTIONS) --quiet --force ./src/
|
cppcheck $(CPPCHECK_OPTIONS) --quiet --force ./src/
|
||||||
|
|
||||||
|
.PHONY: flawfinder
|
||||||
|
flawfinder:
|
||||||
|
flawfinder --minlevel 5 --error-level=5 ./src/
|
||||||
|
|
||||||
IGNORE_WORDS = ba
|
IGNORE_WORDS = ba
|
||||||
CODESPELL_OPTIONS = --write-changes --interactive 3 --enable-colors
|
CODESPELL_OPTIONS = --write-changes --interactive 3 --enable-colors
|
||||||
CODESPELL_OPTIONS += --ignore-words-list $(IGNORE_WORDS)
|
CODESPELL_OPTIONS += --ignore-words-list $(IGNORE_WORDS)
|
||||||
|
|||||||
@@ -946,8 +946,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
|||||||
ToState = CurrentAV->Ack_notify_data.EventState;
|
ToState = CurrentAV->Ack_notify_data.EventState;
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "Send Acknotification for (%s,%d).\n",
|
fprintf(stderr, "Send Acknotification for (%s,%u).\n",
|
||||||
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance);
|
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||||
|
(unsigned)object_instance);
|
||||||
#endif /* PRINT_ENABLED */
|
#endif /* PRINT_ENABLED */
|
||||||
|
|
||||||
characterstring_init_ansi(&msgText, "AckNotification");
|
characterstring_init_ansi(&msgText, "AckNotification");
|
||||||
@@ -1094,8 +1095,9 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
|
|||||||
} /* switch (ToState) */
|
} /* switch (ToState) */
|
||||||
|
|
||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "Event_State for (%s,%d) goes from %s to %s.\n",
|
fprintf(stderr, "Event_State for (%s,%u) goes from %s to %s.\n",
|
||||||
bactext_object_type_name(OBJECT_ANALOG_VALUE), object_instance,
|
bactext_object_type_name(OBJECT_ANALOG_VALUE),
|
||||||
|
(unsigned)object_instance,
|
||||||
bactext_event_state_name(FromState),
|
bactext_event_state_name(FromState),
|
||||||
bactext_event_state_name(ToState));
|
bactext_event_state_name(ToState));
|
||||||
#endif /* PRINT_ENABLED */
|
#endif /* PRINT_ENABLED */
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ bool bacfile_read_ack_stream_data(
|
|||||||
pFilename = bacfile_name(instance);
|
pFilename = bacfile_name(instance);
|
||||||
if (pFilename) {
|
if (pFilename) {
|
||||||
found = true;
|
found = true;
|
||||||
pFile = fopen(pFilename, "rb");
|
pFile = fopen(pFilename, "rb+");
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
(void)fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
|
(void)fseek(pFile, data->type.stream.fileStartPosition, SEEK_SET);
|
||||||
if (fwrite(octetstring_value(&data->fileData[0]),
|
if (fwrite(octetstring_value(&data->fileData[0]),
|
||||||
@@ -574,7 +574,7 @@ bool bacfile_read_ack_record_data(
|
|||||||
pFilename = bacfile_name(instance);
|
pFilename = bacfile_name(instance);
|
||||||
if (pFilename) {
|
if (pFilename) {
|
||||||
found = true;
|
found = true;
|
||||||
pFile = fopen(pFilename, "rb");
|
pFile = fopen(pFilename, "rb+");
|
||||||
if (pFile) {
|
if (pFile) {
|
||||||
if (data->type.record.fileStartRecord > 0) {
|
if (data->type.record.fileStartRecord > 0) {
|
||||||
for (i = 0; i < (uint32_t)data->type.record.fileStartRecord;
|
for (i = 0; i < (uint32_t)data->type.record.fileStartRecord;
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ void handler_atomic_read_file(uint8_t *service_request,
|
|||||||
#if PRINT_ENABLED
|
#if PRINT_ENABLED
|
||||||
fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n",
|
fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n",
|
||||||
(int)data.type.record.fileStartRecord,
|
(int)data.type.record.fileStartRecord,
|
||||||
(int)data.type.record.RecordCount);
|
(unsigned)data.type.record.RecordCount);
|
||||||
#endif
|
#endif
|
||||||
len = arf_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
len = arf_ack_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||||
service_data->invoke_id, &data);
|
service_data->invoke_id, &data);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ void ge_ack_print_data(
|
|||||||
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
|
const char *state_strs[] = { "NO", "FA", "ON", "HL", "LL" };
|
||||||
printf("DeviceID\tType\tInstance\teventState\n");
|
printf("DeviceID\tType\tInstance\teventState\n");
|
||||||
printf("--------------- ------- --------------- ---------------\n");
|
printf("--------------- ------- --------------- ---------------\n");
|
||||||
int count = 0;
|
unsigned int count = 0;
|
||||||
while (act_data) {
|
while (act_data) {
|
||||||
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
|
printf("%u\t\t%u\t%u\t\t%s\n", device_id,
|
||||||
act_data->objectIdentifier.type,
|
act_data->objectIdentifier.type,
|
||||||
|
|||||||
@@ -1509,7 +1509,7 @@ BACNET_PROPERTY_ID property_list_special_property(
|
|||||||
{
|
{
|
||||||
int property = -1; /* return value */
|
int property = -1; /* return value */
|
||||||
unsigned required, optional, proprietary;
|
unsigned required, optional, proprietary;
|
||||||
struct special_property_list_t PropertyList = { { 0 } };
|
struct special_property_list_t PropertyList = { 0 };
|
||||||
|
|
||||||
property_list_special(object_type, &PropertyList);
|
property_list_special(object_type, &PropertyList);
|
||||||
required = PropertyList.Required.count;
|
required = PropertyList.Required.count;
|
||||||
@@ -1552,7 +1552,7 @@ unsigned property_list_special_count(
|
|||||||
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID special_property)
|
BACNET_OBJECT_TYPE object_type, BACNET_PROPERTY_ID special_property)
|
||||||
{
|
{
|
||||||
unsigned count = 0; /* return value */
|
unsigned count = 0; /* return value */
|
||||||
struct special_property_list_t PropertyList = { { 0 } };
|
struct special_property_list_t PropertyList = { 0 };
|
||||||
|
|
||||||
property_list_special(object_type, &PropertyList);
|
property_list_special(object_type, &PropertyList);
|
||||||
if (special_property == PROP_ALL) {
|
if (special_property == PROP_ALL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user