Bugfix/code clean using gcc warnings (#371)

* Enable extra GCC warnings to discover subtle bugs

* convert c++ comments to c comments

* cleanup pedantic compiler warnings

* Compile apps with GNU89 GNU99 GNU11 and GNU17

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-12-25 21:43:51 -06:00
committed by GitHub
parent 0728bc4390
commit b91735af13
66 changed files with 990 additions and 847 deletions
+2 -6
View File
@@ -39,14 +39,10 @@
#include "bacnet/basic/services.h"
#include "bacnet/proplist.h"
#include "bacnet/timestamp.h"
#include "bacnet/basic/sys/debug.h"
#include "bacnet/basic/object/ai.h"
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define PRINTF debug_perror
#ifndef MAX_ANALOG_INPUTS
#define MAX_ANALOG_INPUTS 4
+4
View File
@@ -236,12 +236,14 @@ bool Analog_Value_Present_Value_Set(
unsigned index = 0;
bool status = false;
(void)priority;
index = Analog_Value_Instance_To_Index(object_instance);
if (index < MAX_ANALOG_VALUES) {
Analog_Value_COV_Detect(index, value);
AV_Descr[index].Present_Value = value;
status = true;
}
return status;
}
@@ -1136,6 +1138,8 @@ void Analog_Value_Intrinsic_Reporting(uint32_t object_instance)
CurrentAV->Event_Time_Stamps[TRANSITION_TO_NORMAL] =
event_data.timeStamp.value.dateTime;
break;
default:
break;
}
}
+3 -2
View File
@@ -657,6 +657,7 @@ int Channel_Value_Encode(
{
int apdu_len = BACNET_STATUS_ERROR;
(void)apdu_max;
if (!apdu || !value) {
return BACNET_STATUS_ERROR;
}
@@ -907,7 +908,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
#if defined(BACAPP_REAL)
case BACNET_APPLICATION_TAG_REAL:
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
if (value->type.Real != 0.0F) {
if (islessgreater(value->type.Real, 0.0F)) {
boolean_value = true;
}
apdu_len =
@@ -954,7 +955,7 @@ int Channel_Coerce_Data_Encode(uint8_t *apdu,
#if defined(BACAPP_DOUBLE)
case BACNET_APPLICATION_TAG_DOUBLE:
if (tag == BACNET_APPLICATION_TAG_BOOLEAN) {
if (value->type.Double != 0.0) {
if (islessgreater(value->type.Double, 0.0)) {
boolean_value = true;
}
apdu_len =
+1
View File
@@ -820,4 +820,5 @@ bool Command_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
void Command_Intrinsic_Reporting(uint32_t object_instance)
{
(void)object_instance;
}
+5 -12
View File
@@ -39,16 +39,9 @@
#include "bacnet/basic/object/ao.h"
#include "bacnet/wp.h"
#include "bacnet/basic/services.h"
#include "bacnet/basic/sys/debug.h"
#ifndef LOAD_CONTROL_DEBUG
#define LOAD_CONTROL_DEBUG 0
#endif
#if LOAD_CONTROL_DEBUG
#include <sys/PRINTF.h>
#define PRINTF(...) printk(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define PRINTF debug_printf
/* number of demo objects */
#ifndef MAX_LOAD_CONTROLS
@@ -67,7 +60,7 @@ typedef enum BACnetShedLevelType {
#define DEFAULT_VALUE_PERCENT 100
#define DEFAULT_VALUE_LEVEL 0
#define DEFAULT_VALUE_AMOUNT 0
#define DEFAULT_VALUE_AMOUNT 0.0
/* The shed levels for the LEVEL choice of BACnetShedLevel
that have meaning for this particular Load Control object. */
@@ -423,7 +416,7 @@ void Load_Control_State_Machine(int object_index)
}
break;
case BACNET_SHED_TYPE_AMOUNT:
if (Requested_Shed_Level[object_index].value.amount ==
if (Requested_Shed_Level[object_index].value.amount <=
DEFAULT_VALUE_AMOUNT) {
Load_Control_State[object_index] = SHED_INACTIVE;
}
@@ -431,7 +424,7 @@ void Load_Control_State_Machine(int object_index)
case BACNET_SHED_TYPE_LEVEL:
default:
if (Requested_Shed_Level[object_index].value.level ==
DEFAULT_VALUE_LEVEL) {
DEFAULT_VALUE_LEVEL) {
Load_Control_State[object_index] = SHED_INACTIVE;
}
break;
+12 -2
View File
@@ -1228,7 +1228,12 @@ static void Lighting_Output_Ramp_Handler(struct lighting_output_object *pLight,
BACNET_LIGHTING_COMMAND *pCommand,
uint16_t milliseconds)
{
if (pLight && pCommand) { }
if (pLight && pCommand) {
/* FIXME: add ramp functionality */
(void)pLight;
(void)pCommand;
(void)milliseconds;
}
}
/**
@@ -1243,7 +1248,12 @@ static void Lighting_Output_Fade_Handler(struct lighting_output_object *pLight,
BACNET_LIGHTING_COMMAND *pCommand,
uint16_t milliseconds)
{
if (pLight && pCommand) { }
if (pLight && pCommand) {
/* FIXME: add fade functionality */
(void)pLight;
(void)pCommand;
(void)milliseconds;
}
}
/**
+1
View File
@@ -140,6 +140,7 @@ bool Multistate_Input_Valid_Instance(uint32_t object_instance)
static uint32_t Multistate_Input_Max_States(uint32_t instance)
{
(void)instance;
return MULTISTATE_NUMBER_OF_STATES;
}
+3 -7
View File
@@ -43,17 +43,13 @@
#include "bacnet/basic/object/device.h"
#include "bacnet/event.h"
#include "bacnet/basic/services.h"
#include "bacnet/basic/sys/debug.h"
#include "bacnet/basic/tsm/tsm.h"
#include "bacnet/wp.h"
#include "bacnet/basic/object/nc.h"
#include "bacnet/datalink/datalink.h"
#if PRINT_ENABLED
#include <stdio.h>
#define PRINTF(...) fprintf(stderr, __VA_ARGS__)
#else
#define PRINTF(...)
#endif
#define PRINTF debug_perror
#ifndef MAX_NOTIFICATION_CLASSES
#define MAX_NOTIFICATION_CLASSES 2
@@ -747,8 +743,8 @@ bool Notification_Class_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
* &src); */
}
}
status = true;
break;
case PROP_OBJECT_NAME:
wp_data->error_class = ERROR_CLASS_PROPERTY;
+4
View File
@@ -2561,6 +2561,8 @@ bool Network_Port_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
*/
int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
{
(void)apdu;
(void)pRequest;
return 0;
}
@@ -2574,6 +2576,8 @@ int Network_Port_Read_Range_BDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
*/
int Network_Port_Read_Range_FDT(uint8_t *apdu, BACNET_READ_RANGE_DATA *pRequest)
{
(void)apdu;
(void)pRequest;
return 0;
}
+2
View File
@@ -140,6 +140,7 @@ bool OctetString_Value_Present_Value_Set(
unsigned index = 0;
bool status = false;
(void)priority;
index = OctetString_Value_Instance_To_Index(object_instance);
if (index < MAX_OCTETSTRING_VALUES) {
octetstring_copy(&OSV_Descr[index].Present_Value, value);
@@ -354,4 +355,5 @@ bool OctetString_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
void OctetString_Value_Intrinsic_Reporting(uint32_t object_instance)
{
(void)object_instance;
}
+3
View File
@@ -140,11 +140,13 @@ bool PositiveInteger_Value_Present_Value_Set(
unsigned index = 0;
bool status = false;
(void)priority;
index = PositiveInteger_Value_Instance_To_Index(object_instance);
if (index < MAX_POSITIVEINTEGER_VALUES) {
PIV_Descr[index].Present_Value = value;
status = true;
}
return status;
}
@@ -359,4 +361,5 @@ bool PositiveInteger_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
void PositiveInteger_Value_Intrinsic_Reporting(uint32_t object_instance)
{
(void)object_instance;
}
+3
View File
@@ -1498,6 +1498,9 @@ int TL_encode_entry(uint8_t *apdu, int iLog, int iEntry)
case TL_TYPE_ANY:
/* Should never happen as we don't support this at the moment */
break;
default:
break;
}
iLen += encode_closing_tag(&apdu[iLen], 1);