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

fix compiler warning #6018

Merged
merged 1 commit into from Feb 12, 2018

Conversation

Projects
None yet
5 participants
@bmcdonnell-ionx
Contributor

bmcdonnell-ionx commented Feb 5, 2018

Resolves the compiler warnings first mentioned here:

../mbed-os/features/filesystem/fat/FATFileSystem.cpp: In member function 'virtual void FATFileSystem::dir_seek(mbed::fs_dir_t, off_t)':
../mbed-os/features/filesystem/fat/FATFileSystem.cpp:661:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (offset < dh->dptr) {
         ~~~~~~~^~~~~~~~~~
../mbed-os/features/filesystem/fat/FATFileSystem.cpp:664:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (dh->dptr < offset) {
            ~~~~~~~~~^~~~~~~~

I don't actually understand how dir_seek() is doing its job, though. Can someone explain?

@mbed-ci

This comment has been minimized.

mbed-ci commented Feb 5, 2018

User not whitelisted, CI not run.

@cmonr cmonr requested a review from geky Feb 6, 2018

@cmonr cmonr added the needs: review label Feb 6, 2018

@0xc0170

0xc0170 approved these changes Feb 7, 2018

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Feb 7, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Feb 7, 2018

Build : SUCCESS

Build number : 1084
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6018/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@geky

This comment has been minimized.

Member

geky commented Feb 7, 2018

Thanks for the pr!

The conditions in dir_seek are handling two different cases:

  1. offset > dptr:

              dptr
              v
    blah blah blah blah blah
                   ^
                   off
    

    Here we can just iterate forward until dptr == off (the while loop).

  2. offset < dptr:

              dptr
              v
    blah blah blah blah blah
         ^
         off
    

    But here we would need to iterate backwards. In theory we could iterate backwards, but it gets complicated because of LFNs. Since ChanFS targets embedded systems and we care more about code footprint than speed (especially in the weird corner case of iterating backwards in a directory), we just rewind completely (the rewind call) and then iterate forwards until dptr == off (the while loop).

It's an interesting case of reusing as much code as possible to keep the code footprint small.

Does that help clarify things?

@bmcdonnell-ionx

This comment has been minimized.

Contributor

bmcdonnell-ionx commented Feb 8, 2018

Does that help clarify things?

Yes, thanks!

I think my confusion stemmed from figuring that offset would be relative to the current position, not an "absolute" position within the directory.

...This PR should stay open until someone merges it, right? (Just checking, since I have the option to close it.)

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Feb 8, 2018

...This PR should stay open until someone merges it, right? (Just checking, since I have the option to close it.)

@geky Approved?

@geky

geky approved these changes Feb 8, 2018

@geky

This comment has been minimized.

Member

geky commented Feb 8, 2018

Ah my bad, I forgot to click the approve button.

Only open prs are candidates for being merged. Closing a pr is the same as saying you don't want the pr merged.

Although it's easy to reopen closed prs and issues.


Thinking about it, offset is kinda a funny name, but the name comes from the fact that it's an offset from the start of the file/directory.

@cmonr cmonr merged commit bab8cc4 into ARMmbed:master Feb 12, 2018

19 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
mbed-ci-generic Build finished.
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Local events testing has passed
Details
travis-ci/littlefs Local littlefs testing has passed
Details
travis-ci/mbed2-ATMEL Local mbed2-ATMEL testing has passed
Details
travis-ci/mbed2-MAXIM Local mbed2-MAXIM testing has passed
Details
travis-ci/mbed2-NORDIC Local mbed2-NORDIC testing has passed
Details
travis-ci/mbed2-NUVOTON Local mbed2-NUVOTON testing has passed
Details
travis-ci/mbed2-NXP Local mbed2-NXP testing has passed
Details
travis-ci/mbed2-RENESAS Local mbed2-RENESAS testing has passed
Details
travis-ci/mbed2-SILICON_LABS Local mbed2-SILICON_LABS testing has passed
Details
travis-ci/mbed2-STM Local mbed2-STM testing has passed
Details
travis-ci/tools Local tools testing has passed
Details

@cmonr cmonr removed the ready for merge label Feb 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment