On Thu, Jun 22, 2023 at 10:47:54PM -0700, Jacob Keller wrote:
> When building the tlv.c file, the following warning may occur when
> operating in C89 mode:
> 
>   $make EXTRA_CFLAGS=-std=gnu89
>   tlv.c: In function ‘mgt_post_recv’:
>   tlv.c:374:17: error: ‘for’ loop initial declarations are only allowed in 
> C99 or C11 mode
>     374 |                 for (int i = 0; i < umtn->actual_table_size; i++) {
>         |                 ^~~
>   tlv.c:374:17: note: use option ‘-std=c99’, ‘-std=gnu99’, ‘-std=c11’ or 
> ‘-std=gnu11’ to compile your code
>   tlv.c: In function ‘mgt_pre_send’:
>   tlv.c:551:17: error: ‘for’ loop initial declarations are only allowed in 
> C99 or C11 mode
>     551 |                 for (int i = 0; i < umtn->actual_table_size; i++) {
>         |                 ^~~
>   make: *** [<builtin>: tlv.o] Error 1
>   make: *** Waiting for unfinished jobs....
>   pmc.c: In function ‘pmc_show’:
>   pmc.c:559:17: error: ‘for’ loop initial declarations are only allowed in 
> C99 or C11 mode
>     559 |                 for (int i = 0; i < umtn->actual_table_size; i++) {
>         |                 ^~~
> 
> This occurs because initial loop declarations are only supported in C99 or
> newer. LinuxPTP source still prefers to keep with the GNU C89 convention of
> variables being at the top of the function. Newer versions of GCC have
> begun defaulting to a newer C standard, which explains how these slipped
> in. Note that directly enforcing "-std=c89" does not work because we rely
> on some GNU extensions of C89.
> 
> For the tlv.c file it turns out that the case statements which declare the
> variables in loops already have suitable iterator variables bound at the
> top of the function. For the iterator in pmc_show, we need to add the
> declaration at the top of the function.
> 
> Reported-by: Jakub Raczyński <j.raczyn...@elpromaelectronics.com>
> Signed-off-by: Jacob Keller <jacob.e.kel...@intel.com>

Applied.

Thanks,
Richard


_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to