Build more code in CI (#725)

* bugfix/hostnport: Fix bacnet_fdt_entry_from_ascii() parse wrong
* apps/router: Fix Wstrict-prototypes compiler warnings
* apps/router: Fix -Wmissing-field-initializers compiler warning
* ports/linux: Fix -Wself-assign compiler warning
* ports/linux: Fix -Wunused-function compiler warning
* Fix -Wimplicit-function-declaration warnings
* ci: Add more compile options to enable more code build
* ci: Do not fail-fast our main matrix build
* cmake: Add -Wno-c99-extensions compiler option

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Kari Argillander
2024-08-15 19:20:10 +03:00
committed by GitHub
parent 2d7a2961a2
commit dab6d8af55
15 changed files with 85 additions and 28 deletions
+39 -4
View File
@@ -17,6 +17,7 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false
matrix: matrix:
os: [windows-latest, ubuntu-latest, macOS-latest] os: [windows-latest, ubuntu-latest, macOS-latest]
project: [root, test] project: [root, test]
@@ -28,6 +29,13 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Install Dependencies (Ubuntu)
if: matrix.os == 'ubuntu-latest' && matrix.project == 'root'
run: |
sudo apt-get update
# apps/router needs libconfig-dev.
sudo apt-get install -y libconfig-dev
- name: Create Build Environment - name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory # Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands # We'll use this as our working directory for all subsequent commands
@@ -48,12 +56,39 @@ jobs:
source_dir=$GITHUB_WORKSPACE source_dir=$GITHUB_WORKSPACE
fi fi
if [[ "$RUNNER_OS" == "Windows" ]]; then c_flags=""
cmake $source_dir -DCMAKE_BUILD_TYPE=$BUILD_TYPE if [[ "$RUNNER_OS" != "Windows" ]]; then
else # Warnings as errors.
cmake $source_dir -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="-Werror" c_flags="$c_flags -Werror"
fi fi
# Compile as much as possible to at least compile test code.
c_flags="$c_flags -DBACFILE=ON"
c_flags="$c_flags -DPRINT_ENABLED=1"
c_flags="$c_flags -DBACNET_TIME_MASTER=ON"
c_flags="$c_flags -DBACAPP_COLOR_RGB_CONVERSION_ENABLED=ON"
cmake_options="-DCMAKE_C_FLAGS=$c_flags"
# TODO: Add BACDL_BIP6=ON when it builds withous errors.
cmake_options="$cmake_options -DBACDL_BIP=ON"
cmake_options="$cmake_options -DBACNET_PROTOCOL_REVISION=24"
if [[ "$RUNNER_OS" != "macOS" ]]; then
# Apple does not have port yet for this.
cmake_options="$cmake_options -DBACDL_MSTP=ON"
fi
if [[ "$RUNNER_OS" == "Linux" ]]; then
# Apple nor Windows does not have port yet for this.
cmake_options="$cmake_options -DBACDL_ARCNET=ON"
# Currently Windows fails because of pcab.h not found.
# Apple does not have port yet for this.
cmake_options="$cmake_options -DBACDL_ETHERNET=ON"
fi
cmake $source_dir -DCMAKE_BUILD_TYPE=$BUILD_TYPE $cmake_options
- name: Build - name: Build
working-directory: ${{runner.workspace}}/build working-directory: ${{runner.workspace}}/build
shell: bash shell: bash
+1 -1
View File
@@ -765,7 +765,7 @@ if(BACNET_STACK_BUILD_APPS)
add_executable(reinit apps/reinit/main.c) add_executable(reinit apps/reinit/main.c)
target_link_libraries(reinit PRIVATE ${PROJECT_NAME}) target_link_libraries(reinit PRIVATE ${PROJECT_NAME})
if(BACDL_MSTP) if(BACDL_MSTP AND NOT WIN32)
add_executable( add_executable(
router router
apps/router/ipmodule.c apps/router/ipmodule.c
+2
View File
@@ -38,6 +38,8 @@
#include "bacnet/basic/sys/keylist.h" #include "bacnet/basic/sys/keylist.h"
#include "bacnet/basic/tsm/tsm.h" #include "bacnet/basic/tsm/tsm.h"
#include "bacnet/datalink/datalink.h" #include "bacnet/datalink/datalink.h"
#include "bacnet/datalink/bip.h"
#include "bacnet/basic/bbmd/h_bbmd.h"
#include "bacnet/datalink/dlenv.h" #include "bacnet/datalink/dlenv.h"
#include "bacepics.h" #include "bacepics.h"
+2
View File
@@ -24,6 +24,8 @@
#include "bacnet/basic/object/device.h" #include "bacnet/basic/object/device.h"
#include "bacnet/datalink/datalink.h" #include "bacnet/datalink/datalink.h"
#include "bacnet/datalink/bvlc.h" #include "bacnet/datalink/bvlc.h"
#include "bacnet/datalink/bip.h"
#include "bacnet/basic/bbmd/h_bbmd.h"
/* some demo stuff needed */ /* some demo stuff needed */
#include "bacnet/basic/sys/debug.h" #include "bacnet/basic/sys/debug.h"
#include "bacnet/basic/sys/filename.h" #include "bacnet/basic/sys/filename.h"
+2
View File
@@ -24,6 +24,8 @@
#include "bacnet/basic/object/device.h" #include "bacnet/basic/object/device.h"
#include "bacnet/datalink/datalink.h" #include "bacnet/datalink/datalink.h"
#include "bacnet/datalink/bvlc.h" #include "bacnet/datalink/bvlc.h"
#include "bacnet/datalink/bip.h"
#include "bacnet/basic/bbmd/h_bbmd.h"
/* some demo stuff needed */ /* some demo stuff needed */
#include "bacnet/basic/sys/debug.h" #include "bacnet/basic/sys/debug.h"
#include "bacnet/basic/sys/filename.h" #include "bacnet/basic/sys/filename.h"
+10 -10
View File
@@ -41,7 +41,7 @@ ROUTER_PORT *head = NULL; /* pointer to list of router ports */
int port_count; int port_count;
void print_help(); void print_help(void);
bool read_config(char *filepath); bool read_config(char *filepath);
@@ -49,17 +49,17 @@ bool parse_cmd(int argc, char *argv[]);
void init_port_threads(ROUTER_PORT *port_list); void init_port_threads(ROUTER_PORT *port_list);
bool init_router(); bool init_router(void);
void cleanup(); void cleanup(void);
void print_msg(BACMSG *msg); void print_msg(BACMSG *msg);
uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff); uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff);
uint16_t get_next_free_dnet(); uint16_t get_next_free_dnet(void);
int kbhit(); int kbhit(void);
inline bool is_network_msg(BACMSG *msg); inline bool is_network_msg(BACMSG *msg);
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
void print_help() void print_help(void)
{ {
printf( printf(
"Usage: router <init_method> [init_parameters]\n" "Usage: router <init_method> [init_parameters]\n"
@@ -649,7 +649,7 @@ void init_port_threads(ROUTER_PORT *port_list)
} }
} }
bool init_router() bool init_router(void)
{ {
MSGBOX_ID msgboxid; MSGBOX_ID msgboxid;
ROUTER_PORT *port; ROUTER_PORT *port;
@@ -687,7 +687,7 @@ bool init_router()
return true; return true;
} }
void cleanup() void cleanup(void)
{ {
ROUTER_PORT *port; ROUTER_PORT *port;
BACMSG msg; BACMSG msg;
@@ -801,7 +801,7 @@ uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
return buff_len; return buff_len;
} }
int kbhit() int kbhit(void)
{ {
static const int STDIN = 0; static const int STDIN = 0;
static bool initialized = false; static bool initialized = false;
@@ -831,7 +831,7 @@ bool is_network_msg(BACMSG *msg)
return control_byte & 0x80; /* check 7th bit */ return control_byte & 0x80; /* check 7th bit */
} }
uint16_t get_next_free_dnet() uint16_t get_next_free_dnet(void)
{ {
ROUTER_PORT *port = head; ROUTER_PORT *port = head;
uint16_t i = 1; uint16_t i = 1;
+1 -1
View File
@@ -17,7 +17,7 @@
pthread_mutex_t msg_lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t msg_lock = PTHREAD_MUTEX_INITIALIZER;
MSGBOX_ID create_msgbox() MSGBOX_ID create_msgbox(void)
{ {
MSGBOX_ID msgboxid; MSGBOX_ID msgboxid;
+1 -2
View File
@@ -55,8 +55,7 @@ typedef struct _msg_data {
uint8_t ref_count; uint8_t ref_count;
} MSG_DATA; } MSG_DATA;
MSGBOX_ID create_msgbox( MSGBOX_ID create_msgbox(void);
);
/* returns sent byte count */ /* returns sent byte count */
bool send_to_msgbox( bool send_to_msgbox(
+1 -1
View File
@@ -27,7 +27,7 @@
void *dl_mstp_thread(void *pArgs) void *dl_mstp_thread(void *pArgs)
{ {
ROUTER_PORT *port = (ROUTER_PORT *)pArgs; ROUTER_PORT *port = (ROUTER_PORT *)pArgs;
struct mstp_port_struct_t mstp_port = { (MSTP_RECEIVE_STATE)0 }; struct mstp_port_struct_t mstp_port = { 0 };
volatile SHARED_MSTP_DATA shared_port_data = { 0 }; volatile SHARED_MSTP_DATA shared_port_data = { 0 };
uint16_t pdu_len; uint16_t pdu_len;
uint8_t shutdown = 0; uint8_t shutdown = 0;
+3 -2
View File
@@ -426,8 +426,9 @@ static bool dlmstp_compare_data_expecting_reply(
struct DER_compare_t reply; struct DER_compare_t reply;
/* unused parameters */ /* unused parameters */
request_pdu_len = request_pdu_len; (void)request_pdu_len;
reply_pdu_len = reply_pdu_len; (void)reply_pdu_len;
/* decode the request data */ /* decode the request data */
request.address.mac[0] = src_address; request.address.mac[0] = src_address;
request.address.mac_len = 1; request.address.mac_len = 1;
+8 -2
View File
@@ -408,8 +408,9 @@ static bool dlmstp_compare_data_expecting_reply(
struct DER_compare_t reply; struct DER_compare_t reply;
/* unused parameters */ /* unused parameters */
request_pdu_len = request_pdu_len; (void)request_pdu_len;
reply_pdu_len = reply_pdu_len; (void)reply_pdu_len;
/* decode the request data */ /* decode the request data */
request.address.mac[0] = src_address; request.address.mac[0] = src_address;
request.address.mac_len = 1; request.address.mac_len = 1;
@@ -857,5 +858,10 @@ bool dlmstp_init(void *poPort, char *ifname)
fprintf(stderr, "Failed to start Master Node FSM task\n"); fprintf(stderr, "Failed to start Master Node FSM task\n");
} }
/* You can try also this for thread. This here so we ignore
* -Wunused-function compiler warning
*/
dlmstp_receive_fsm_task(NULL);
return true; return true;
} }
+3
View File
@@ -22,6 +22,9 @@
#include "bacnet/basic/sys/debug.h" #include "bacnet/basic/sys/debug.h"
#include "bacnet/basic/services.h" #include "bacnet/basic/services.h"
#include "bacnet/datalink/datalink.h" #include "bacnet/datalink/datalink.h"
#if defined(BACDL_BIP)
#include "bacnet/basic/bbmd/h_bbmd.h"
#endif
#if PRINT_ENABLED #if PRINT_ENABLED
#include <stdio.h> #include <stdio.h>
+3 -1
View File
@@ -20,9 +20,11 @@
#include "bacnet/rp.h" /* ReadProperty handling */ #include "bacnet/rp.h" /* ReadProperty handling */
#include "bacnet/dcc.h" /* DeviceCommunicationControl handling */ #include "bacnet/dcc.h" /* DeviceCommunicationControl handling */
#include "bacnet/version.h" #include "bacnet/version.h"
#if defined(BACDL_MSTP)
#include "bacnet/datalink/dlmstp.h"
#endif
#include "bacnet/basic/object/device.h" /* me */ #include "bacnet/basic/object/device.h" /* me */
#include "bacnet/basic/services.h" #include "bacnet/basic/services.h"
#include "bacnet/datalink/datalink.h"
#include "bacnet/basic/binding/address.h" #include "bacnet/basic/binding/address.h"
/* include the device object */ /* include the device object */
#include "bacnet/basic/object/device.h" #include "bacnet/basic/object/device.h"
+5
View File
@@ -18,6 +18,11 @@
#include "bacnet/basic/services.h" #include "bacnet/basic/services.h"
#include "bacnet/datalink/dlenv.h" #include "bacnet/datalink/dlenv.h"
#include "bacnet/basic/tsm/tsm.h" #include "bacnet/basic/tsm/tsm.h"
#if defined(BACDL_BIP)
#include "bacnet/datalink/bip.h"
#include "bacnet/basic/bbmd/h_bbmd.h"
#endif
#if (BACNET_PROTOCOL_REVISION >= 17) #if (BACNET_PROTOCOL_REVISION >= 17)
#include "bacnet/basic/object/netport.h" #include "bacnet/basic/object/netport.h"
#endif #endif
+4 -4
View File
@@ -1055,8 +1055,8 @@ bool bacnet_fdt_entry_from_ascii(BACNET_FDT_ENTRY *value, const char *argv)
value->time_to_live = (uint16_t)ttl; value->time_to_live = (uint16_t)ttl;
value->remaining_time_to_live = (uint16_t)rttl; value->remaining_time_to_live = (uint16_t)rttl;
} }
address[4] = (uint8_t)p >> 8; address[4] = (uint8_t)((p >> 8) & 0xFF);
address[5] = (uint8_t)p & 0xFF; address[5] = (uint8_t)((p >> 0) & 0xFF);
octetstring_init(&value->bacnetip_address, address, 6); octetstring_init(&value->bacnetip_address, address, 6);
status = true; status = true;
} else { } else {
@@ -1099,8 +1099,8 @@ bool bacnet_fdt_entry_from_ascii(BACNET_FDT_ENTRY *value, const char *argv)
value->time_to_live = (uint16_t)ttl; value->time_to_live = (uint16_t)ttl;
value->remaining_time_to_live = (uint16_t)rttl; value->remaining_time_to_live = (uint16_t)rttl;
} }
address[16] = (uint8_t)p >> 8; address[16] = (uint8_t)((p >> 8) & 0xFF);
address[17] = (uint8_t)p & 0xFF; address[17] = (uint8_t)((p >> 0) & 0xFF);
octetstring_init(&value->bacnetip_address, address, 18); octetstring_init(&value->bacnetip_address, address, 18);
status = true; status = true;
} else { } else {