Clean up warnings in cuttlefish_common

Test: Local build and boot
BUG: 70865594
Change-Id: I4eb2abf4b03bcd392eb1686c0d45ddbab4d7aa49
diff --git a/Android.bp b/Android.bp
index 142b66a..a4de508 100644
--- a/Android.bp
+++ b/Android.bp
@@ -55,6 +55,7 @@
             enabled: false,
         },
     },
+    cflags: ["-Werror", "-Wall"],
     vendor: true,
 }
 
diff --git a/common/libs/fs/shared_fd.h b/common/libs/fs/shared_fd.h
index 69542e6..57ace56 100644
--- a/common/libs/fs/shared_fd.h
+++ b/common/libs/fs/shared_fd.h
@@ -411,7 +411,7 @@
     cmsg->cmsg_level = SOL_SOCKET;
     cmsg->cmsg_type = SCM_RIGHTS;
     int* fd_array = reinterpret_cast<int*>(CMSG_DATA(cmsg));
-    for (int i = 0; i < SZ; ++i) {
+    for (size_t i = 0; i < SZ; ++i) {
       fd_array[i] = fds[i]->fd_;
     }
     return SendMsg(&msg, flags);
diff --git a/common/libs/wifi/netlink.h b/common/libs/wifi/netlink.h
index 20b13c1..e380731 100644
--- a/common/libs/wifi/netlink.h
+++ b/common/libs/wifi/netlink.h
@@ -57,7 +57,9 @@
   WRClient wrcl_;
 
   int mac80211_hwsim_family_ = 0;
+#if 0
   int router_family_ = 0;
+#endif
   int nl80211_family_ = 0;
 
   std::unique_ptr<std::thread> netlink_thread_;
diff --git a/common/libs/wifi/wr_client.cc b/common/libs/wifi/wr_client.cc
index 65fd170..7b342b0 100644
--- a/common/libs/wifi/wr_client.cc
+++ b/common/libs/wifi/wr_client.cc
@@ -71,7 +71,7 @@
   }
 
   auto hdr = reinterpret_cast<nlmsghdr*>(buf.get());
-  if (size != hdr->nlmsg_len) {
+  if (static_cast<uint32_t>(size) != hdr->nlmsg_len) {
     LOG(FATAL) << "Malformed message from WIFI Router.";
     return;
   }
diff --git a/common/vsoc/lib/circqueue_impl.h b/common/vsoc/lib/circqueue_impl.h
index 3355a9b..d40399b 100644
--- a/common/vsoc/lib/circqueue_impl.h
+++ b/common/vsoc/lib/circqueue_impl.h
@@ -198,7 +198,6 @@
   }
   Range header = range;
   header.end_idx = header.start_idx + sizeof(uint32_t);
-  uint32_t sizeof_uint32_t = sizeof(uint32_t);
   Range payload{
       static_cast<uint32_t>(range.start_idx + sizeof(uint32_t)),
       static_cast<uint32_t>(range.start_idx + sizeof(uint32_t) + bytes)};
diff --git a/guest/commands/wifirouter/Android.bp b/guest/commands/wifirouter/Android.bp
index 741ca7c..ed5d930 100644
--- a/guest/commands/wifirouter/Android.bp
+++ b/guest/commands/wifirouter/Android.bp
@@ -15,7 +15,6 @@
 //
 cc_binary {
     name: "wifirouter",
-    vendor: true,
     srcs: ["router.cc"],
     static_libs: [
         "libbase",
@@ -29,5 +28,6 @@
         "cuttlefish_common_headers",
         "cuttlefish_glog",
     ],
+    defaults: ["cuttlefish_base"],
 }
 
diff --git a/guest/commands/wifirouter/router.cc b/guest/commands/wifirouter/router.cc
index 47727f3..0763e4b 100644
--- a/guest/commands/wifirouter/router.cc
+++ b/guest/commands/wifirouter/router.cc
@@ -355,10 +355,11 @@
   std::unique_ptr<nlmsghdr, void (*)(nlmsghdr*)> msg(
       reinterpret_cast<nlmsghdr*>(malloc(kMaxSupportedPacketSize)),
       [](nlmsghdr* h) { free(h); });
-  int64_t size = recv(client, msg.get(), kMaxSupportedPacketSize, 0);
+  ssize_t size = recv(client, msg.get(), kMaxSupportedPacketSize, 0);
 
   // Invalid message or no data -> client invalid or disconnected.
-  if (size == 0 || size != msg->nlmsg_len || size < sizeof(nlmsghdr)) {
+  if (size == 0 || size != static_cast<ssize_t>(msg->nlmsg_len) ||
+      size < static_cast<ssize_t>(sizeof(nlmsghdr))) {
     return false;
   }
 
diff --git a/guest/frontend/vnc_server/Android.mk b/guest/frontend/vnc_server/Android.mk
index 2e676ac..6f62250 100644
--- a/guest/frontend/vnc_server/Android.mk
+++ b/guest/frontend/vnc_server/Android.mk
@@ -50,11 +50,7 @@
 LOCAL_CFLAGS := \
     $(VSOC_VERSION_CFLAGS) \
     -std=gnu++11 \
-    -Wall -Werror \
-    -Wno-error-unused -Wno-error=unused-parameter \
-    -Wno-attributes
-
-LOCAL_CFLAGS += -Wno-error=implicit-exception-spec-mismatch
+    -Wall -Werror
 
 LOCAL_SHARED_LIBRARIES := \
     $(LIBJPEG_TURBO_NAME) \
diff --git a/guest/frontend/vnc_server/vnc_client_connection.cpp b/guest/frontend/vnc_server/vnc_client_connection.cpp
index b551f64..7336d00 100644
--- a/guest/frontend/vnc_server/vnc_client_connection.cpp
+++ b/guest/frontend/vnc_server/vnc_client_connection.cpp
@@ -497,7 +497,8 @@
   virtual_inputs_->HandlePointerEvent(button_mask, x_pos, y_pos);
 }
 
-void VncClientConnection::UpdateAccelerometer(float x, float y, float z) {
+void VncClientConnection::UpdateAccelerometer(float /*x*/, float /*y*/,
+                                              float /*z*/) {
   // TODO(jemoreira): Implement when vsoc sensor hal is updated
 }
 
diff --git a/guest/vsoc/lib/Android.mk b/guest/vsoc/lib/Android.mk
index 5ea78d7..2072415 100644
--- a/guest/vsoc/lib/Android.mk
+++ b/guest/vsoc/lib/Android.mk
@@ -23,7 +23,7 @@
     device/google/cuttlefish_common \
     device/google/cuttlefish_kernel
 
-LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING
+LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING -Werror -Wall
 
 LOCAL_STATIC_LIBRARIES := \
     libgtest
diff --git a/guest/vsoc/lib/guest_region_e2e_test.cpp b/guest/vsoc/lib/guest_region_e2e_test.cpp
index 62d98f6..2dcce74 100644
--- a/guest/vsoc/lib/guest_region_e2e_test.cpp
+++ b/guest/vsoc/lib/guest_region_e2e_test.cpp
@@ -78,7 +78,7 @@
 template <typename View>
 void CheckPeerStrings(View* in) {
   size_t num_data = in->string_size();
-  EXPECT_LE(2, num_data);
+  EXPECT_LE(2U, num_data);
   for (size_t i = 0; i < num_data; ++i) {
     EXPECT_STREQ(View::Layout::host_pattern, in->host_string(i));
   }
diff --git a/host/frontend/vnc_server/frame_buffer_watcher.cpp b/host/frontend/vnc_server/frame_buffer_watcher.cpp
index a09269a..bc6b892 100644
--- a/host/frontend/vnc_server/frame_buffer_watcher.cpp
+++ b/host/frontend/vnc_server/frame_buffer_watcher.cpp
@@ -69,8 +69,8 @@
   Message rotated(raw.size(), 0xAA);
   for (std::uint16_t i = 0; i < w; ++i) {
     for (std::uint16_t j = 0; j < h; ++j) {
-      auto to = (i * h + j) * BytesPerPixel();
-      auto from = (w - (i + 1) + w * j) * BytesPerPixel();
+      size_t to = (i * h + j) * BytesPerPixel();
+      size_t from = (w - (i + 1) + w * j) * BytesPerPixel();
       CHECK(from < raw.size());
       CHECK(to < rotated.size());
       std::memcpy(&rotated[to], &raw[from], BytesPerPixel());
diff --git a/host/frontend/vnc_server/virtual_input_device.cpp b/host/frontend/vnc_server/virtual_input_device.cpp
index 66cedc2..eacec38 100644
--- a/host/frontend/vnc_server/virtual_input_device.cpp
+++ b/host/frontend/vnc_server/virtual_input_device.cpp
@@ -37,7 +37,7 @@
 // VirtualButton Support
 //////////////////////////
 
-void VirtualButton::HandleButtonPressEvent(bool button_down) {
+void VirtualButton::HandleButtonPressEvent(bool /*button_down*/) {
   SendCommand(std::string("key ") + "down " + input_keycode_ + "\n");
 }
 
diff --git a/host/frontend/vnc_server/virtual_inputs.cpp b/host/frontend/vnc_server/virtual_inputs.cpp
index 369fa96..30f8638 100644
--- a/host/frontend/vnc_server/virtual_inputs.cpp
+++ b/host/frontend/vnc_server/virtual_inputs.cpp
@@ -58,7 +58,8 @@
 }
 
 bool VirtualInputs::SendMonkeyComand(std::string cmd) {
-  return monkey_socket_->Send(cmd.c_str(), cmd.size(), 0) == cmd.size();
+  return static_cast<size_t>(
+             monkey_socket_->Send(cmd.c_str(), cmd.size(), 0)) == cmd.size();
   // TODO(jemoreira): If monkey is going to be used for a long time it may be
   // useful to check the response to this commands.
 }
diff --git a/host/frontend/vnc_server/vnc_client_connection.cpp b/host/frontend/vnc_server/vnc_client_connection.cpp
index 8f44a97..62cb90a 100644
--- a/host/frontend/vnc_server/vnc_client_connection.cpp
+++ b/host/frontend/vnc_server/vnc_client_connection.cpp
@@ -514,7 +514,8 @@
   virtual_inputs_->HandlePointerEvent(button_mask, x_pos, y_pos);
 }
 
-void VncClientConnection::UpdateAccelerometer(float x, float y, float z) {
+void VncClientConnection::UpdateAccelerometer(float /*x*/, float /*y*/,
+                                              float /*z*/) {
   // // Discard the event if we don't have a connection to the HAL.
   // if (!sensor_event_hal_->IsOpen()) {
   //   LOG(ERROR) << "sensor event client not open";
diff --git a/host/libs/config/guest_config.cpp b/host/libs/config/guest_config.cpp
index 6cd1528..049c55d 100644
--- a/host/libs/config/guest_config.cpp
+++ b/host/libs/config/guest_config.cpp
@@ -20,6 +20,7 @@
 
 #include <gflags/gflags.h>
 #include <glog/logging.h>
+#include <libxml/tree.h>
 #include "host/libs/config/host_config.h"
 
 std::string g_default_libvirt_domain{vsoc::GetPerInstanceDefault("cvd-")};
diff --git a/host/libs/config/guest_config.h b/host/libs/config/guest_config.h
index eaf8ff6..ff7432f 100644
--- a/host/libs/config/guest_config.h
+++ b/host/libs/config/guest_config.h
@@ -15,7 +15,6 @@
  */
 #pragma once
 
-#include <libxml/tree.h>
 #include <memory>
 #include <string>
 
diff --git a/host/libs/ivserver/hald_client_test.cc b/host/libs/ivserver/hald_client_test.cc
index 434f153..a8c5bbb 100644
--- a/host/libs/ivserver/hald_client_test.cc
+++ b/host/libs/ivserver/hald_client_test.cc
@@ -111,8 +111,8 @@
 
     int32_t proto_version;
     EXPECT_EQ(sizeof(proto_version),
-              test_socket_->Recv(&proto_version, sizeof(proto_version),
-                                 MSG_NOSIGNAL));
+              static_cast<size_t>(test_socket_->Recv(
+                  &proto_version, sizeof(proto_version), MSG_NOSIGNAL)));
 
     test_socket_->Send(&size, sizeof(size), MSG_NOSIGNAL);
     thread.join();
@@ -148,14 +148,15 @@
   });
 
   int32_t proto_version;
-  EXPECT_EQ(
-      sizeof(proto_version),
-      test_socket_->Recv(&proto_version, sizeof(proto_version), MSG_NOSIGNAL));
+  EXPECT_EQ(sizeof(proto_version),
+            static_cast<size_t>(test_socket_->Recv(
+                &proto_version, sizeof(proto_version), MSG_NOSIGNAL)));
 
   uint16_t size = test_location.size();
-  EXPECT_EQ(sizeof(size),
-            test_socket_->Send(&size, sizeof(size), MSG_NOSIGNAL));
-  EXPECT_EQ(size, test_socket_->Send(test_location.data(), size, MSG_NOSIGNAL));
+  EXPECT_EQ(sizeof(size), static_cast<size_t>(test_socket_->Send(
+                              &size, sizeof(size), MSG_NOSIGNAL)));
+  EXPECT_EQ(size, static_cast<size_t>(test_socket_->Send(test_location.data(),
+                                                         size, MSG_NOSIGNAL)));
 
   // TODO(ender): delete this once no longer necessary. Currently, absence of
   // payload makes RecvMsgAndFDs hang forever.
diff --git a/host/libs/usbip/client.cpp b/host/libs/usbip/client.cpp
index 7860f24..7f5534a 100644
--- a/host/libs/usbip/client.cpp
+++ b/host/libs/usbip/client.cpp
@@ -15,6 +15,8 @@
  */
 #include "host/libs/usbip/client.h"
 
+#include <arpa/inet.h>
+
 #include <glog/logging.h>
 #include <iostream>
 
@@ -24,6 +26,103 @@
 namespace vadb {
 namespace usbip {
 
+// NetToHost and HostToNet are used to reduce risk of copy/paste errors and to
+// provide uniform method of converting messages between different endian types.
+namespace {
+
+uint32_t NetToHost(uint32_t t) { return ntohl(t); }
+
+Command NetToHost(Command t) { return static_cast<Command>(ntohl(t)); }
+
+Direction NetToHost(Direction t) { return static_cast<Direction>(ntohl(t)); }
+
+uint32_t NetToHost(uint16_t t) { return ntohs(t); }
+
+CmdHeader NetToHost(const CmdHeader& t) {
+  CmdHeader rval = t;
+  rval.command = NetToHost(t.command);
+  rval.seq_num = NetToHost(t.seq_num);
+  rval.bus_num = NetToHost(t.bus_num);
+  rval.dev_num = NetToHost(t.dev_num);
+  rval.direction = NetToHost(t.direction);
+  rval.endpoint = NetToHost(t.endpoint);
+  return rval;
+}
+
+CmdReqSubmit NetToHost(const CmdReqSubmit& t) {
+  CmdReqSubmit rval = t;
+  rval.transfer_flags = NetToHost(t.transfer_flags);
+  rval.transfer_buffer_length = NetToHost(t.transfer_buffer_length);
+  rval.start_frame = NetToHost(t.start_frame);
+  rval.number_of_packets = NetToHost(t.number_of_packets);
+  rval.deadline_interval = NetToHost(t.deadline_interval);
+  return rval;
+}
+
+CmdReqUnlink NetToHost(const CmdReqUnlink& t) {
+  CmdReqUnlink rval = t;
+  rval.seq_num = NetToHost(t.seq_num);
+  return rval;
+}
+
+uint32_t HostToNet(uint32_t t) { return htonl(t); }
+
+Command HostToNet(const Command t) { return static_cast<Command>(htonl(t)); }
+
+Direction HostToNet(Direction t) { return static_cast<Direction>(htonl(t)); }
+
+uint16_t HostToNet(uint16_t t) { return htons(t); }
+
+CmdHeader HostToNet(const CmdHeader& t) {
+  CmdHeader rval = t;
+  rval.command = HostToNet(t.command);
+  rval.seq_num = HostToNet(t.seq_num);
+  rval.bus_num = HostToNet(t.bus_num);
+  rval.dev_num = HostToNet(t.dev_num);
+  rval.direction = HostToNet(t.direction);
+  rval.endpoint = HostToNet(t.endpoint);
+  return rval;
+}
+
+CmdRepSubmit HostToNet(const CmdRepSubmit& t) {
+  CmdRepSubmit rval = t;
+  rval.status = HostToNet(t.status);
+  rval.actual_length = HostToNet(t.actual_length);
+  rval.start_frame = HostToNet(t.start_frame);
+  rval.number_of_packets = HostToNet(t.number_of_packets);
+  rval.error_count = HostToNet(t.error_count);
+  return rval;
+}
+
+CmdRepUnlink HostToNet(const CmdRepUnlink& t) {
+  CmdRepUnlink rval = t;
+  rval.status = HostToNet(t.status);
+  return rval;
+}
+
+// Converts data to network order and sends it to the USB/IP client.
+// Returns true, if message was sent successfully.
+template <typename T>
+bool SendUSBIPMsg(const cvd::SharedFD& fd, const T& data) {
+  T net = HostToNet(data);
+  return fd->Send(&net, sizeof(T), MSG_NOSIGNAL) == sizeof(T);
+}
+
+// Receive message from USB/IP client.
+// After message is received, it's updated to match host endian.
+// Returns true, if message was received successfully.
+template <typename T>
+bool RecvUSBIPMsg(const cvd::SharedFD& fd, T* data) {
+  T net;
+  bool res = fd->Recv(&net, sizeof(T), MSG_NOSIGNAL) == sizeof(T);
+  if (res) {
+    *data = NetToHost(net);
+  }
+  return res;
+}
+
+}  // namespace
+
 void Client::BeforeSelect(cvd::SharedFDSet* fd_read) const {
   fd_read->Set(fd_);
 }
@@ -88,7 +187,7 @@
   if (device) {
     // Read data to be sent to device, if specified.
     if (is_host_to_device && payload_length) {
-      int32_t got = 0;
+      size_t got = 0;
       // Make sure we read everything.
       while (got < payload.size()) {
         auto read =
@@ -163,7 +262,8 @@
   }
 
   if (!is_host_to_device && data.size() > 0) {
-    if (fd_->Send(data.data(), data.size(), MSG_NOSIGNAL) != data.size()) {
+    if (static_cast<size_t>(
+            fd_->Send(data.data(), data.size(), MSG_NOSIGNAL)) != data.size()) {
       LOG(ERROR) << "Failed to send response payload: " << fd_->StrError();
       return;
     }
diff --git a/host/libs/usbip/messages.cpp b/host/libs/usbip/messages.cpp
index 27af986..041fd96 100644
--- a/host/libs/usbip/messages.cpp
+++ b/host/libs/usbip/messages.cpp
@@ -38,100 +38,6 @@
               "USB/IP command + header must be exactly 48 bytes.");
 }  // namespace
 
-// NetToHost and HostToNet are used to reduce risk of copy/paste errors and to
-// provide uniform method of converting messages between different endian types.
-namespace internal {
-
-template <>
-void NetToHost(uint32_t* t) {
-  *t = ntohl(*t);
-}
-
-template <>
-void NetToHost(Command* t) {
-  *t = static_cast<Command>(ntohl(*t));
-}
-
-template <>
-void NetToHost(Direction* t) {
-  *t = static_cast<Direction>(ntohl(*t));
-}
-
-template <>
-void NetToHost(uint16_t* t) {
-  *t = ntohs(*t);
-}
-
-template <>
-void NetToHost(CmdHeader* t) {
-  NetToHost(&t->command);
-  NetToHost(&t->seq_num);
-  NetToHost(&t->bus_num);
-  NetToHost(&t->dev_num);
-  NetToHost(&t->direction);
-  NetToHost(&t->endpoint);
-}
-
-template <>
-void NetToHost(CmdReqSubmit* t) {
-  NetToHost(&t->transfer_flags);
-  NetToHost(&t->transfer_buffer_length);
-  NetToHost(&t->start_frame);
-  NetToHost(&t->number_of_packets);
-  NetToHost(&t->deadline_interval);
-}
-
-template <>
-void NetToHost(CmdReqUnlink* t) {
-  NetToHost(&t->seq_num);
-}
-
-template <>
-void HostToNet(uint32_t* t) {
-  *t = htonl(*t);
-}
-
-template <>
-void HostToNet(Command* t) {
-  *t = static_cast<Command>(htonl(*t));
-}
-
-template <>
-void HostToNet(Direction* t) {
-  *t = static_cast<Direction>(htonl(*t));
-}
-
-template <>
-void HostToNet(uint16_t* t) {
-  *t = htons(*t);
-}
-
-template <>
-void HostToNet(CmdHeader* t) {
-  HostToNet(&t->command);
-  HostToNet(&t->seq_num);
-  HostToNet(&t->bus_num);
-  HostToNet(&t->dev_num);
-  HostToNet(&t->direction);
-  HostToNet(&t->endpoint);
-}
-
-template <>
-void HostToNet(CmdRepSubmit* t) {
-  HostToNet(&t->status);
-  HostToNet(&t->actual_length);
-  HostToNet(&t->start_frame);
-  HostToNet(&t->number_of_packets);
-  HostToNet(&t->error_count);
-}
-
-template <>
-void HostToNet(CmdRepUnlink* t) {
-  HostToNet(&t->status);
-}
-
-}  // namespace internal
-
 std::ostream& operator<<(std::ostream& out, const CmdHeader& header) {
   out << "CmdHeader\n";
   out << "\t\tcmd:\t" << header.command << '\n';
diff --git a/host/libs/usbip/messages.h b/host/libs/usbip/messages.h
index 8941df1..8594465 100644
--- a/host/libs/usbip/messages.h
+++ b/host/libs/usbip/messages.h
@@ -24,34 +24,6 @@
 // https://www.kernel.org/doc/Documentation/usb/usbip_protocol.txt
 namespace vadb {
 namespace usbip {
-namespace internal {
-// Rotate endianness of the data to match protocol.
-template <typename T>
-void HostToNet(T* data);
-template <typename T>
-void NetToHost(T* data);
-}  // namespace internal
-
-// Send message to USB/IP client.
-// Accept data by value and modify it to match net endian locally.
-// Returns true, if message was sent successfully.
-template <typename T>
-bool SendUSBIPMsg(const cvd::SharedFD& fd, T data) {
-  internal::HostToNet(&data);
-  return fd->Send(&data, sizeof(T), MSG_NOSIGNAL) == sizeof(T);
-}
-
-// Receive message from USB/IP client.
-// After message is received, it's updated to match host endian.
-// Returns true, if message was received successfully.
-template <typename T>
-bool RecvUSBIPMsg(const cvd::SharedFD& fd, T* data) {
-  bool res = fd->Recv(data, sizeof(T), MSG_NOSIGNAL) == sizeof(T);
-  if (res) {
-    internal::NetToHost(data);
-  }
-  return res;
-}
 
 ////////////////////////////////////////////////////////////////////////////////
 // COMMANDS
diff --git a/host/libs/vadb/usb_cmd_attach.cpp b/host/libs/vadb/usb_cmd_attach.cpp
index 02ade80..8e9cbf7 100644
--- a/host/libs/vadb/usb_cmd_attach.cpp
+++ b/host/libs/vadb/usb_cmd_attach.cpp
@@ -27,7 +27,7 @@
   return true;
 }
 
-bool USBCmdAttach::OnResponse(bool is_success, const cvd::SharedFD& data) {
+bool USBCmdAttach::OnResponse(bool is_success, const cvd::SharedFD& /*data*/) {
   if (!is_success) return false;
   LOG(INFO) << "Attach successful.";
   return true;
diff --git a/host/libs/vadb/usb_cmd_control_transfer.cpp b/host/libs/vadb/usb_cmd_control_transfer.cpp
index 643d416..c293057 100644
--- a/host/libs/vadb/usb_cmd_control_transfer.cpp
+++ b/host/libs/vadb/usb_cmd_control_transfer.cpp
@@ -41,7 +41,8 @@
 
   if ((req_.type & 0x80) == 0) {
     if (data_.size() > 0) {
-      if (fd->Write(data_.data(), data_.size()) != data_.size()) {
+      if (static_cast<size_t>(fd->Write(data_.data(), data_.size())) !=
+          data_.size()) {
         LOG(ERROR) << "Short write: " << fd->StrError();
         return false;
       }
diff --git a/host/libs/vadb/usb_cmd_data_transfer.cpp b/host/libs/vadb/usb_cmd_data_transfer.cpp
index 7503374..d088303 100644
--- a/host/libs/vadb/usb_cmd_data_transfer.cpp
+++ b/host/libs/vadb/usb_cmd_data_transfer.cpp
@@ -38,7 +38,8 @@
   }
 
   if (req_.is_host_to_device && data_.size() > 0) {
-    if (fd->Write(data_.data(), data_.size()) != data_.size()) {
+    if (static_cast<size_t>(fd->Write(data_.data(), data_.size())) !=
+        data_.size()) {
       LOG(ERROR) << "Short write: " << fd->StrError();
       return false;
     }
diff --git a/host/libs/vadb/usb_cmd_device_list.cpp b/host/libs/vadb/usb_cmd_device_list.cpp
index ce561de..ce07d23 100644
--- a/host/libs/vadb/usb_cmd_device_list.cpp
+++ b/host/libs/vadb/usb_cmd_device_list.cpp
@@ -18,7 +18,7 @@
 #include "host/libs/vadb/usb_cmd_device_list.h"
 
 namespace vadb {
-bool USBCmdDeviceList::OnRequest(const cvd::SharedFD& data) {
+bool USBCmdDeviceList::OnRequest(const cvd::SharedFD& /*data*/) {
   LOG(INFO) << "Requesting device list from Cuttlefish...";
   // No action required.
   return true;
@@ -46,8 +46,9 @@
     }
 
     ifaces.resize(dev.num_interfaces);
-    if (fd->Read(ifaces.data(),
-                 ifaces.size() * sizeof(usb_forward::InterfaceInfo)) !=
+    if (static_cast<size_t>(
+            fd->Read(ifaces.data(),
+                     ifaces.size() * sizeof(usb_forward::InterfaceInfo))) !=
         ifaces.size() * sizeof(usb_forward::InterfaceInfo)) {
       LOG(ERROR) << "Short read: " << fd->StrError();
       return false;
diff --git a/host/libs/vadb/usb_cmd_heartbeat.cpp b/host/libs/vadb/usb_cmd_heartbeat.cpp
index 59138bc..80ec1cf 100644
--- a/host/libs/vadb/usb_cmd_heartbeat.cpp
+++ b/host/libs/vadb/usb_cmd_heartbeat.cpp
@@ -19,9 +19,10 @@
 #include "host/libs/vadb/usb_cmd_heartbeat.h"
 
 namespace vadb {
-bool USBCmdHeartbeat::OnRequest(const cvd::SharedFD& fd) { return true; }
+bool USBCmdHeartbeat::OnRequest(const cvd::SharedFD& /*fd*/) { return true; }
 
-bool USBCmdHeartbeat::OnResponse(bool is_success, const cvd::SharedFD& data) {
+bool USBCmdHeartbeat::OnResponse(bool is_success,
+                                 const cvd::SharedFD& /*data*/) {
   callback_(is_success);
   return true;
 }
diff --git a/host/vsoc/lib/host_region_e2e_test.cpp b/host/vsoc/lib/host_region_e2e_test.cpp
index a707838..64cb2a6 100644
--- a/host/vsoc/lib/host_region_e2e_test.cpp
+++ b/host/vsoc/lib/host_region_e2e_test.cpp
@@ -40,7 +40,7 @@
 template <typename View>
 void SetHostStrings(View* in) {
   size_t num_data = in->string_size();
-  EXPECT_LE(2, num_data);
+  EXPECT_LE(static_cast<size_t>(2), num_data);
   for (size_t i = 0; i < num_data; ++i) {
     EXPECT_TRUE(!in->host_string(i)[0] ||
                 !strcmp(in->host_string(i), View::Layout::host_pattern));
@@ -52,7 +52,7 @@
 template <typename View>
 void CheckPeerStrings(View* in) {
   size_t num_data = in->string_size();
-  EXPECT_LE(2, num_data);
+  EXPECT_LE(static_cast<size_t>(2), num_data);
   for (size_t i = 0; i < num_data; ++i) {
     EXPECT_STREQ(View::Layout::guest_pattern, in->guest_string(i));
   }
diff --git a/host/vsoc/lib/region_control.cpp b/host/vsoc/lib/region_control.cpp
index 1ad94a5..fa98d61 100644
--- a/host/vsoc/lib/region_control.cpp
+++ b/host/vsoc/lib/region_control.cpp
@@ -50,10 +50,11 @@
         outgoing_interrupt_fd_{outgoing_interrupt_fd},
         shared_memory_fd_{shared_memory_fd} {}
 
-  int CreateFdScopedPermission(const char* managed_region_name,
-                               vsoc_reg_off_t owner_offset, uint32_t owned_val,
-                               vsoc_reg_off_t begin_offset,
-                               vsoc_reg_off_t end_offset) override {
+  int CreateFdScopedPermission(const char* /*managed_region_name*/,
+                               vsoc_reg_off_t /*owner_offset*/,
+                               uint32_t /*owned_val*/,
+                               vsoc_reg_off_t /*begin_offset*/,
+                               vsoc_reg_off_t /*end_offset*/) override {
     return -1;
   }