Skip to content

Commit e09c04f

Browse files
committed
cli: fix all compiler warnings and remove dead code
- remove unused helper functions (BuildCommand, TestsCommand, UpdateCommand) - fix sign-conversion in termios handling - fix FNV-1a hash sign conversion - fix variable shadowing in DirectScriptRunner - clarify logical conditions with explicit parentheses in error rules - improve overall code safety and determinism
1 parent 6304b31 commit e09c04f

9 files changed

Lines changed: 13 additions & 71 deletions

src/commands/BuildCommand.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,40 +1496,6 @@ namespace vix::commands::BuildCommand
14961496
process::Plan plan_{};
14971497
};
14981498

1499-
static std::optional<fs::path> find_last_built_binary()
1500-
{
1501-
namespace fs = std::filesystem;
1502-
1503-
const fs::path meta = fs::current_path() / ".vix" / "meta.json";
1504-
1505-
if (!fs::exists(meta))
1506-
return std::nullopt;
1507-
1508-
std::ifstream f(meta);
1509-
if (!f)
1510-
return std::nullopt;
1511-
1512-
std::string content((std::istreambuf_iterator<char>(f)),
1513-
std::istreambuf_iterator<char>());
1514-
1515-
const std::string key = "\"last_binary\":\"";
1516-
auto pos = content.find(key);
1517-
if (pos == std::string::npos)
1518-
return std::nullopt;
1519-
1520-
pos += key.size();
1521-
auto end = content.find("\"", pos);
1522-
if (end == std::string::npos)
1523-
return std::nullopt;
1524-
1525-
fs::path p = content.substr(pos, end - pos);
1526-
1527-
if (fs::exists(p))
1528-
return p;
1529-
1530-
return std::nullopt;
1531-
}
1532-
15331499
} // namespace
15341500

15351501
int run(const std::vector<std::string> &args)

src/commands/TestsCommand.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,6 @@ namespace
290290
return std::nullopt;
291291
}
292292

293-
static bool has_flag(
294-
const std::vector<std::string> &args,
295-
const std::string &flag)
296-
{
297-
return std::find(args.begin(), args.end(), flag) != args.end();
298-
}
299-
300293
static std::string resolve_preset_name(const vix::commands::TestsCommand::detail::Options &opt)
301294
{
302295
if (auto p = value_after_flag(opt.forwarded, "--preset"))

src/commands/UpdateCommand.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -238,24 +238,6 @@ namespace vix::commands
238238
return 0;
239239
}
240240

241-
bool lock_contains_dependency_id(const json &lock, const std::string &wantedId)
242-
{
243-
if (!lock.contains("dependencies") || !lock["dependencies"].is_array())
244-
{
245-
return false;
246-
}
247-
248-
for (const auto &d : lock["dependencies"])
249-
{
250-
if (d.value("id", "") == wantedId)
251-
{
252-
return true;
253-
}
254-
}
255-
256-
return false;
257-
}
258-
259241
std::string read_locked_version(const json &lock, const std::string &id)
260242
{
261243
if (!lock.contains("dependencies") || !lock["dependencies"].is_array())

src/commands/run/RunProcess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ namespace vix::commands::RunCommand::detail
10151015
struct termios tty{};
10161016
if (::tcgetattr(slaveFd, &tty) == 0)
10171017
{
1018-
tty.c_lflag &= ~ECHO;
1018+
tty.c_lflag &= static_cast<tcflag_t>(~ECHO);
10191019
::tcsetattr(slaveFd, TCSANOW, &tty);
10201020
}
10211021
}

src/commands/run/detail/DirectScriptRunner.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ namespace vix::commands::RunCommand::detail
110110
constexpr std::uint64_t prime = 1099511628211ull;
111111

112112
std::uint64_t h = offset;
113-
for (unsigned char c : input)
113+
for (char ch : input)
114114
{
115+
const auto c = static_cast<unsigned char>(ch);
115116
h ^= static_cast<std::uint64_t>(c);
116117
h *= prime;
117118
}
@@ -265,9 +266,9 @@ namespace vix::commands::RunCommand::detail
265266
if (const auto pch = find_vix_pch())
266267
cmd << " -include-pch " << process::quote(pch->string());
267268

268-
if (const auto lib = find_vix_lib())
269+
if (const auto vixLib = find_vix_lib())
269270
{
270-
cmd << " " << process::quote(lib->string());
271+
cmd << " " << process::quote(vixLib->string());
271272
}
272273
else
273274
{
@@ -277,8 +278,8 @@ namespace vix::commands::RunCommand::detail
277278
#ifndef __APPLE__
278279
cmd << " -Wl,--start-group";
279280
#endif
280-
for (const auto &lib : libs)
281-
cmd << " " << process::quote(lib.string());
281+
for (const auto &moduleLib : libs)
282+
cmd << " " << process::quote(moduleLib.string());
282283
#ifndef __APPLE__
283284
cmd << " -Wl,--end-group";
284285
#endif

src/errors/runtime/IteratorInvalidationRule.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ namespace vix::cli::errors::runtime
4141
icontains(log, "attempt to dereference a singular iterator") ||
4242
icontains(log, "attempt to increment a singular iterator") ||
4343
icontains(log, "attempt to compare a singular iterator") ||
44-
icontains(log, "vector iterator") && icontains(log, "invalid") ||
45-
icontains(log, "deque iterator") && icontains(log, "invalid") ||
46-
icontains(log, "list iterator") && icontains(log, "invalid");
44+
(icontains(log, "vector iterator") && icontains(log, "invalid")) ||
45+
(icontains(log, "deque iterator") && icontains(log, "invalid")) ||
46+
(icontains(log, "list iterator") && icontains(log, "invalid"));
4747
}
4848

4949
bool handle(

src/errors/template/ConceptConstraintFailureRule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace vix::cli::errors::template_rules
7373

7474
return icontains(m, "constraints not satisfied") ||
7575
icontains(m, "constraint failure") ||
76-
icontains(m, "concept") && icontains(m, "not satisfied") ||
76+
(icontains(m, "concept") && icontains(m, "not satisfied")) ||
7777
icontains(m, "requirements not satisfied") ||
7878
icontains(m, "does not satisfy") ||
7979
icontains(m, "failed requirement");

src/errors/template/RequiresExpressionFailureRule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ namespace vix::cli::errors::template_rules
7575
(icontains(m, "requires") && icontains(m, "invalid")) ||
7676
icontains(m, "required expression") ||
7777
icontains(m, "required type") ||
78-
icontains(m, "required from here") && icontains(m, "requires") ||
78+
(icontains(m, "required from here") && icontains(m, "requires")) ||
7979
icontains(m, "would be invalid") ||
8080
icontains(m, "does not satisfy return-type-requirement");
8181
}

src/errors/template/TemplateArgumentMismatchRule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace vix::cli::errors::template_rules
7272
const std::string &m = err.message;
7373

7474
return icontains(m, "wrong number of template arguments") ||
75-
icontains(m, "template argument") && icontains(m, "invalid") ||
75+
(icontains(m, "template argument") && icontains(m, "invalid")) ||
7676
icontains(m, "type/value mismatch at argument") ||
7777
icontains(m, "expected a type, got") ||
7878
icontains(m, "expected a constant of type") ||

0 commit comments

Comments
 (0)