Skip to content

Commit e33310e

Browse files
committed
minor fix
1 parent 0dc3b6b commit e33310e

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

runtime-light/state/component-state.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ void ComponentState::parse_runtime_config_arg(std::string_view value_view) noexc
8686
}
8787

8888
struct stat stat {};
89-
if (auto stat_result{k2::stat({runtime_config_path.get(), runtime_config_path_size}, std::addressof(stat))}; !stat_result.has_value()) [[unlikely]] {
90-
return kphp::log::warning("error getting runtime-config stat: error code -> {}", stat_result.error());
89+
if (auto expected_stat_result{k2::stat({runtime_config_path.get(), runtime_config_path_size}, std::addressof(stat))}; !expected_stat_result.has_value())
90+
[[unlikely]] {
91+
return kphp::log::warning("error getting runtime-config stat: error code -> {}", expected_stat_result.error());
9192
}
9293

9394
const auto runtime_config_mem{std::unique_ptr<char, decltype(std::addressof(kphp::memory::script::free))>{

runtime-light/stdlib/file/file-system-functions.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ inline Optional<string> f$file_get_contents(const string& stream) noexcept {
203203
inline Optional<array<string>> f$file(const string& name) noexcept {
204204
struct stat stat_buf {};
205205

206-
auto open_result{kphp::fs::file::open(name.c_str(), "r")};
207-
if (!open_result.has_value()) {
206+
auto expected_file{kphp::fs::file::open(name.c_str(), "r")};
207+
if (!expected_file.has_value()) {
208208
return false;
209209
}
210210
if (!k2::stat(name.c_str(), std::addressof(stat_buf)).has_value()) {
@@ -221,15 +221,14 @@ inline Optional<array<string>> f$file(const string& name) noexcept {
221221
return false;
222222
}
223223

224-
auto& file{open_result.value()};
225-
226224
kphp::stl::vector<std::byte, kphp::memory::script_allocator> file_content{size};
227-
if (auto rd_status{file.read(file_content)}; !rd_status.has_value() || rd_status.value() < size) {
228-
return false;
225+
{
226+
auto& file{std::move(*expected_file)};
227+
if (auto expected_read_result{file.read(file_content)}; !expected_read_result.has_value() || *expected_read_result < size) {
228+
return false;
229+
}
229230
}
230231

231-
file.close();
232-
233232
array<string> result;
234233
int32_t prev{-1};
235234
for (size_t i{0}; i < size; i++) {

runtime-light/stdlib/kml/kml-file-api.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ class dir_traverser final : public kphp::kml::dir_traverser_interface<dir_traver
120120
}
121121

122122
struct stat stat {};
123-
if (auto stat_result{k2::stat(direntry_path, std::addressof(stat))}; !stat_result.has_value()) [[unlikely]] {
124-
kphp::log::warning("[kml] failed to get stat: error code -> {}, path -> {}", stat_result.error(), direntry_path);
123+
if (auto expected_stat_result{k2::stat(direntry_path, std::addressof(stat))}; !expected_stat_result.has_value()) [[unlikely]] {
124+
kphp::log::warning("[kml] failed to get stat: error code -> {}, path -> {}", expected_stat_result.error(), direntry_path);
125125
return std::nullopt;
126126
}
127127

0 commit comments

Comments
 (0)