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

Improve path handling #190

Merged
merged 2 commits into from
Sep 8, 2021
Merged

Improve path handling #190

merged 2 commits into from
Sep 8, 2021

Conversation

mkroening
Copy link
Member

@mkroening mkroening commented Sep 7, 2021

This fixes a faulty PathBuf construction and lets all PathBufs be constructed via collecting instead of pushing.

Found via #192.

@codecov
Copy link

codecov bot commented Sep 7, 2021

Codecov Report

Merging #190 (d257e37) into master (4115924) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #190      +/-   ##
==========================================
- Coverage   30.76%   30.75%   -0.02%     
==========================================
  Files          16       16              
  Lines        4018     4026       +8     
==========================================
+ Hits         1236     1238       +2     
- Misses       2782     2788       +6     
Impacted Files Coverage Δ
src/vm.rs 28.47% <100.00%> (+0.12%) ⬆️
src/linux/uhyve.rs 52.88% <0.00%> (-0.89%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4115924...d257e37. Read the comment docs.

@jounathaen
Copy link
Member

The first commit is fine, even though a // inside a path is not really faulty 😉
However, I don't really get the advantage of .iter().collect() in this case.

@jounathaen
Copy link
Member

Just to prove my point, that this isn't faulty 😛 :
From the POSIX standard:

Multiple successive <slash> characters are considered to be the same as one , except for the case of exactly two leading <slash> characters

@mkroening
Copy link
Member Author

It certainly is faulty! “Pushing an absolute path replaces the existing path” (PathBuf::push)

As for using collect over push, this is preferential, but this avoids having a mutable PathBuf and avoids spreading the path segments across multiple statements. “push is best used for dynamic situations. This is a better way to do this when you know all of the components ahead of time” (PathBuf)

@jounathaen
Copy link
Member

Fair enough!

bors r+

@bors bors bot merged commit 4c33c8e into hermit-os:master Sep 8, 2021
@mkroening mkroening deleted the pathbuf branch September 8, 2021 09:17
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

Successfully merging this pull request may close these issues.

None yet

2 participants