diff options
Diffstat (limited to 'kernel/storage.cpp')
-rw-r--r-- | kernel/storage.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/kernel/storage.cpp b/kernel/storage.cpp index ff86896..29ae6cf 100644 --- a/kernel/storage.cpp +++ b/kernel/storage.cpp @@ -122,7 +122,7 @@ namespace mercury::kernel::storage { while (len != 0) { size_t segment_len = utility::find(str, len, '/'); - size_t to_skip = segment_len == len ? len : len + 1; + size_t to_skip = segment_len == len ? segment_len : segment_len + 1; if (segment_len == 0) ; @@ -211,6 +211,9 @@ namespace mercury::kernel::storage { for (unsigned i = 0; i < prefix_length; ++i) path_without_symlinks_out.segments.add_end(path.segments.buffer[i]); + if (path.segments.count == 0) + goto on_final_node; + for (unsigned i = prefix_length; i < path.segments.count - 1; ++i) { path_without_symlinks_out.segments.add_end(path.segments.buffer[i]); @@ -228,13 +231,17 @@ namespace mercury::kernel::storage { } - const utility::string &last_segment = - path.segments.buffer[path.segments.count - 1]; - path_without_symlinks_out.segments.add_end(last_segment); - - RETURN_IF_NOT_SUCCESS(bd_out->mounted_as->get_child( - node_out, node_out, last_segment.buffer, last_segment.count)) + { + //in a block so that compiler sees last_segment + //isn't needed after this and allows the goto above. + const utility::string &last_segment = + path.segments.buffer[path.segments.count - 1]; + path_without_symlinks_out.segments.add_end(last_segment); + RETURN_IF_NOT_SUCCESS(bd_out->mounted_as->get_child( + node_out, node_out, last_segment.buffer, last_segment.count)) + } + on_final_node: if (resolve_final_node) RETURN_IF_NOT_SUCCESS(resolve_symlinks( bd_out, node_out, path_without_symlinks_out)) |