Error in altera_avalon_i2c.h
I have a problem with the NIOS code generation code:
We have a project where we use Quartus Prime 20.3p, but it also appears 22.2.0, and while checking the code quality we ran into an issue.
The issue is around the bsp/drivers/inc/altera_avalon_i2c.h where it gives an error here:
…
alt_u32 ip_freq_in_hz;
/*!< freq of clock to ip */
ALT_AVALON_I2C_ADDR_MODE_t address_mode;
/*!< address mode 7 or 10 bit */
ALT_SEM (regs_lock); <=== here is the issue.
/*!< Semaphore used to control access registers
in multi-threaded mode */
} ALT_AVALON_I2C_DEV_t;
…
The macro ALT_SEM(x) is evaluated as 'empty' and that a “;” is left. What is invalid C code.
This macro is defined in bsp/HAL/inc/os/alt_sem.h and is indeed defined as ‘empty’.
But this file also contains a warning:
* It's important to be careful in the use of the macros: ALT_SEM,
* ALT_EXTERN_SEM, and ALT_STATIC_SEM. In these three cases the semi-colon is
* included in the macro definition; so, for example, you should use:
*
* ALT_SEM(mysem)
*
* not:
*
* ALT_SEM(mysem);
*
* The inclusion of the semi-colon has been necessary to ensure the macros can
* compile with no warnings when used in a single threaded HAL environment.
This warning is not followed in bsp/drivers/inc/altera_avalon_i2c.h. Where it does contain the semicolon.
Since this is ‘generated’ code I think it is a problem in the software.