diff --git a/bacnet-stack/demo/object/bacfile.c b/bacnet-stack/demo/object/bacfile.c index a0e9d229..23cfab84 100644 --- a/bacnet-stack/demo/object/bacfile.c +++ b/bacnet-stack/demo/object/bacfile.c @@ -41,6 +41,7 @@ #include "awf.h" #include "rp.h" #include "wp.h" +#include "handlers.h" typedef struct { uint32_t instance; diff --git a/bacnet-stack/demo/object/trendlog.c b/bacnet-stack/demo/object/trendlog.c index 481691bd..6a9a706f 100644 --- a/bacnet-stack/demo/object/trendlog.c +++ b/bacnet-stack/demo/object/trendlog.c @@ -447,14 +447,14 @@ int Trend_Log_Read_Property( case PROP_LOG_DEVICE_OBJECT_PROPERTY: /* * BACnetDeviceObjectPropertyReference ::= SEQUENCE { - * objectIdentifier [0] BACnetObjectIdentifier, + * objectIdentifier [0] BACnetObjectIdentifier, * propertyIdentifier [1] BACnetPropertyIdentifier, * propertyArrayIndex [2] Unsigned OPTIONAL, -- used only with array datatype * -- if omitted with an array then * -- the entire array is referenced * deviceIdentifier [3] BACnetObjectIdentifier OPTIONAL - * } - */ + * } + */ apdu_len += bacapp_encode_device_obj_property_ref(&apdu[0], &CurrentLog->Source); break; @@ -1111,11 +1111,8 @@ int rr_trend_log_encode( return(TL_encode_by_position(apdu, pRequest, error_class, error_code)); else if(pRequest->RequestType == RR_BY_SEQUENCE) return(TL_encode_by_sequence(apdu, pRequest, error_class, error_code)); - else { - return(TL_encode_by_time(apdu, pRequest, error_class, error_code)); - } - - return(-1); + + return(TL_encode_by_time(apdu, pRequest, error_class, error_code)); } /**************************************************************************** @@ -1130,23 +1127,22 @@ int TL_encode_by_position( BACNET_ERROR_CLASS *error_class, BACNET_ERROR_CODE *error_code) { - int iLen; - int32_t iTemp; - TL_LOG_INFO *CurrentLog; + int iLen = 0; + int32_t iTemp = 0; + TL_LOG_INFO *CurrentLog = NULL; - uint32_t uiIndex; /* Current entry number */ - uint32_t uiFirst; /* Entry number we started encoding from */ - uint32_t uiLast; /* Entry number we finished encoding on */ - uint32_t uiTarget; /* Last entry we are required to encode */ - uint32_t uiRemaining; /* Amount of unused space in packet */ + uint32_t uiIndex = 0; /* Current entry number */ + uint32_t uiFirst = 0; /* Entry number we started encoding from */ + uint32_t uiLast = 0; /* Entry number we finished encoding on */ + uint32_t uiTarget = 0; /* Last entry we are required to encode */ + uint32_t uiRemaining = 0; /* Amount of unused space in packet */ - uiFirst = 0; - uiLast = 0; - iLen = 0; - uiRemaining = MAX_APDU - pRequest->Overhead; /* See how much space we have */ - + /* unused parameters */ + error_class = error_class; + error_code = error_code; + /* See how much space we have */ + uiRemaining = MAX_APDU - pRequest->Overhead; CurrentLog = &LogInfo[pRequest->object_instance]; - if(pRequest->RequestType == RR_READ_ALL) { /* * Read all the list or as much as will fit in the buffer by selecting @@ -1155,7 +1151,7 @@ int TL_encode_by_position( */ pRequest->Count = CurrentLog->ulRecordCount; /* Full list */ pRequest->Range.RefIndex = 1; /* Starting at the beginning */ - } + } if(pRequest->Count < 0) { /* negative count means work from index backwards */ /* @@ -1237,29 +1233,30 @@ int TL_encode_by_sequence( BACNET_ERROR_CLASS *error_class, BACNET_ERROR_CODE *error_code) { - int iLen; - int32_t iTemp; - TL_LOG_INFO *CurrentLog; + int iLen = 0; + int32_t iTemp = 0; + TL_LOG_INFO *CurrentLog = NULL; - uint32_t uiIndex; /* Current entry number */ - uint32_t uiFirst; /* Entry number we started encoding from */ - uint32_t uiLast; /* Entry number we finished encoding on */ - uint32_t uiSequence; /* Tracking sequenc number when encoding */ - uint32_t uiRemaining; /* Amount of unused space in packet */ - uint32_t uiFirstSeq; /* Sequence number for 1st record in log */ + uint32_t uiIndex = 0; /* Current entry number */ + uint32_t uiFirst = 0; /* Entry number we started encoding from */ + uint32_t uiLast = 0; /* Entry number we finished encoding on */ + uint32_t uiSequence = 0; /* Tracking sequenc number when encoding */ + uint32_t uiRemaining = 0; /* Amount of unused space in packet */ + uint32_t uiFirstSeq = 0; /* Sequence number for 1st record in log */ - uint32_t uiBegin; /* Starting Sequence number for request */ - uint32_t uiEnd; /* Ending Sequence number for request */ + uint32_t uiBegin = 0; /* Starting Sequence number for request */ + uint32_t uiEnd = 0; /* Ending Sequence number for request */ bool bWrapReq = false; /* Has request sequence range spanned the max for uint32_t? */ bool bWrapLog = false; /* Has log sequence range spanned the max for uint32_t? */ - uiFirst = 0; - uiLast = 0; - iLen = 0; - uiRemaining = MAX_APDU - pRequest->Overhead; /* See how much space we have */ + /* unused parameters */ + error_class = error_class; + error_code = error_code; + /* See how much space we have */ + uiRemaining = MAX_APDU - pRequest->Overhead; CurrentLog = &LogInfo[pRequest->object_instance]; - /* Figure out the sequence number for the first record, last is ulTotalRecordCount */ - uiFirstSeq = CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1); + /* Figure out the sequence number for the first record, last is ulTotalRecordCount */ + uiFirstSeq = CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1); /* Calculate start and end sequence numbers from request */ if(pRequest->Count < 0) { @@ -1356,7 +1353,7 @@ int TL_encode_by_sequence( pRequest->FirstSequence = uiBegin; -return(iLen); + return(iLen); } /**************************************************************************** @@ -1372,22 +1369,23 @@ int TL_encode_by_time( BACNET_ERROR_CLASS *error_class, BACNET_ERROR_CODE *error_code) { - int iLen; - int32_t iTemp; - int iCount; - TL_LOG_INFO *CurrentLog; + int iLen = 0; + int32_t iTemp = 0; + int iCount = 0; + TL_LOG_INFO *CurrentLog = NULL; - uint32_t uiIndex; /* Current entry number */ - uint32_t uiFirst; /* Entry number we started encoding from */ - uint32_t uiLast; /* Entry number we finished encoding on */ - uint32_t uiRemaining; /* Amount of unused space in packet */ - uint32_t uiFirstSeq; /* Sequence number for 1st record in log */ - time_t tRefTime; /* The time from the request in local format */ + uint32_t uiIndex = 0; /* Current entry number */ + uint32_t uiFirst = 0; /* Entry number we started encoding from */ + uint32_t uiLast = 0; /* Entry number we finished encoding on */ + uint32_t uiRemaining = 0; /* Amount of unused space in packet */ + uint32_t uiFirstSeq = 0; /* Sequence number for 1st record in log */ + time_t tRefTime = 0; /* The time from the request in local format */ - uiFirst = 0; - uiLast = 0; - iLen = 0; - uiRemaining = MAX_APDU - pRequest->Overhead; /* See how much space we have */ + /* unused parameters */ + error_class = error_class; + error_code = error_code; + /* See how much space we have */ + uiRemaining = MAX_APDU - pRequest->Overhead; CurrentLog = &LogInfo[pRequest->object_instance]; tRefTime = TL_BAC_Time_To_Local(&pRequest->Range.RefTime); @@ -1402,8 +1400,8 @@ int TL_encode_by_time( * timestamp greater than or equal to the reference. */ iCount = CurrentLog->ulRecordCount - 1; - /* Start out with the sequence number for the last record */ - uiFirstSeq = CurrentLog->ulTotalRecordCount; + /* Start out with the sequence number for the last record */ + uiFirstSeq = CurrentLog->ulTotalRecordCount; for(;;) { if(Logs[pRequest->object_instance][(uiIndex + iCount) % TL_MAX_ENTRIES].tTimeStamp < tRefTime) break; @@ -1438,15 +1436,15 @@ int TL_encode_by_time( * timestamp greater than the reference time. */ iCount = 0; - /* Figure out the sequence number for the first record, last is ulTotalRecordCount */ - uiFirstSeq = CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1); + /* Figure out the sequence number for the first record, last is ulTotalRecordCount */ + uiFirstSeq = CurrentLog->ulTotalRecordCount - (CurrentLog->ulRecordCount - 1); for(;;) { if(Logs[pRequest->object_instance][(uiIndex + iCount) % TL_MAX_ENTRIES].tTimeStamp > tRefTime) break; uiFirstSeq++; iCount++; - if(iCount == CurrentLog->ulRecordCount) + if((uint32_t)iCount == CurrentLog->ulRecordCount) return(0); } } @@ -1488,16 +1486,16 @@ int TL_encode_by_time( pRequest->FirstSequence = uiFirstSeq; -return(iLen); + return(iLen); } int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry) { - int iLen; - TL_DATA_REC *pSource; + int iLen = 0; + TL_DATA_REC *pSource = NULL; BACNET_BIT_STRING TempBits; - int iCount; + int iCount = 0; BACNET_DATE_TIME TempTime; /* Convert from BACnet 1 based to 0 based array index and then @@ -1750,10 +1748,13 @@ void TL_fetch_property(int iLog) void trend_log_timer( uint16_t uSeconds) { - TL_LOG_INFO *CurrentLog; - int iCount; - time_t tNow; + TL_LOG_INFO *CurrentLog = NULL; + int iCount = 0; + time_t tNow = 0; + /* unused parameter */ + uSeconds = uSeconds; + /* use OS to get the current time */ tNow = time(NULL); for(iCount = 0; iCount < MAX_TREND_LOGS; iCount++) { CurrentLog = &LogInfo[iCount]; diff --git a/bacnet-stack/src/address.c b/bacnet-stack/src/address.c index 75d497db..a676e7a3 100644 --- a/bacnet-stack/src/address.c +++ b/bacnet-stack/src/address.c @@ -603,7 +603,8 @@ int address_list_encode( /* FIXME: I really shouild check the length remaining here but it is fairly pointless until we have the true length remaining in the packet to work with as at the moment it is just MAX_APDU */ - + apdu_len = apdu_len; + /* look for matching address */ pMatch = Address_Cache; while (pMatch <= &Address_Cache[MAX_ADDRESS_CACHE - 1]) { if ((pMatch->Flags & (BAC_ADDR_IN_USE | BAC_ADDR_BIND_REQ)) == @@ -665,27 +666,25 @@ int rr_address_list_encode( BACNET_ERROR_CLASS *error_class, BACNET_ERROR_CODE *error_code) { - int iLen; - int32_t iTemp; - struct Address_Cache_Entry *pMatch; + int iLen = 0; + int32_t iTemp = 0; + struct Address_Cache_Entry *pMatch = NULL; BACNET_OCTET_STRING MAC_Address; - uint32_t uiTotal; /* Number of bound entries in the cache */ - uint32_t uiIndex; /* Current entry number */ - uint32_t uiFirst; /* Entry number we started encoding from */ - uint32_t uiLast; /* Entry number we finished encoding on */ - uint32_t uiTarget; /* Last entry we are required to encode */ - uint32_t uiRemaining; /* Amount of unused space in packet */ + uint32_t uiTotal = 0; /* Number of bound entries in the cache */ + uint32_t uiIndex = 0; /* Current entry number */ + uint32_t uiFirst = 0; /* Entry number we started encoding from */ + uint32_t uiLast = 0; /* Entry number we finished encoding on */ + uint32_t uiTarget = 0; /* Last entry we are required to encode */ + uint32_t uiRemaining = 0; /* Amount of unused space in packet */ + /* unused parameters */ + error_class = error_class; + error_code = error_code; /* Initialise result flags to all false */ - - bitstring_init(&pRequest->ResultFlags); + bitstring_init(&pRequest->ResultFlags); bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_FIRST_ITEM, false); bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, false); bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_MORE_ITEMS, false); - - uiFirst = 0; - uiLast = 0; - iLen = 0; /* See how much space we have */ uiRemaining = (uint32_t)(MAX_APDU - pRequest->Overhead); @@ -801,7 +800,7 @@ int rr_address_list_encode( if(uiLast == uiTotal) bitstring_set_bit(&pRequest->ResultFlags, RESULT_FLAG_LAST_ITEM, true); -return(iLen); + return(iLen); } /**************************************************************************** diff --git a/bacnet-stack/src/alarm_ack.c b/bacnet-stack/src/alarm_ack.c index ae5fda89..a8623227 100644 --- a/bacnet-stack/src/alarm_ack.c +++ b/bacnet-stack/src/alarm_ack.c @@ -124,7 +124,10 @@ int alarm_ack_decode_service_request( int len = 0; int section_len; uint32_t enumValue; - + + /* unused parameter */ + apdu_len = apdu_len; + if (-1 == (section_len = decode_context_unsigned(&apdu[len], 0, &data->ackProcessIdentifier))) { diff --git a/bacnet-stack/src/getevent.c b/bacnet-stack/src/getevent.c index 08fa47f5..5c6c690c 100644 --- a/bacnet-stack/src/getevent.c +++ b/bacnet-stack/src/getevent.c @@ -115,6 +115,8 @@ int getevent_ack_encode_apdu_data( BACNET_GET_EVENT_INFORMATION_DATA *event_data; unsigned i = 0; /* counter */ + /* unused parameter */ + max_apdu = max_apdu; if (apdu) { event_data = get_event_data; while (event_data) { @@ -169,6 +171,8 @@ int getevent_ack_encode_apdu_end( { int apdu_len = 0; /* total length of the apdu, return value */ + /* unused parameter */ + max_apdu = max_apdu; if (apdu) { apdu_len += encode_closing_tag(&apdu[apdu_len], 0); apdu_len += encode_context_boolean(&apdu[apdu_len], 1, moreEvents);