From eb087c33835da15af4449b18e1c27448fda6e156 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 12 Jul 2022 13:13:14 -0700 Subject: [PATCH] exploitability_linux: fix mismatched comparison warning On ARM, this write fails to build: comparison of integers of different signs: 'ssize_t' (aka 'int') and 'const unsigned int' [-Werror,-Wsign-compare] Since we check that it's <= 15 above, we can simply cast it without issue. Bug: b:235999011 Change-Id: Id75fc0df74e88b347df615df06567e96c6b59a1d Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3758800 Reviewed-by: Mike Frysinger --- src/processor/exploitability_linux.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/processor/exploitability_linux.cc b/src/processor/exploitability_linux.cc index 7a0fb71a..d4900bb0 100644 --- a/src/processor/exploitability_linux.cc +++ b/src/processor/exploitability_linux.cc @@ -502,7 +502,9 @@ bool ExploitabilityLinux::DisassembleBytes(const string& architecture, unlink(raw_bytes_tmpfile); return false; } - if (write(raw_bytes_fd, raw_bytes, raw_bytes_len) != raw_bytes_len) { + // Casting raw_bytes_len to `ssize_t` won't cause a sign flip, since we check + // its bounds above. + if (write(raw_bytes_fd, raw_bytes, raw_bytes_len) != (ssize_t)raw_bytes_len) { BPLOG(ERROR) << "Writing of raw bytes failed."; unlink(raw_bytes_tmpfile); return false;