Skip to content

retarget: Fix path behaviour without leading slash #6156

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

Merged
merged 1 commit into from
Feb 23, 2018

Conversation

geky
Copy link
Contributor

@geky geky commented Feb 21, 2018

Current behaviour ends up undefined when the constructor leaves early. Now FilePath just discards leading slashes and otherwise asserts if the path is bad.

Note: The correct behavior should be to return ENOENT in this case, but in order to propagate errors this layer would require quite a bit of restructuring. Since this is currently blocking #5959 and assert is a good compromise.

related #5959, #6090
release patch
cc @deepikabhavnani, @kegilbert

Current behaviour ends up undefined when the constructor leaves early.
Now FilePath just discards leading slashes and otherwise asserts if the
path is bad.
Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


const char* file_system = &file_path[1];
const char* file_system = file_path;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why is this a const char* instead of char*?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because file_path is a const char*. To change to char * would break constness. But this is describing the data, not the pointer itself. If you wanted a const pointer it'd look like this const char *const file_path, and then you would be prevented from modifying the pointer itself. Isn't it beautiful?

@@ -18,9 +18,10 @@
namespace mbed {

FilePath::FilePath(const char* file_path) : file_name(NULL), fb(NULL) {
if ((file_path[0] != '/') || (file_path[1] == 0)) return;
// skip slashes
file_path += strspn(file_path, "/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an amusing way to catch a slew of slashes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's more amusing is the rest of the function could be replaced by:

len = strcspn(file_path, "/");

@cmonr
Copy link
Contributor

cmonr commented Feb 21, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Feb 21, 2018

Build : SUCCESS

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

Triggering tests

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

@mbed-ci
Copy link

mbed-ci commented Feb 22, 2018

@mbed-ci
Copy link

mbed-ci commented Feb 22, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 22, 2018

aborted build, restarting

/morph test

@mbed-ci
Copy link

mbed-ci commented Feb 22, 2018

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 22, 2018

Looking at the logs, seems this change is causing one target to timeout, please review if it's related or we are having target/network issue, will check other test results if we can reproduce this somewhere else

This is the last output from the device:

03:29:02 [1519291821.88][CONN][INF] found KV pair in stream: {{__testcase_start;TCP hello world}}, queued...

@cmonr
Copy link
Contributor

cmonr commented Feb 22, 2018

/morph test

@mbed-ci
Copy link

mbed-ci commented Feb 23, 2018

@cmonr cmonr removed the needs: CI label Feb 23, 2018
@cmonr cmonr merged commit d44f999 into ARMmbed:master Feb 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants