FreeRTOS+FAT Compiler Warnings

Hello,
We’re starting a new project on PIC32, and intend on using a more up-to-date compiler version than we’ve been standardized on for the past few years. XC32 version 3.01+ is really GCC 8.3.1.

While FreeRTOS+FAT has compiled without problem on XC32 2.50 (GCC 4.8.3), there are a number of warnings kicked out by GCC 8.3.1 related to strings.

Currently using FreeRTOS+FAT 191128, but I have tried FreeRTOS+FAT 2.3.3 with the same warnings.

../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c: In function 'FF_Open':
In file included from ../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_headers.h:51,
                 from ../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:37:
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:263:3: note: in expansion of macro 'STRNCPY'
   STRNCPY( pcFileName, pcPath + xIndex + 1, ffconfigMAX_FILENAME );
   ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:263:3: note: in expansion of macro 'STRNCPY'
   STRNCPY( pcFileName, pcPath + xIndex + 1, ffconfigMAX_FILENAME );
   ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_stdio.c: In function 'prvABSPath':
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_stdio.c:1992:95: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
     snprintf( pxWorkingDirectory->pcFileName, sizeof( pxWorkingDirectory->pcFileName ), "%s/%s", pxWorkingDirectory->pcCWD, pcPath );
                                                                                               ^
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_stdio.c:1992:5: note: 'snprintf' output 2 or more bytes (assuming 251) into a destination of size 250
     snprintf( pxWorkingDirectory->pcFileName, sizeof( pxWorkingDirectory->pcFileName ), "%s/%s", pxWorkingDirectory->pcCWD, pcPath );
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c: In function 'FF_SetTime':
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:2633:3: note: in expansion of macro 'STRNCPY'
   STRNCPY( pcFileName, ( pcPath + xIndex + 1 ), ffconfigMAX_FILENAME );
   ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:2633:3: note: in expansion of macro 'STRNCPY'
   STRNCPY( pcFileName, ( pcPath + xIndex + 1 ), ffconfigMAX_FILENAME );
   ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c: In function 'FF_SetPerm':
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:2723:2: note: in expansion of macro 'STRNCPY'
  STRNCPY( pcFileName, ( pcPath + xIndex + 1 ), ffconfigMAX_FILENAME );
  ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:2723:2: note: in expansion of macro 'STRNCPY'
  STRNCPY( pcFileName, ( pcPath + xIndex + 1 ), ffconfigMAX_FILENAME );
  ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c: In function 'FF_Move':
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:890:6: note: in expansion of macro 'STRNCPY'
      STRNCPY( xMyFile.pcFileName, ( szDestinationFile + xIndex + 1 ), ffconfigMAX_FILENAME );
      ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/include/ff_string.h:103:41: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
  #define STRNCPY( target, src, maxlen ) strncpy( ( target ), ( src ), ( maxlen ) );
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_file.c:890:6: note: in expansion of macro 'STRNCPY'
      STRNCPY( xMyFile.pcFileName, ( szDestinationFile + xIndex + 1 ), ffconfigMAX_FILENAME );
      ^~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_dir.c: In function 'FF_CreateFile':
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_dir.c:2870:3: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
   strncpy( xMyFile.pcFileName, pcFileName, ffconfigMAX_FILENAME );
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_dir.c: In function 'FF_MkDir':
../FreeRTOS-Labs/Source/FreeRTOS-Plus-FAT/ff_dir.c:3044:4: warning: 'strncpy' specified bound 250 equals destination size [-Wstringop-truncation]
    strncpy( xMyDirectory.pcFileName, pcDirName, ffconfigMAX_FILENAME );

Looking these over, some of them appear to be legitimate errors. Curious to hear thoughts on these warnings.

Thanks!

Hi, thanks for the report. I’m looking into these issues.

Hello Archit,

Thank you for looking into them. As I’m progressing, I’m finding that FreeRTOS+TCP also has some similar warnings. The kernel seems to build (and function) without issue, as well as +CLI.

Should I post the +TCP warnings here, or start another thread?

Archit,

For the moment, I’m going to add them here - but I’ll start a new thread if you feel it better.

Looks like a lot of the warnings are actually coming from Hein’s version of the FTP Server, so I’m guessing this might not be a big deal to the FreeRTOS Kernel/Library.

../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c: In function 'xMakeAbsolute':
../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c:2806:58: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    snprintf( pcNewDirBuffer, sizeof( pcNEW_DIR ), "%s%s%s",
                                                          ^
../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c:2806:4: note: 'snprintf' output 1 or more bytes (assuming 251) into a destination of size 250
    snprintf( pcNewDirBuffer, sizeof( pcNEW_DIR ), "%s%s%s",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        pxClient->pcCurrentDir,
        ~~~~~~~~~~~~~~~~~~~~~~~
        pxClient->pcCurrentDir[ xCurLength - 1 ] == '/' ? "" : "/",
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        pcFileName );
        ~~~~~~~~~~~~
../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c: In function 'xFTPClientWork':
In file included from ../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c:45:
../HEIN_FreeRTOS_Demo_Protocols/include/FreeRTOS_FTP_commands.h:56:25: warning: '%s' directive output may be truncated writing up to 2047 bytes into a region of size 2043 [-Wformat-truncation=]
 #define REPL_257_PWD    "257 \"%s\"\r\n"
                         ^~~~~~~~~~~~~~~~
../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c:542:62: note: in expansion of macro 'REPL_257_PWD'
      snprintf( pcCOMMAND_BUFFER, sizeof( pcCOMMAND_BUFFER ), REPL_257_PWD, pcFILE_BUFFER );
                                                              ^~~~~~~~~~~~
../HEIN_FreeRTOS_Demo_Protocols/FTP/FreeRTOS_FTP_server.c:542:6: note: 'snprintf' output between 9 and 2056 bytes into a destination of size 2048
      snprintf( pcCOMMAND_BUFFER, sizeof( pcCOMMAND_BUFFER ), REPL_257_PWD, pcFILE_BUFFER );
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NetworkInterface.c: In function 'vNetworkInterfaceAllocateRAMToBuffers':
NetworkInterface.c:517:12: warning: passing argument 1 of 'memset' discards 'volatile' qualifier from pointer target type [-Wdiscarded-array-qualifiers]
     memset(s_tNetworkBuffers, 0xBB, sizeof(s_tNetworkBuffers));
            ^~~~~~~~~~~~~~~~~
In file included from ../FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_Sockets.h:34,
                 from ../FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/include/FreeRTOS_IP_Private.h:36,
                 from NetworkInterface.c:31:
c:\program files\microchip\xc32\v4.00\pic32mx\include\musl\string.h:27:7: note: expected 'void *' but argument is of type 'volatile uint8_t (*)[1532]' {aka 'volatile unsigned char (*)[1532]'}
 void *memset (void *, int, size_t);
       ^~~~~~
NetworkInterface.c: In function 'ExecuteSelfTests':
NetworkInterface.c:715:27: warning: implicit declaration of function 'min' [-Wimplicit-function-declaration]
     uint16_t iterations = min(ipconfigPIC32_TX_DMA_DESCRIPTORS, ipconfigPIC32_RX_DMA_DESCRIPTORS);

Hi, sorry for the delay. A fix for the strncpy bugs has been merged into FreeRTOS+FAT.
As for the snprintf warnings, they do not seem to be bugs.

Thanks again for the report!

Hello @Pilot,

I would tend to agree. Those files are not in the standard library.

Which network interface are you using? Can you please give me a link?

Thanks,
Aniruddha

Archit,

Thanks very much for looking into this! Have a great day!

I’m using a pretty custom network interface (PIC32MZ MAC, Zero-Copy, DP83822 PHY). I can send it privately if you’d like to look at it, but it’s not something I would want to share on the forum.

Hello Pilot, the warnings that you show are indeed about the FTP/HTTP server that I once developed. You can find the latest version here

Ah! I see :slightly_smiling_face:

I was just asking for the file so that I can fix the warnings in the code. Since it is not in the official GitHub repository, I don’t think that you would need to send it to me.

If it is a new network driver and you would like to contribute to FreeRTOS+TCP, we would appreciate if you can create a PR for that.

Thanks,
Aniruddha