Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ crate-type = ["cdylib", "rlib"]
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "net", "io-util", "macros"] }
bytes = "1"
log = "0.4"
thiserror = "1.0" # Error handling
thiserror = "2.0" # Error handling
des = "0.8" # DES encryption for VNC auth
rand = "0.8" # Random number generation for auth
rand = "0.9" # Random number generation for auth
flate2 = "1.0" # Zlib compression for Tight encoding
rfb-encodings = "0.1.6" # RFB encoding implementations

Expand Down
2 changes: 1 addition & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl VncAuth {
/// A `[u8; 16]` array containing the random challenge bytes.
#[allow(clippy::unused_self)] // Kept as method for API consistency with other VncAuthenticator methods
pub fn generate_challenge(&self) -> [u8; 16] {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
let mut challenge = [0u8; 16];
rng.fill(&mut challenge);
challenge
Expand Down
33 changes: 20 additions & 13 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,13 +1118,15 @@ impl VncClient {
not(feature = "debug-logging"),
allow(unused_variables, unused_assignments)
)]
let mut total_pixels = 0u64;
#[cfg(feature = "debug-logging")]
{
let mut total_pixels = 0u64;
let mut copy_rect_count = 0;
}
#[cfg_attr(
not(feature = "debug-logging"),
allow(unused_variables, unused_assignments)
)]
Comment on lines +1122 to 1129
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variables total_pixels and copy_rect_count are declared inside a block that only exists when the debug-logging feature is enabled, but they are used outside this block (at lines 1162-1163, 1232, 1331, 1715, 1722-1723, and 1749). This will cause a compilation error when the feature is enabled because the variables will go out of scope at line 1125.

The variables should be declared at function scope with the #[cfg(feature = "debug-logging")] attribute applied to each variable declaration, not inside a separate block. Remove the braces and apply the attribute to each let statement individually.

Suggested change
{
let mut total_pixels = 0u64;
let mut copy_rect_count = 0;
}
#[cfg_attr(
not(feature = "debug-logging"),
allow(unused_variables, unused_assignments)
)]
let mut total_pixels = 0u64;
#[cfg_attr(
not(feature = "debug-logging"),
allow(unused_variables, unused_assignments)
)]
#[cfg(feature = "debug-logging")]
let mut copy_rect_count = 0;
#[cfg_attr(
not(feature = "debug-logging"),
allow(unused_variables, unused_assignments)
)]

Copilot uses AI. Check for mistakes.
Comment on lines 1126 to 1129
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This #[cfg_attr] attribute is orphaned and not attached to any code statement. It should be removed since the variables it was intended to suppress warnings for (total_pixels and copy_rect_count) are now conditionally compiled with #[cfg(feature = "debug-logging")].

Copilot uses AI. Check for mistakes.
let mut copy_rect_count = 0;

// Load quality/compression settings atomically
let jpeg_quality = self.jpeg_quality.load(Ordering::Relaxed);
let compression_level = self.compression_level.load(Ordering::Relaxed);
Expand Down Expand Up @@ -1155,9 +1157,11 @@ impl VncClient {
// CopyRect data is just src_x and src_y
response.put_u16(src_x);
response.put_u16(src_y);

total_pixels += u64::from(region.width) * u64::from(region.height);
copy_rect_count += 1;
#[cfg(feature = "debug-logging")]
{
total_pixels += u64::from(region.width) * u64::from(region.height);
copy_rect_count += 1;
}
}
}

Expand Down Expand Up @@ -1223,11 +1227,10 @@ impl VncClient {

rect.write_header(&mut response);
response.extend_from_slice(encoded);

total_pixels += u64::from(*w) * u64::from(*h);

#[cfg(feature = "debug-logging")]
{
total_pixels += u64::from(*w) * u64::from(*h);

rect_count += 1;
}
}
Expand Down Expand Up @@ -1323,8 +1326,10 @@ impl VncClient {

// Write encoder output (background color + subrectangle data)
response.extend_from_slice(&encoded);

total_pixels += u64::from(tile_width) * u64::from(tile_height);
#[cfg(feature = "debug-logging")]
{
total_pixels += u64::from(tile_width) * u64::from(tile_height);
}
}

x += tile_width;
Expand Down Expand Up @@ -1705,8 +1710,10 @@ impl VncClient {
};
rect.write_header(&mut response);
response.extend_from_slice(&encoded);

total_pixels += u64::from(region.width) * u64::from(region.height);
#[cfg(feature = "debug-logging")]
{
total_pixels += u64::from(region.width) * u64::from(region.height);
}
}
}

Expand Down
Loading