Skip to content

Commit

Permalink
refactor(server_core): 🚨 Fix lints and fail CI on clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp committed Jan 18, 2025
1 parent f69b428 commit e0bad43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions alvr/graphics/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ impl StreamRenderer {
}
}

/// # Safety
/// `hardware_buffer` must be a valid pointer to a ANativeWindowBuffer.
pub unsafe fn render(&self, hardware_buffer: *mut c_void, view_params: [StreamViewParams; 2]) {
// if hardware_buffer is available copy stream to staging texture
if !hardware_buffer.is_null() {
Expand Down
5 changes: 3 additions & 2 deletions alvr/server_core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,9 @@ pub fn handshake_loop(ctx: Arc<ConnectionContext>, lifecycle_state: Arc<RwLock<L
}
};

if let WiredConnectionStatus::NotReady(m) = status {
dbg_connection!("handshake_loop: Wired connection not ready: {m}");
#[cfg_attr(not(debug_assertions), allow(unused_variables))]
if let WiredConnectionStatus::NotReady(s) = status {
dbg_connection!("handshake_loop: Wired connection not ready: {s}");
thread::sleep(RETRY_CONNECT_MIN_INTERVAL);
continue;
}
Expand Down
26 changes: 17 additions & 9 deletions alvr/xtask/src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ pub fn clippy_ci() {
let stream = Deserializer::from_slice(&out.stdout).into_iter::<Value>();

// https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages
for message in stream.filter_map(|msg| {
let msg = msg.unwrap();
let messages = stream
.filter_map(|msg| {
let msg = msg.unwrap();

if msg.get("reason")? == "compiler-message" {
msg.get("message").map(|x| x.to_owned())
} else {
None
}
}) {
let msg: CompilerMessage = json::from_value(message).unwrap();
if msg.get("reason")? == "compiler-message" {
msg.get("message").map(|x| x.to_owned())
} else {
None
}
})
.collect::<Vec<_>>();

for message in &messages {
let msg: CompilerMessage = json::from_value(message.clone()).unwrap();

if msg.message_type != "diagnostic" {
continue;
Expand Down Expand Up @@ -100,4 +104,8 @@ pub fn clippy_ci() {
if !out.status.success() {
panic!("ci clippy didn't exit with 0 code, propagating failure");
}

if messages.is_empty() {
panic!("ci clippy produced warnings");
}
}

0 comments on commit e0bad43

Please sign in to comment.