From 4e14f1dd771cdaa430f1463ca9f59c3270edc22b Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Wed, 17 Jul 2024 09:14:32 -0400
Subject: Avoid signed bitwise operations

---
 src/JackLibDriver.cpp |  5 +++--
 src/Legend.cpp        | 10 +++++-----
 src/Patchage.cpp      | 10 +++++-----
 3 files changed, 13 insertions(+), 12 deletions(-)

(limited to 'src')

diff --git a/src/JackLibDriver.cpp b/src/JackLibDriver.cpp
index b0b96a5..411916f 100644
--- a/src/JackLibDriver.cpp
+++ b/src/JackLibDriver.cpp
@@ -196,7 +196,7 @@ PortInfo
 JackLibDriver::get_port_info(const jack_port_t* const port)
 {
   const auto        uuid  = jack_port_uuid(port);
-  const auto        flags = jack_port_flags(port);
+  const auto        flags = static_cast<unsigned>(jack_port_flags(port));
   const std::string name  = jack_port_name(port);
   auto              label = PortNames{name}.port();
 
@@ -281,7 +281,8 @@ JackLibDriver::refresh(const EventSink& sink)
     const char** const peers = jack_port_get_all_connections(_client, port);
 
     if (peers) {
-      if (jack_port_flags(port) & JackPortIsInput) {
+      const auto flags = static_cast<unsigned>(jack_port_flags(port));
+      if (flags & JackPortIsInput) {
         for (auto j = 0U; peers[j]; ++j) {
           connections.emplace(peers[j], ports[i]);
         }
diff --git a/src/Legend.cpp b/src/Legend.cpp
index 5be8545..0733e2f 100644
--- a/src/Legend.cpp
+++ b/src/Legend.cpp
@@ -51,9 +51,9 @@ void
 Legend::add_button(const PortType id, const std::string& label, uint32_t rgba)
 {
   Gdk::Color col;
-  col.set_rgb(((rgba >> 24) & 0xFF) * 0x100,
-              ((rgba >> 16) & 0xFF) * 0x100,
-              ((rgba >> 8) & 0xFF) * 0x100);
+  col.set_rgb(((rgba >> 24U) & 0xFFU) * 0x100U,
+              ((rgba >> 16U) & 0xFFU) * 0x100U,
+              ((rgba >> 8U) & 0xFFU) * 0x100U);
 
   auto* box = new Gtk::HBox();
   auto* but = new Gtk::ColorButton(col);
@@ -74,8 +74,8 @@ Legend::on_color_set(const PortType          id,
 {
   const Gdk::Color col = but->get_color();
   const uint32_t   rgba =
-    (((col.get_red() / 0x100) << 24) | ((col.get_green() / 0x100) << 16) |
-     ((col.get_blue() / 0x100) << 8) | 0xFF);
+    (((col.get_red() / 0x100U) << 24U) | ((col.get_green() / 0x100U) << 16U) |
+     ((col.get_blue() / 0x100U) << 8U) | 0xFFU);
 
   signal_color_changed.emit(id, label, rgba);
 }
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index 94d580e..0a0de82 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -187,11 +187,11 @@ update_labels(GanvNode* node, void* data)
 inline guint
 highlight_color(guint c, guint delta)
 {
-  const guint max_char = 255;
-  const guint r        = MIN((c >> 24) + delta, max_char);
-  const guint g        = MIN(((c >> 16) & 0xFF) + delta, max_char);
-  const guint b        = MIN(((c >> 8) & 0xFF) + delta, max_char);
-  const guint a        = c & 0xFF;
+  const guint max_char = 255U;
+  const guint r        = MIN((c >> 24U) + delta, max_char);
+  const guint g        = MIN(((c >> 16U) & 0xFFU) + delta, max_char);
+  const guint b        = MIN(((c >> 8U) & 0xFFU) + delta, max_char);
+  const guint a        = c & 0xFFU;
 
   return ((r << 24U) | (g << 16U) | (b << 8U) | a);
 }
-- 
cgit v1.2.1