From cfe257fe6977dc6497b610217c95a4203ecf3586 Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Tue, 21 Jan 2025 13:31:43 -0600 Subject: [PATCH] Fixed spelling errors detected by code-spell utility. (#895) * Fixed spelling errors detected by code-spell utility. * Fixed cppcheck preprocessorErrorDirective. Suppressed new cppcheck warnings until fixed. --- Makefile | 6 ++++- src/bacnet/bacapp.c | 6 ++--- src/bacnet/bacdest.c | 2 +- src/bacnet/basic/binding/address.c | 4 ++-- src/bacnet/basic/client/bac-discover.c | 4 ++-- src/bacnet/basic/object/trendlog.c | 2 +- src/bacnet/credential_authentication_factor.c | 24 ++++++++++--------- src/bacnet/credential_authentication_factor.h | 8 +++---- src/bacnet/datalink/bsc/bsc-node.c | 3 ++- src/bacnet/property.c | 2 -- src/bacnet/wp.h | 2 +- src/bacnet/wpm.h | 4 ++-- 12 files changed, 36 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 9e384923..4a226919 100644 --- a/Makefile +++ b/Makefile @@ -410,12 +410,16 @@ CPPCHECK_OPTIONS += --suppress=duplicateCondition CPPCHECK_OPTIONS += --suppress=funcArgNamesDifferent CPPCHECK_OPTIONS += --suppress=unusedStructMember CPPCHECK_OPTIONS += --suppress=uselessAssignmentPtrArg -CPPCHECK_OPTIONS += --addon=cert.py CPPCHECK_OPTIONS += --suppress=cert-MSC30-c CPPCHECK_OPTIONS += --suppress=cert-STR05-C CPPCHECK_OPTIONS += --suppress=cert-API01-C CPPCHECK_OPTIONS += --suppress=cert-MSC24-C CPPCHECK_OPTIONS += --suppress=cert-INT31-c +# new in cppcheck 2.13 +CPPCHECK_OPTIONS += --suppress=constParameterCallback +CPPCHECK_OPTIONS += --suppress=constParameterPointer +CPPCHECK_OPTIONS += --suppress=constVariablePointer +# suppress the deprecated warning for the BACnet stack CPPCHECK_OPTIONS += -DBACNET_STACK_DEPRECATED #CPPCHECK_OPTIONS += -I./src #CPPCHECK_OPTIONS += --enable=information --check-config diff --git a/src/bacnet/bacapp.c b/src/bacnet/bacapp.c index d022ca50..c2cb8d0b 100644 --- a/src/bacnet/bacapp.c +++ b/src/bacnet/bacapp.c @@ -3367,19 +3367,19 @@ int bacapp_snprintf_value( char *str, size_t str_len, const BACNET_OBJECT_PROPERTY_VALUE *object_value) { size_t len = 0, i = 0; -#if defined(BACAPP_CHARACTER_STRING) - const char *char_str; -#endif const BACNET_APPLICATION_DATA_VALUE *value; BACNET_PROPERTY_ID property = PROP_ALL; BACNET_OBJECT_TYPE object_type = MAX_BACNET_OBJECT_TYPE; int ret_val = 0; int slen = 0; +#if defined(BACAPP_CHARACTER_STRING) + const char *char_str; #if (__STDC_VERSION__ >= 199901L) && defined(__STDC_ISO_10646__) /* Wide character (decoded from multi-byte character). */ wchar_t wc; /* Wide character length in bytes. */ int wclen; +#endif #endif if (object_value && object_value->value) { diff --git a/src/bacnet/bacdest.c b/src/bacnet/bacdest.c index d76bb7c1..18a9022c 100644 --- a/src/bacnet/bacdest.c +++ b/src/bacnet/bacdest.c @@ -755,7 +755,7 @@ int bacnet_destination_to_ascii( /** * Parse BACnet_Destination from ASCII string (as entered by user) * - * @param bacdest - Destination struct to pupulate with data from the ASCII + * @param bacdest - Destination struct to populate with data from the ASCII * string * @param buf - ASCII string, zero terminated * @return true on success diff --git a/src/bacnet/basic/binding/address.c b/src/bacnet/basic/binding/address.c index 3bc4cd66..25669f03 100644 --- a/src/bacnet/basic/binding/address.c +++ b/src/bacnet/basic/binding/address.c @@ -76,7 +76,7 @@ static struct Address_Cache_Entry { */ void address_protected_entry_index_set(uint32_t top_protected_entry_index) { - if (top_protected_entry_index <= (MAX_ADDRESS_CACHE - 1)) { + if (top_protected_entry_index < MAX_ADDRESS_CACHE) { Top_Protected_Entry = top_protected_entry_index; } } @@ -976,7 +976,7 @@ int rr_address_list_encode(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest) /** * Scan the cache and eliminate any expired entries. Should be called * periodically to ensure the cache is managed correctly. If this function - * is never called at all the whole cache is effectivly rendered static and + * is never called at all the whole cache is effectively rendered static and * entries never expire unless explicitly deleted. * * @param uSeconds Approximate number of seconds since last call to this diff --git a/src/bacnet/basic/client/bac-discover.c b/src/bacnet/basic/client/bac-discover.c index 7f770c49..54dd3089 100644 --- a/src/bacnet/basic/client/bac-discover.c +++ b/src/bacnet/basic/client/bac-discover.c @@ -1138,7 +1138,7 @@ uint16_t bacnet_discover_vendor_id(void) */ void bacnet_discover_seconds_set(unsigned int seconds) { - Discovery_Milliseconds = seconds * 1000; + Discovery_Milliseconds = (unsigned long)seconds * 1000UL; } /** @@ -1147,7 +1147,7 @@ void bacnet_discover_seconds_set(unsigned int seconds) */ unsigned int bacnet_discover_seconds(void) { - return Discovery_Milliseconds = 1000; + return Discovery_Milliseconds = 1000UL; } /** diff --git a/src/bacnet/basic/object/trendlog.c b/src/bacnet/basic/object/trendlog.c index 24437a55..9383a719 100644 --- a/src/bacnet/basic/object/trendlog.c +++ b/src/bacnet/basic/object/trendlog.c @@ -1113,7 +1113,7 @@ int TL_encode_by_sequence(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest) 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 uiSequence = 0; /* Tracking sequence number when encoding */ uint32_t uiRemaining = 0; /* Amount of unused space in packet */ uint32_t uiFirstSeq = 0; /* Sequence number for 1st record in log */ diff --git a/src/bacnet/credential_authentication_factor.c b/src/bacnet/credential_authentication_factor.c index 4ac13e66..ab8e6993 100644 --- a/src/bacnet/credential_authentication_factor.c +++ b/src/bacnet/credential_authentication_factor.c @@ -11,12 +11,12 @@ #include "bacnet/bacdcode.h" int bacapp_encode_credential_authentication_factor( - uint8_t *apdu, const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf) + uint8_t *apdu, const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor) { int len; int apdu_len = 0; - len = encode_context_enumerated(&apdu[apdu_len], 0, caf->disable); + len = encode_context_enumerated(&apdu[apdu_len], 0, factor->disable); if (len < 0) { return -1; } else { @@ -24,7 +24,7 @@ int bacapp_encode_credential_authentication_factor( } len = bacapp_encode_context_authentication_factor( - &apdu[apdu_len], 1, &caf->authentication_factor); + &apdu[apdu_len], 1, &factor->authentication_factor); if (len < 0) { return -1; } else { @@ -37,7 +37,7 @@ int bacapp_encode_credential_authentication_factor( int bacapp_encode_context_credential_authentication_factor( uint8_t *apdu, uint8_t tag, - const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf) + const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor) { int len; int apdu_len = 0; @@ -45,7 +45,8 @@ int bacapp_encode_context_credential_authentication_factor( len = encode_opening_tag(&apdu[apdu_len], tag); apdu_len += len; - len = bacapp_encode_credential_authentication_factor(&apdu[apdu_len], caf); + len = + bacapp_encode_credential_authentication_factor(&apdu[apdu_len], factor); apdu_len += len; len = encode_closing_tag(&apdu[apdu_len], tag); @@ -55,11 +56,11 @@ int bacapp_encode_context_credential_authentication_factor( } int bacapp_decode_credential_authentication_factor( - const uint8_t *apdu, BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf) + const uint8_t *apdu, BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor) { int len; int apdu_len = 0; - uint32_t disable = caf->disable; + uint32_t disable = factor->disable; if (decode_is_context_tag(&apdu[apdu_len], 0)) { len = decode_context_enumerated(&apdu[apdu_len], 0, &disable); @@ -67,7 +68,8 @@ int bacapp_decode_credential_authentication_factor( return -1; } else if (disable < ACCESS_AUTHENTICATION_FACTOR_DISABLE_MAX) { apdu_len += len; - caf->disable = (BACNET_ACCESS_AUTHENTICATION_FACTOR_DISABLE)disable; + factor->disable = + (BACNET_ACCESS_AUTHENTICATION_FACTOR_DISABLE)disable; } else { return -1; } @@ -77,7 +79,7 @@ int bacapp_decode_credential_authentication_factor( if (decode_is_context_tag(&apdu[apdu_len], 1)) { len = bacapp_decode_context_authentication_factor( - &apdu[apdu_len], 1, &caf->authentication_factor); + &apdu[apdu_len], 1, &factor->authentication_factor); if (len < 0) { return -1; } else { @@ -93,7 +95,7 @@ int bacapp_decode_credential_authentication_factor( int bacapp_decode_context_credential_authentication_factor( const uint8_t *apdu, uint8_t tag, - BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf) + BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor) { int len = 0; int section_length; @@ -101,7 +103,7 @@ int bacapp_decode_context_credential_authentication_factor( if (decode_is_opening_tag_number(&apdu[len], tag)) { len++; section_length = - bacapp_decode_credential_authentication_factor(&apdu[len], caf); + bacapp_decode_credential_authentication_factor(&apdu[len], factor); if (section_length == -1) { len = -1; diff --git a/src/bacnet/credential_authentication_factor.h b/src/bacnet/credential_authentication_factor.h index 53fe04c8..97fed36f 100644 --- a/src/bacnet/credential_authentication_factor.h +++ b/src/bacnet/credential_authentication_factor.h @@ -28,20 +28,20 @@ extern "C" { BACNET_STACK_EXPORT int bacapp_encode_credential_authentication_factor( - uint8_t *apdu, const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf); + uint8_t *apdu, const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor); BACNET_STACK_EXPORT int bacapp_encode_context_credential_authentication_factor( uint8_t *apdu, uint8_t tag, - const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf); + const BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor); BACNET_STACK_EXPORT int bacapp_decode_credential_authentication_factor( - const uint8_t *apdu, BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf); + const uint8_t *apdu, BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor); BACNET_STACK_EXPORT int bacapp_decode_context_credential_authentication_factor( const uint8_t *apdu, uint8_t tag, - BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *caf); + BACNET_CREDENTIAL_AUTHENTICATION_FACTOR *factor); #ifdef __cplusplus } diff --git a/src/bacnet/datalink/bsc/bsc-node.c b/src/bacnet/datalink/bsc/bsc-node.c index b7904b3c..22fcac51 100644 --- a/src/bacnet/datalink/bsc/bsc-node.c +++ b/src/bacnet/datalink/bsc/bsc-node.c @@ -6,6 +6,7 @@ * @copyright SPDX-License-Identifier: MIT */ #include "bacnet/basic/sys/debug.h" +#include "bacnet/datalink/bsc/bsc-conf.h" #include "bacnet/datalink/bsc/bsc-node.h" #include "bacnet/datalink/bsc/bsc-event.h" #include "bacnet/datalink/bsc/bsc-util.h" @@ -48,7 +49,7 @@ struct BSC_Node { BACNET_SC_HUB_FUNCTION_CONNECTION_STATUS *hub_status; }; -#if BSC_CONF_NODES_NUM < 1 +#if defined(BSC_CONF_NODES_NUM) && (BSC_CONF_NODES_NUM < 1) #error "BSC_CONF_NODES_NUM must be >= 1" #endif diff --git a/src/bacnet/property.c b/src/bacnet/property.c index 5478a5ad..d5d1976d 100644 --- a/src/bacnet/property.c +++ b/src/bacnet/property.c @@ -3274,8 +3274,6 @@ bool property_list_writable_member( (object_property == PROP_PACKET_REORDER_TIME) || (object_property == PROP_LAST_KEY_SERVER) || (object_property == PROP_SECURITY_PDU_TIMEOUT) || - (object_property == PROP_LAST_KEY_SERVER) || - (object_property == PROP_SECURITY_PDU_TIMEOUT) || (object_property == PROP_DO_NOT_HIDE)) { writable = true; } diff --git a/src/bacnet/wp.h b/src/bacnet/wp.h index c287dc5c..1dfbc80d 100644 --- a/src/bacnet/wp.h +++ b/src/bacnet/wp.h @@ -111,7 +111,7 @@ bool write_property_unsigned_decode( * The WriteProperty service is used by a client BACnet-user to modify the * value of a single specified property of a BACnet object. This service * potentially allows write access to any property of any object, whether a - * BACnet-defined object or not. Some implementors may wish to restrict write + * BACnet-defined object or not. Some implementers may wish to restrict write * access to certain properties of certain objects. In such cases, an attempt * to modify a restricted property shall result in the return of an error of * 'Error Class' PROPERTY and 'Error Code' WRITE_ACCESS_DENIED. diff --git a/src/bacnet/wpm.h b/src/bacnet/wpm.h index 8dbe9848..7afb52db 100644 --- a/src/bacnet/wpm.h +++ b/src/bacnet/wpm.h @@ -101,11 +101,11 @@ void wpm_write_access_data_link_array( * parameter, and execution of the service shall continue until all of the * specified properties have been written to or a property is encountered that * for some reason cannot be modified as requested. - * Some implementors may wish to restrict write access to certain properties + * Some implementers may wish to restrict write access to certain properties * of certain objects. In such cases, an attempt to modify a restricted property * shall result in the return of an error of 'Error Class' PROPERTY and 'Error * Code' WRITE_ACCESS_DENIED. Note that these restricted properties may be * accessible through the use of Virtual Terminal services or other means at the - * discretion of the implementor. + * discretion of the implementer. */ #endif