Skip to content

Commit ffd08b8

Browse files
authored
maintenance: fixed msvc warnings about unreachable code (#3991)
1 parent 1f226d6 commit ffd08b8

File tree

6 files changed

+45
-20
lines changed

6 files changed

+45
-20
lines changed

libmamba/include/mamba/solver/solution.hpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ namespace mamba::solver
124124
{
125125
return &(a.what);
126126
}
127-
return nullptr;
127+
else
128+
{
129+
return nullptr;
130+
}
128131
},
129132
action
130133
);
@@ -171,7 +174,10 @@ namespace mamba::solver
171174
{
172175
return &(a.what);
173176
}
174-
return nullptr;
177+
else
178+
{
179+
return nullptr;
180+
}
175181
},
176182
action
177183
);
@@ -214,7 +220,10 @@ namespace mamba::solver
214220
{
215221
return &(a.what);
216222
}
217-
return nullptr;
223+
else
224+
{
225+
return nullptr;
226+
}
218227
},
219228
action
220229
);

libmamba/src/core/run.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ namespace mamba
197197
const Context& context,
198198
const std::string& name,
199199
const std::vector<std::string>& command,
200-
LockFile proc_dir_lock
200+
LockFile proc_dir_lock [[maybe_unused]]
201201
)
202202
: location{ proc_dir() / fmt::format("{}.json", getpid()) }
203203
{
@@ -302,9 +302,9 @@ namespace mamba
302302
const std::string& cwd,
303303
int stream_options,
304304
bool clean_env,
305-
bool detach,
305+
bool detach [[maybe_unused]],
306306
const std::vector<std::string>& env_vars,
307-
const std::string& specific_process_name
307+
const std::string& specific_process_name [[maybe_unused]]
308308
)
309309
{
310310
if (!fs::exists(prefix))

libmamba/src/core/util_os.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ namespace mamba
494494
#else
495495

496496
CONSOLE_SCREEN_BUFFER_INFO coninfo;
497-
auto res = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
497+
auto res [[maybe_unused]] = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
498498
return coninfo.dwSize.X;
499499
#endif
500500
}
@@ -508,7 +508,7 @@ namespace mamba
508508
#else
509509

510510
CONSOLE_SCREEN_BUFFER_INFO coninfo;
511-
auto res = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
511+
auto res [[maybe_unused]] = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
512512
return coninfo.srWindow.Bottom - coninfo.srWindow.Top + 1;
513513
#endif
514514
}

libmamba/src/solver/libsolv/helpers.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,17 +1647,17 @@ namespace mamba::solver::libsolv
16471647
);
16481648
return {};
16491649
}
1650-
if constexpr (std::is_same_v<Job, Request::Freeze>)
1650+
else if constexpr (std::is_same_v<Job, Request::Freeze>)
16511651
{
16521652
return pool_add_matchspec(pool, job.spec, parser)
16531653
.transform([&](auto id) { raw_jobs.push_back(SOLVER_LOCK, id); });
16541654
}
1655-
if constexpr (std::is_same_v<Job, Request::Keep>)
1655+
else if constexpr (std::is_same_v<Job, Request::Keep>)
16561656
{
16571657
return pool_add_matchspec(pool, job.spec, parser)
16581658
.transform([&](auto id) { raw_jobs.push_back(SOLVER_USERINSTALLED, id); });
16591659
}
1660-
if constexpr (std::is_same_v<Job, Request::Pin>)
1660+
else if constexpr (std::is_same_v<Job, Request::Pin>)
16611661
{
16621662
// WARNING pins are not working with namespace dependencies so far
16631663
return pool_add_pin(pool, job.spec, MatchSpecParser::Libsolv)
@@ -1674,8 +1674,11 @@ namespace mamba::solver::libsolv
16741674
}
16751675
);
16761676
}
1677-
assert(false);
1678-
return {};
1677+
else
1678+
{
1679+
assert(false); // TODO c++23: replace by `std::unreachable();`
1680+
return {};
1681+
}
16791682
}
16801683
}
16811684

@@ -1698,7 +1701,10 @@ namespace mamba::solver::libsolv
16981701
{
16991702
return add_job(job, solv_jobs, pool, force_reinstall, parser);
17001703
}
1701-
return {};
1704+
else
1705+
{
1706+
return {};
1707+
}
17021708
},
17031709
unknown_job
17041710
);
@@ -1719,7 +1725,10 @@ namespace mamba::solver::libsolv
17191725
{
17201726
return add_job(job, solv_jobs, pool, force_reinstall, parser);
17211727
}
1722-
return {};
1728+
else
1729+
{
1730+
return {};
1731+
}
17231732
},
17241733
unknown_job
17251734
);

libmamba/src/util/environment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ namespace mamba::util
195195
return util::get_windows_known_user_folder(WindowsKnowUserFolder::LocalAppData);
196196
}
197197

198-
auto which_system(std::string_view exe) -> fs::u8path
198+
auto which_system(std::string_view /*exe*/) -> fs::u8path
199199
{
200200
return "";
201201
}

libmamba/src/util/url_manip.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,19 @@ namespace mamba::util
106106
// when followed with a drive letter
107107
// to make it compatible with libcurl on unix
108108
auto [is_file_scheme, slashes, rest] = check_file_scheme_and_slashes(uri);
109-
if (!on_win && is_file_scheme && path_has_drive_letter(rest)
110-
&& ((slashes.size() == 2) || (slashes.size() == 3)))
109+
if constexpr (!on_win)
111110
{
112-
return util::concat("file:////", rest);
111+
if (is_file_scheme && path_has_drive_letter(rest)
112+
&& ((slashes.size() == 2) || (slashes.size() == 3)))
113+
{
114+
return util::concat("file:////", rest);
115+
}
116+
return uri;
117+
}
118+
else
119+
{
120+
return uri;
113121
}
114-
return uri;
115122
}
116123

117124
auto file_uri_unc2_to_unc4(std::string_view uri) -> std::string

0 commit comments

Comments
 (0)