chore(3p/nix): apply google-readability-casting

Command run: jq <compile_commands.json -r 'map(.file)|.[]' | grep -v '/generated/' | parallel clang-tidy -p compile_commands.json -checks=-*,google-readability-casting --fix

Manual fixes applied in src/nix-env/nix-env.cc, src/libstore/store-api.cc

Change-Id: I406b4be9368c557ca59329bf6f7002704e955f8d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1557
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Kane York 2020-08-01 17:17:44 -07:00 committed by kanepyork
parent 053a138002
commit 1de00e6c42
40 changed files with 161 additions and 125 deletions

View file

@ -876,7 +876,7 @@ static void prim_readFile(EvalState& state, const Pos& pos, Value** args,
}
std::string s =
readFile(state.checkSourcePath(state.toRealPath(path, context)));
if (s.find((char)0) != std::string::npos) {
if (s.find(static_cast<char>(0)) != std::string::npos) {
throw Error(format("the contents of the file '%1%' cannot be represented "
"as a Nix string") %
path);
@ -1421,7 +1421,7 @@ static void prim_isList(EvalState& state, const Pos& pos, Value** args,
static void elemAt(EvalState& state, const Pos& pos, Value& list, int n,
Value& v) {
state.forceList(list, pos);
if (n < 0 || (unsigned int)n >= list.listSize()) {
if (n < 0 || static_cast<unsigned int>(n) >= list.listSize()) {
throw Error(format("list index %1% is out of bounds, at %2%") % n % pos);
}
state.forceValue(*(*list.list)[n]);
@ -1587,7 +1587,7 @@ static void prim_genList(EvalState& state, const Pos& pos, Value** args,
state.mkList(v, len);
for (unsigned int n = 0; n < (unsigned int)len; ++n) {
for (unsigned int n = 0; n < static_cast<unsigned int>(len); ++n) {
Value* arg = state.allocValue();
mkInt(*arg, n);
mkApp(*((*v.list)[n] = state.allocValue()), *args[0], *arg);
@ -1790,7 +1790,10 @@ static void prim_substring(EvalState& state, const Pos& pos, Value** args,
pos);
}
mkString(v, (unsigned int)start >= s.size() ? "" : std::string(s, start, len),
mkString(v,
static_cast<unsigned int>(start) >= s.size()
? ""
: std::string(s, start, len),
context);
}