Hi to all,
I ported SDK and several test programs to GCC and during this task the compiler found some issues in the source code.
So, I'm reporting some of these corrections, not related to the type of the compiler, that in my opinion they could be considered as bugs:
1) ===============
I have not found metrics.h in the source tree. By looking the source code, I have reconstructed it in the best way I could but, unless I just missed it somewhere, it would be better to include it in the next release..
2) ===============
There is an error in declaration of LCD_DevData[] into lcd.c.
The struct ADI_LCD_DEV_DATA_TYPE has a bBlockingMode but it is missing in the later declaration:
@@ -72,7 +72,6 @@ ADI_LCD_STATE_UNINITIALIZED, /* Init state */ pADI_LCD, /* Pointer to the LCD MMR registers */ LCD_IRQn, /* LCD Interrupt Number */ + 0, NULL, /* Pointer to callback function */ NULL, /* Callback parameter */ }
3) ===============
Into i2c.c:
@@ -1204,7 +1204,7 @@ hDevice->TxRemaining = 0; hDevice->pRxBuffer = NULL; hDevice->RxRemaining = 0; + hDevice->dataAddress = 0; - hDevice->dataAddress = NULL; hDevice->dataAddressWidth = ADI_I2C_NO_DATA_ADDRESSING_PHASE; #if (ADI_I2C_CFG_ENABLE_DMA_SUPPORT == 1)
the dataAddress field is initialized with NULL without reason and the compiler complained about the fact that a pointer is assigned to an integer of different size without a cast.
4) ===============
In captouch_lib.c:
@@ -28,7 +28,7 @@ #include <stddef.h> /* for NULL */ #include <string.h> /* for memcpy */ #include <stdlib.h> -#include "test_common.h" // test #include "captouch.h" #include "captouch_lib.h" #include "gpio.h" /* GPIO configuration */
the inclusion of test_common.h is useless so I removed it.
5) ===============
It is better to avoid C99, like C++ in-scope declarations.
With GCC I could bypass it by adding -std=C99 in the options, but in my opinion it would be better to leave clean ANSI C code.
Hopefully, this happens only in few sources.
6) ===============
GCC complained that NULL cannot be assigned to an enum type, obviously.
This happens in system.c:
@@ -170,7 +170,7 @@ #ifdef ADI_SYSTEM_CLOCK_TRANSITION +static ADI_SYS_CLOCK_STATE_TYPE currentState = ADI_SYS_CLOCK_STATE_INVALID; -static ADI_SYS_CLOCK_STATE_TYPE currentState = NULL; /*---------------------------------------------------------------------------- State parameters initialization
@@ -1751,35 +1751,35 @@ static const StateTableEntryType StateTransitionTable[] = { /* from-state input-event to-state action */ + {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, + {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_USB, aEnterUSBState, }, + {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + + {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_MINIMAL, aEnterMinimalState, }, + {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, aEnterUSBState, }, + {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + + {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_MINIMAL, aEnterMinimalState, }, + {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_USB_LPM, aEnterUSBLPMState, }, + + {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, + {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, + + {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, + {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, + {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_USB, aEnterUSBState, }, + {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_MINIMAL, aEnterMinimalState, }, + {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_INVALID, ADI_SYS_CLOCK_STATE_INVALID, }, - {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, - {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_USB, aEnterUSBState, }, - {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_USB_OFF, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_MINIMAL, ADI_SYS_CLOCK_TRIGGER_USB_LPM, NULL, NULL, }, - - {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_MINIMAL, aEnterMinimalState, }, - {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, aEnterUSBState, }, - {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_OFF, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_LPM, NULL, NULL, }, - - {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, NULL, }, - {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_USB_ON, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_MINIMAL, aEnterMinimalState, }, - {ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_USB_LPM, aEnterUSBLPMState, }, - - {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, ADI_SYS_CLOCK_STATE_USB, NULL, }, - {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_ON, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, - {ADI_SYS_CLOCK_STATE_USB_MEASUREMENT, ADI_SYS_CLOCK_TRIGGER_USB_LPM, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, - - {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_ON, ADI_SYS_CLOCK_STATE_MEASUREMENT, aEnterMeasurementState, }, - {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_MEASUREMENT_OFF, NULL, NULL, }, - {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_USB_ON, ADI_SYS_CLOCK_STATE_USB, aEnterUSBState, }, - {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_USB_OFF, ADI_SYS_CLOCK_STATE_MINIMAL, aEnterMinimalState, }, - {ADI_SYS_CLOCK_STATE_USB_LPM, ADI_SYS_CLOCK_TRIGGER_USB_LPM, NULL, NULL, }, };
Into system.h, I added ADI_SYS_CLOCK_STATE_INVALID to the enum.
@@ -253,8 +253,7 @@ * configurations are requested asynchronously. */ typedef enum { + ADI_SYS_CLOCK_STATE_INVALID = 0, + ADI_SYS_CLOCK_STATE_MINIMAL, - ADI_SYS_CLOCK_STATE_MINIMAL = 1, /* use one-based enum to avoid confusion with NULL, which is used to flag invalid state transitions */ ADI_SYS_CLOCK_STATE_MEASUREMENT, ADI_SYS_CLOCK_STATE_USB, ADI_SYS_CLOCK_STATE_USB_MEASUREMENT,
7) ===============
Into system.c, __vector_table is declared as a void object.
Probably, __relocated_vector_table needs to be fixed too, but I have not tested it.
@@ -26,7 +26,7 @@ #ifdef RELOCATE_IVT extern void __relocated_vector_table; #else +extern void *__vector_table[]; -extern void __vector_table; #endif /*----------------------------------------------------------------------------
8) ===============
Into uart.c, some fields of UART_DevData[] are NULL instead of zero and the compiler complained the pointer to integer assignment.
@@ -176,15 +176,15 @@ NULL, /*!< rx buffer start address */ 0, /*!< rx buffer write index */ 0, /*!< rx buffer read index */ + 0, /*!< rx buffer size */ - NULL, /*!< rx buffer size */ 0, /*!< available bytes */ }, { NULL, /*!< tx buffer start address */ 0, /*!< tx buffer read index */ 0, /*!< tx buffer write index */ + 0, /*!< tx buffer size */ + 0, /*!< number of free elements */ - NULL, /*!< tx buffer size */ - NULL, /*!< number of free elements */ }, #endif /* (1 == ADI_UART_CFG_INTERRUPT_MODE_SUPPORT) */ #if defined(ADI_DEBUG)
Other fixes are required for making the SDK working.
I hope this could be useful.
Sincerely,
Carlo Bramini.