1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/pkg_fatfs
Kaspar Schleiser ea6c4a7f23 tests/pkg_fatfs: fix sprintf format overflow warning
Some platforms issue this:

    tests/pkg_fatfs/main.c: In function '_mkfs':
    tests/pkg_fatfs/main.c:355:26: error: '%d' directive writing between 1 and 11 bytes into a region of size 8 [-Werror=format-overflo
    w=]
      355 |     sprintf(volume_str, "%d:/", vol_idx);
          |                          ^~
    tests/pkg_fatfs/main.c:355:25: note: directive argument in the range [-2147483648, 0]
      355 |     sprintf(volume_str, "%d:/", vol_idx);
          |                         ^~~~~~
    tests/pkg_fatfs/main.c:355:5: note: 'sprintf' output between 4 and 14 bytes into a destination of size 8
      355 |     sprintf(volume_str, "%d:/", vol_idx);
          |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

The cause is vol_idx being converted by atoi(), so it might be negative.
This commit increases the stack array so it cannot overflow.
2019-10-18 23:06:44 +02:00
..
create_fat_image_file.sh pkg/fatfs: add vfs integration 2018-01-09 14:46:40 +01:00
main.c tests/pkg_fatfs: fix sprintf format overflow warning 2019-10-18 23:06:44 +02:00
Makefile tests: BOARD_INSUFFICIENT_MEMORY -> Makefile.ci 2019-10-17 15:11:59 +02:00
Makefile.ci tests: BOARD_INSUFFICIENT_MEMORY -> Makefile.ci 2019-10-17 15:11:59 +02:00
README.md tests/pkg_fatfs: Word wrap README 2018-03-14 11:56:52 +01:00
riot_fatfs_disk.tar.gz pkg/fatfs: add vfs integration 2018-01-09 14:46:40 +01:00

Using FatFs on RIOT

native

To use this test on native you can either use a FAT-formatted image file or directly use the mkfs command from the RIOT shell. Use make image to extract a prepared image file that already contains a simple test.txt file. This is only a convinience function to allow testing against a "default linux" formatted fat volume without the need to call mount or other stuff that may require super user privileges. Optionally make compressed-image can be used to generate the compressed image that is in turn used by make image.

To tell RIOT where your image file is located you can use the define MTD_NATIVE_FILENAME.

NOTE: You shouldn't leave the image mounted while you use it in RIOT, the abstraction layer between FatFs and the image file mimics a dumb block device (i.e. behaves much like the devices that are actually meant to be used with FAT) That implies it doesn't show any modifications in RIOT that you perform on your OS and the other way round. So always remember to mount/unmount correctly or your FS will probably get damaged.

Real Hardware

Currently the test defaults to sdcard_spi on real hardware. But generally any device that supports the mtd-interface can be used with FatFs.