summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Webb <chris@arachsys.com>2023-12-10 08:50:09 +0000
committerChris Webb <chris@arachsys.com>2023-12-10 11:09:55 +0000
commita8d5b8bd2c8846bc996aed70434a4f0c488c1cc6 (patch)
tree85f240825b14de0030e5ebfdcd28de7d0e255191 /src
parent7f49395cf931b2af8a75ffb5319a8aa8c395ed8d (diff)
Fix compiler warnings when char is unsigned
In several places, we check for a control character with something like char c; [...] if (c >= 0 and c <= 0x1F) [...] When char is signed (e.g. amd64) this is fine, but when char is unsigned by default (e.g. arm32 and arm64) this generates warnings about the tautologous check that an unsigned value is non-negative. Write as if ((unsigned char) c <= 0x1F) [...] which is both correct and not suspicious under both conventions.
Diffstat (limited to 'src')
-rw-r--r--src/json.cc4
-rw-r--r--src/terminal_ui.cc4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/json.cc b/src/json.cc
index 82fc0f28..7323e2fe 100644
--- a/src/json.cc
+++ b/src/json.cc
@@ -20,7 +20,7 @@ String to_json(StringView str)
for (auto it = str.begin(), end = str.end(); it != end; )
{
auto next = std::find_if(it, end, [](char c) {
- return c == '\\' or c == '"' or (c >= 0 and c <= 0x1F);
+ return c == '\\' or c == '"' or (unsigned char) c <= 0x1F;
});
res += StringView{it, next};
@@ -28,7 +28,7 @@ String to_json(StringView str)
break;
char buf[7] = {'\\', *next, 0};
- if (*next >= 0 and *next <= 0x1F)
+ if ((unsigned char) *next <= 0x1F)
format_to(buf, "\\u{:04}", hex(*next));
res += buf;
diff --git a/src/terminal_ui.cc b/src/terminal_ui.cc
index 62df5aa7..db967976 100644
--- a/src/terminal_ui.cc
+++ b/src/terminal_ui.cc
@@ -30,8 +30,8 @@ static String fix_atom_text(StringView str)
auto pos = str.begin();
for (auto it = str.begin(), end = str.end(); it != end; ++it)
{
- char c = *it;
- if (c >= 0 and c <= 0x1F)
+ unsigned char c = *it;
+ if (c <= 0x1F)
{
res += StringView{pos, it};
res += String{Codepoint{(uint32_t)(0x2400 + c)}};