From c25c43d8c8e42767f2dcb8c45a7547f31bac4866 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Tue, 20 Aug 2024 16:13:17 -0700 Subject: [PATCH] flake: fix compiler warning GCC was complaining, rightfully, about mixed-sign comparisons in there. I removed some extra sign mixing too. Change-Id: I949a618c7405c23d4dc3fd17440ea2d7b5c22c9d --- src/nix/flake.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index d4eca86b8..15c393c90 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -1275,13 +1275,15 @@ struct CmdFlakeShow : FlakeCommand, MixJSON // FIXME: handle utf8 visible width properly once we get KJ which has utf8 support // technically filterANSIEscapes knows how to do this but there is absolutely // no clear usage of it that would actually let us do this layout. - int spaceForDescription = screenWidth - output.size() - quotesAndSepsWidth; + assert(output.size() < std::numeric_limits::max()); + int spaceForDescription = screenWidth - int(output.size()) - quotesAndSepsWidth; if (spaceForDescription <= 0) { // do nothing, it is going to wrap no matter what, and it's better to output *something* } else { const char *ellipsis = ""; - if (spaceForDescription < firstLineDesc.size()) { + assert(firstLineDesc.size() < std::numeric_limits::max()); + if (spaceForDescription < int(firstLineDesc.size())) { // subtract one to make space for the ellipsis firstLineDesc.resize(spaceForDescription - 1); ellipsis = "…";