Fix type definitions for inner_tag and object_instance when uint32_t is defined as long unsigned int instead of unsigned int (#1293)

* Fix type definitions in bacapp.c for inner_tag and object_instance when uint32_t is defined as long unsigned int instead of unsigned int

* Change DNET_list type from int to int32_t across multiple files to avoid compiler warnings when int32_t is defined as long int instead of int.
This commit is contained in:
Steve Karg
2026-04-06 11:51:36 -05:00
committed by GitHub
parent 589a61b287
commit e77e070d90
10 changed files with 38 additions and 32 deletions
+4
View File
@@ -216,6 +216,10 @@ The git repositories are hosted at the following sites:
### Fixed ### Fixed
* Fixed type definition compiler warnings in DNET list when int32_t is
defined as long int instead of int on 32-bit platforms, and in bacapp
module for inner_tag and object_instance when uint32_t is defined
as long unsigned int instead of unsigned int on 32-bit platforms. (#1293)
* Fixed CMakeLists.txt by replacing BIG_ENDIAN definition with * Fixed CMakeLists.txt by replacing BIG_ENDIAN definition with
BACNET_BIG_ENDIAN to fix missing function in builds. (#1284) BACNET_BIG_ENDIAN to fix missing function in builds. (#1284)
* Fixed CMakeLists.txt by adding INTRINSIC_REPORTING CMake option * Fixed CMakeLists.txt by adding INTRINSIC_REPORTING CMake option
+1 -1
View File
@@ -53,7 +53,7 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/** The list of DNETs that our router can reach. /** The list of DNETs that our router can reach.
* Only one entry since we don't support downstream routers. * Only one entry since we don't support downstream routers.
*/ */
int DNET_list[2] = { int32_t DNET_list[2] = {
VIRTUAL_DNET, -1 /* Need -1 terminator */ VIRTUAL_DNET, -1 /* Need -1 terminator */
}; };
+1 -1
View File
@@ -56,7 +56,7 @@ static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/** The list of DNETs that our router can reach. /** The list of DNETs that our router can reach.
* Only one entry since we don't support downstream routers. * Only one entry since we don't support downstream routers.
*/ */
int DNET_list[2] = { int32_t DNET_list[2] = {
VIRTUAL_DNET, -1 /* Need -1 terminator */ VIRTUAL_DNET, -1 /* Need -1 terminator */
}; };
+6 -6
View File
@@ -4147,7 +4147,7 @@ parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value)
{ {
char *chunk, *comma, *space, *t, *v, *colonpos, *sqpos; char *chunk, *comma, *space, *t, *v, *colonpos, *sqpos;
int daynum = 0, tvnum = 0; int daynum = 0, tvnum = 0;
unsigned int inner_tag; uint32_t inner_tag;
BACNET_APPLICATION_DATA_VALUE dummy_value = { 0 }; BACNET_APPLICATION_DATA_VALUE dummy_value = { 0 };
BACNET_DAILY_SCHEDULE *dsch; BACNET_DAILY_SCHEDULE *dsch;
@@ -4179,7 +4179,7 @@ parse_weeklyschedule(char *str, BACNET_APPLICATION_DATA_VALUE *value)
return false; return false;
} }
} else { } else {
inner_tag = (int)dummy_value.type.Unsigned_Int; inner_tag = (uint32_t)dummy_value.type.Unsigned_Int;
} }
chunk = strtok(NULL, ";"); chunk = strtok(NULL, ";");
@@ -4810,8 +4810,8 @@ bool bacapp_parse_application_data(
#if defined(BACAPP_DATE) #if defined(BACAPP_DATE)
int year, month, day, wday; int year, month, day, wday;
#endif #endif
int object_type = 0; unsigned int object_type = 0;
uint32_t instance = 0; unsigned int object_instance = 0;
bool status = false; bool status = false;
long long_value = 0; long long_value = 0;
BACNET_UNSIGNED_INTEGER unsigned_long_value = 0; BACNET_UNSIGNED_INTEGER unsigned_long_value = 0;
@@ -4957,10 +4957,10 @@ bool bacapp_parse_application_data(
#endif #endif
#if defined(BACAPP_OBJECT_ID) #if defined(BACAPP_OBJECT_ID)
case BACNET_APPLICATION_TAG_OBJECT_ID: case BACNET_APPLICATION_TAG_OBJECT_ID:
count = sscanf(argv, "%4d:%7u", &object_type, &instance); count = sscanf(argv, "%4u:%7u", &object_type, &object_instance);
if (count == 2) { if (count == 2) {
value->type.Object_Id.type = (uint16_t)object_type; value->type.Object_Id.type = (uint16_t)object_type;
value->type.Object_Id.instance = instance; value->type.Object_Id.instance = (uint32_t)object_instance;
} else { } else {
status = false; status = false;
} }
+4 -4
View File
@@ -50,7 +50,7 @@
*/ */
static void network_control_handler( static void network_control_handler(
BACNET_ADDRESS *src, BACNET_ADDRESS *src,
int *DNET_list, int32_t *DNET_list,
BACNET_NPDU_DATA *npdu_data, BACNET_NPDU_DATA *npdu_data,
uint8_t *npdu, uint8_t *npdu,
uint16_t npdu_len) uint16_t npdu_len)
@@ -58,6 +58,7 @@ static void network_control_handler(
uint16_t npdu_offset = 0; uint16_t npdu_offset = 0;
uint16_t dnet = 0; uint16_t dnet = 0;
uint16_t len = 0; uint16_t len = 0;
int32_t listTerminator = -1;
switch (npdu_data->network_message_type) { switch (npdu_data->network_message_type) {
case NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK: case NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK:
@@ -133,7 +134,6 @@ static void network_control_handler(
* with no routing list of our own. But we don't DO * with no routing list of our own. But we don't DO
* anything with the info, either. * anything with the info, either.
*/ */
int listTerminator = -1;
Send_Initialize_Routing_Table_Ack(src, &listTerminator); Send_Initialize_Routing_Table_Ack(src, &listTerminator);
} }
break; break;
@@ -181,7 +181,7 @@ static void network_control_handler(
static void routed_apdu_handler( static void routed_apdu_handler(
BACNET_ADDRESS *src, BACNET_ADDRESS *src,
BACNET_ADDRESS *dest, BACNET_ADDRESS *dest,
int *DNET_list, int32_t *DNET_list,
uint8_t *apdu, uint8_t *apdu,
uint16_t apdu_len) uint16_t apdu_len)
{ {
@@ -260,7 +260,7 @@ static void routed_apdu_handler(
* @param pdu_len [in] The size of the received message in the pdu[] buffer. * @param pdu_len [in] The size of the received message in the pdu[] buffer.
*/ */
void routing_npdu_handler( void routing_npdu_handler(
BACNET_ADDRESS *src, int *DNET_list, uint8_t *pdu, uint16_t pdu_len) BACNET_ADDRESS *src, int32_t *DNET_list, uint8_t *pdu, uint16_t pdu_len)
{ {
int apdu_offset = 0; int apdu_offset = 0;
BACNET_ADDRESS dest = { 0 }; BACNET_ADDRESS dest = { 0 };
+1 -1
View File
@@ -22,7 +22,7 @@ extern "C" {
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void routing_npdu_handler( void routing_npdu_handler(
BACNET_ADDRESS *src, int *DNET_list, uint8_t *pdu, uint16_t pdu_len); BACNET_ADDRESS *src, int32_t *DNET_list, uint8_t *pdu, uint16_t pdu_len);
#ifdef __cplusplus #ifdef __cplusplus
} }
+11 -10
View File
@@ -46,12 +46,12 @@
int Send_Network_Layer_Message( int Send_Network_Layer_Message(
BACNET_NETWORK_MESSAGE_TYPE network_message_type, BACNET_NETWORK_MESSAGE_TYPE network_message_type,
BACNET_ADDRESS *dst, BACNET_ADDRESS *dst,
const int *iArgs) const int32_t *iArgs)
{ {
int len = 0; int len = 0;
int pdu_len = 0; int pdu_len = 0;
int bytes_sent = 0; int bytes_sent = 0;
const int *pVal = iArgs; /* Start with first value */ const int32_t *pVal = iArgs; /* Start with first value */
bool data_expecting_reply = false; bool data_expecting_reply = false;
BACNET_NPDU_DATA npdu_data; BACNET_NPDU_DATA npdu_data;
BACNET_ADDRESS bcastDest; BACNET_ADDRESS bcastDest;
@@ -189,7 +189,7 @@ int Send_Network_Layer_Message(
* will be sent and the receiving router(s) will send * will be sent and the receiving router(s) will send
* their full list of reachable BACnet networks. * their full list of reachable BACnet networks.
*/ */
void Send_Who_Is_Router_To_Network(BACNET_ADDRESS *dst, int dnet) void Send_Who_Is_Router_To_Network(BACNET_ADDRESS *dst, int32_t dnet)
{ {
Send_Network_Layer_Message( Send_Network_Layer_Message(
NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, dst, &dnet); NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, dst, &dnet);
@@ -204,7 +204,7 @@ void Send_Who_Is_Router_To_Network(BACNET_ADDRESS *dst, int dnet)
* @param DNET_list [in] List of BACnet network numbers for which I am a router, * @param DNET_list [in] List of BACnet network numbers for which I am a router,
* terminated with -1 * terminated with -1
*/ */
void Send_I_Am_Router_To_Network(const int DNET_list[]) void Send_I_Am_Router_To_Network(const int32_t DNET_list[])
{ {
/* Use a NULL dst here since we want a broadcast MAC address. */ /* Use a NULL dst here since we want a broadcast MAC address. */
Send_Network_Layer_Message( Send_Network_Layer_Message(
@@ -222,9 +222,9 @@ void Send_I_Am_Router_To_Network(const int DNET_list[])
* @param dnet [in] Which BACnet network originated the message. * @param dnet [in] Which BACnet network originated the message.
*/ */
void Send_Reject_Message_To_Network( void Send_Reject_Message_To_Network(
BACNET_ADDRESS *dst, uint8_t reject_reason, int dnet) BACNET_ADDRESS *dst, uint8_t reject_reason, int32_t dnet)
{ {
int iArgs[2]; int32_t iArgs[2];
iArgs[0] = reject_reason; iArgs[0] = reject_reason;
iArgs[1] = dnet; iArgs[1] = dnet;
Send_Network_Layer_Message( Send_Network_Layer_Message(
@@ -248,7 +248,8 @@ void Send_Reject_Message_To_Network(
* terminated with -1. Will be just -1 when we are * terminated with -1. Will be just -1 when we are
* requesting a routing table. * requesting a routing table.
*/ */
void Send_Initialize_Routing_Table(BACNET_ADDRESS *dst, const int DNET_list[]) void Send_Initialize_Routing_Table(
BACNET_ADDRESS *dst, const int32_t DNET_list[])
{ {
/* Use a NULL dst here since we want a broadcast MAC address. */ /* Use a NULL dst here since we want a broadcast MAC address. */
Send_Network_Layer_Message(NETWORK_MESSAGE_INIT_RT_TABLE, dst, DNET_list); Send_Network_Layer_Message(NETWORK_MESSAGE_INIT_RT_TABLE, dst, DNET_list);
@@ -272,7 +273,7 @@ void Send_Initialize_Routing_Table(BACNET_ADDRESS *dst, const int DNET_list[])
* should be sent. * should be sent.
*/ */
void Send_Initialize_Routing_Table_Ack( void Send_Initialize_Routing_Table_Ack(
BACNET_ADDRESS *dst, const int DNET_list[]) BACNET_ADDRESS *dst, const int32_t DNET_list[])
{ {
Send_Network_Layer_Message( Send_Network_Layer_Message(
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, dst, DNET_list); NETWORK_MESSAGE_INIT_RT_TABLE_ACK, dst, DNET_list);
@@ -288,9 +289,9 @@ void Send_Initialize_Routing_Table_Ack(
* will be sent and the receiving router(s) will send * will be sent and the receiving router(s) will send
* their full list of reachable BACnet networks. * their full list of reachable BACnet networks.
*/ */
void Send_Network_Number_Is(BACNET_ADDRESS *dst, int dnet, int status) void Send_Network_Number_Is(BACNET_ADDRESS *dst, int32_t dnet, int status)
{ {
int iArgs[2]; int32_t iArgs[2];
iArgs[0] = dnet; iArgs[0] = dnet;
iArgs[1] = status; iArgs[1] = status;
+8 -7
View File
@@ -25,21 +25,22 @@ BACNET_STACK_EXPORT
int Send_Network_Layer_Message( int Send_Network_Layer_Message(
BACNET_NETWORK_MESSAGE_TYPE network_message_type, BACNET_NETWORK_MESSAGE_TYPE network_message_type,
BACNET_ADDRESS *dst, BACNET_ADDRESS *dst,
const int *iArgs); const int32_t *iArgs);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Send_Who_Is_Router_To_Network(BACNET_ADDRESS *dst, int dnet); void Send_Who_Is_Router_To_Network(BACNET_ADDRESS *dst, int32_t dnet);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Send_I_Am_Router_To_Network(const int DNET_list[]); void Send_I_Am_Router_To_Network(const int32_t DNET_list[]);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Send_Reject_Message_To_Network( void Send_Reject_Message_To_Network(
BACNET_ADDRESS *dst, uint8_t reject_reason, int dnet); BACNET_ADDRESS *dst, uint8_t reject_reason, int32_t dnet);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Send_Initialize_Routing_Table(BACNET_ADDRESS *dst, const int DNET_list[]); void Send_Initialize_Routing_Table(
BACNET_ADDRESS *dst, const int32_t DNET_list[]);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Send_Initialize_Routing_Table_Ack( void Send_Initialize_Routing_Table_Ack(
BACNET_ADDRESS *dst, const int DNET_list[]); BACNET_ADDRESS *dst, const int32_t DNET_list[]);
BACNET_STACK_EXPORT BACNET_STACK_EXPORT
void Send_Network_Number_Is(BACNET_ADDRESS *dst, int dnet, int status); void Send_Network_Number_Is(BACNET_ADDRESS *dst, int32_t dnet, int status);
#ifdef __cplusplus #ifdef __cplusplus
} }
+1 -1
View File
@@ -113,7 +113,7 @@ void handler_who_has_for_routing(
BACNET_WHO_HAS_DATA data; BACNET_WHO_HAS_DATA data;
int32_t dev_instance; int32_t dev_instance;
int cursor = 0; /* Starting hint */ int cursor = 0; /* Starting hint */
int my_list[2] = { 0, -1 }; /* Not really used, so dummy values */ int32_t my_list[2] = { 0, -1 }; /* Not really used, so dummy values */
BACNET_ADDRESS bcast_net; BACNET_ADDRESS bcast_net;
(void)src; (void)src;
+1 -1
View File
@@ -160,7 +160,7 @@ static void check_who_is_for_routing(
int32_t high_limit = 0; int32_t high_limit = 0;
int32_t dev_instance; int32_t dev_instance;
int cursor = 0; /* Starting hint */ int cursor = 0; /* Starting hint */
int my_list[2] = { 0, -1 }; /* Not really used, so dummy values */ int32_t my_list[2] = { 0, -1 }; /* Not really used, so dummy values */
BACNET_ADDRESS bcast_net; BACNET_ADDRESS bcast_net;
len = whois_decode_service_request( len = whois_decode_service_request(