maintenance: fixed msvc warnings about unreachable code (#3991)

This commit is contained in:
Klaim (Joël Lamotte) 2025-06-23 22:05:29 +02:00 committed by GitHub
parent 1f226d6108
commit ffd08b8661
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 45 additions and 20 deletions

View File

@ -124,7 +124,10 @@ namespace mamba::solver
{
return &(a.what);
}
return nullptr;
else
{
return nullptr;
}
},
action
);
@ -171,7 +174,10 @@ namespace mamba::solver
{
return &(a.what);
}
return nullptr;
else
{
return nullptr;
}
},
action
);
@ -214,7 +220,10 @@ namespace mamba::solver
{
return &(a.what);
}
return nullptr;
else
{
return nullptr;
}
},
action
);

View File

@ -197,7 +197,7 @@ namespace mamba
const Context& context,
const std::string& name,
const std::vector<std::string>& command,
LockFile proc_dir_lock
LockFile proc_dir_lock [[maybe_unused]]
)
: location{ proc_dir() / fmt::format("{}.json", getpid()) }
{
@ -302,9 +302,9 @@ namespace mamba
const std::string& cwd,
int stream_options,
bool clean_env,
bool detach,
bool detach [[maybe_unused]],
const std::vector<std::string>& env_vars,
const std::string& specific_process_name
const std::string& specific_process_name [[maybe_unused]]
)
{
if (!fs::exists(prefix))

View File

@ -494,7 +494,7 @@ namespace mamba
#else
CONSOLE_SCREEN_BUFFER_INFO coninfo;
auto res = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
auto res [[maybe_unused]] = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
return coninfo.dwSize.X;
#endif
}
@ -508,7 +508,7 @@ namespace mamba
#else
CONSOLE_SCREEN_BUFFER_INFO coninfo;
auto res = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
auto res [[maybe_unused]] = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
return coninfo.srWindow.Bottom - coninfo.srWindow.Top + 1;
#endif
}

View File

@ -1647,17 +1647,17 @@ namespace mamba::solver::libsolv
);
return {};
}
if constexpr (std::is_same_v<Job, Request::Freeze>)
else if constexpr (std::is_same_v<Job, Request::Freeze>)
{
return pool_add_matchspec(pool, job.spec, parser)
.transform([&](auto id) { raw_jobs.push_back(SOLVER_LOCK, id); });
}
if constexpr (std::is_same_v<Job, Request::Keep>)
else if constexpr (std::is_same_v<Job, Request::Keep>)
{
return pool_add_matchspec(pool, job.spec, parser)
.transform([&](auto id) { raw_jobs.push_back(SOLVER_USERINSTALLED, id); });
}
if constexpr (std::is_same_v<Job, Request::Pin>)
else if constexpr (std::is_same_v<Job, Request::Pin>)
{
// WARNING pins are not working with namespace dependencies so far
return pool_add_pin(pool, job.spec, MatchSpecParser::Libsolv)
@ -1674,8 +1674,11 @@ namespace mamba::solver::libsolv
}
);
}
assert(false);
return {};
else
{
assert(false); // TODO c++23: replace by `std::unreachable();`
return {};
}
}
}
@ -1698,7 +1701,10 @@ namespace mamba::solver::libsolv
{
return add_job(job, solv_jobs, pool, force_reinstall, parser);
}
return {};
else
{
return {};
}
},
unknown_job
);
@ -1719,7 +1725,10 @@ namespace mamba::solver::libsolv
{
return add_job(job, solv_jobs, pool, force_reinstall, parser);
}
return {};
else
{
return {};
}
},
unknown_job
);

View File

@ -195,7 +195,7 @@ namespace mamba::util
return util::get_windows_known_user_folder(WindowsKnowUserFolder::LocalAppData);
}
auto which_system(std::string_view exe) -> fs::u8path
auto which_system(std::string_view /*exe*/) -> fs::u8path
{
return "";
}

View File

@ -106,12 +106,19 @@ namespace mamba::util
// when followed with a drive letter
// to make it compatible with libcurl on unix
auto [is_file_scheme, slashes, rest] = check_file_scheme_and_slashes(uri);
if (!on_win && is_file_scheme && path_has_drive_letter(rest)
&& ((slashes.size() == 2) || (slashes.size() == 3)))
if constexpr (!on_win)
{
return util::concat("file:////", rest);
if (is_file_scheme && path_has_drive_letter(rest)
&& ((slashes.size() == 2) || (slashes.size() == 3)))
{
return util::concat("file:////", rest);
}
return uri;
}
else
{
return uri;
}
return uri;
}
auto file_uri_unc2_to_unc4(std::string_view uri) -> std::string