Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TW#13494] Compilation fails with -O3 optimization - vfs_fat.c specifically #718

Closed
benpeoples opened this issue Jun 20, 2017 · 3 comments
Closed

Comments

@benpeoples
Copy link

CC src/vfs_fat.o
/Users/ben/esp/esp-idf/components/fatfs/src/vfs_fat.c: In function 'vfs_fat_readdir':
/Users/ben/esp/esp-idf/components/fatfs/src/vfs_fat.c:546:20: error: 'out_dirent' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     struct dirent* out_dirent;
                    ^
cc1: some warnings being treated as errors
make[1]: *** [src/vfs_fat.o] Error 1
make: *** [fatfs-build] Error 2

I have not dug into the issue beyond this. Compiles fine with -O2.

@igrr
Copy link
Member

igrr commented Jun 21, 2017

This probably means that there is a possibility that vfs_fat_readdir_r will return 0 while not initializing out_dirent. The code looks like this:

    FRESULT res = f_readdir(&fat_dir->ffdir, &fat_dir->filinfo);
    if (res != FR_OK) {
        ESP_LOGD(TAG, "%s: fresult=%d", __func__, res);
        return fresult_to_errno(res);
    }

Unless I'm missing something, fresult_to_errno can only return 0 if res is FR_OK. On the other hand, the compiler is rarely wrong about such things. Will run this through a static analyzer...

@FayeY
Copy link
Collaborator

FayeY commented Jun 25, 2017

Hi @benpeoples , is this problem solved now?

@igrr
Copy link
Member

igrr commented Jun 25, 2017

@FayeY Not yet, please assign to me.

@FayeY FayeY changed the title Compilation fails with -O3 optimization - vfs_fat.c specifically [TW#13494] Compilation fails with -O3 optimization - vfs_fat.c specifically Jun 25, 2017
@igrr igrr closed this as completed in ca08397 May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants