Skip to content

Commit

Permalink
Handle all must_uses
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Aug 3, 2024
1 parent 6a6ad23 commit fcf9388
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 133 deletions.
16 changes: 8 additions & 8 deletions cairo-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ where
{
let window = conn.generate_id()?;
let colormap = conn.generate_id()?;
conn.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual_id)?;
let _ = conn.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual_id)?;
let win_aux = CreateWindowAux::new()
.event_mask(EventMask::EXPOSURE | EventMask::STRUCTURE_NOTIFY)
.background_pixel(x11rb::NONE)
.border_pixel(screen.black_pixel)
.colormap(colormap);
conn.create_window(
let _ = conn.create_window(
depth,
window,
screen.root,
Expand All @@ -155,36 +155,36 @@ where
)?;

let title = "Simple Window";
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
window,
AtomEnum::WM_NAME,
AtomEnum::STRING,
title.as_bytes(),
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
window,
atoms._NET_WM_NAME,
atoms.UTF8_STRING,
title.as_bytes(),
)?;
conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
window,
atoms.WM_PROTOCOLS,
AtomEnum::ATOM,
&[atoms.WM_DELETE_WINDOW],
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
window,
AtomEnum::WM_CLASS,
AtomEnum::STRING,
b"simple_window\0simple_window\0",
)?;

conn.map_window(window)?;
let _ = conn.map_window(window)?;
Ok(window)
}

Expand Down Expand Up @@ -268,7 +268,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
width.into(),
height.into(),
)
.unwrap();
.unwrap();

loop {
conn.flush()?;
Expand Down
14 changes: 7 additions & 7 deletions x11rb/examples/display_ppm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ fn create_window(
let pixmap_id = conn.generate_id()?;
let gc_id = conn.generate_id()?;

conn.create_gc(
let _ = conn.create_gc(
gc_id,
screen.root,
&CreateGCAux::default().graphics_exposures(0),
)?;
conn.create_pixmap(
let _ = conn.create_pixmap(
screen.root_depth,
pixmap_id,
screen.root,
image.width(),
image.height(),
)?;
image.put(conn, pixmap_id, gc_id, 0, 0)?;
conn.free_gc(gc_id)?;
let _ = conn.free_gc(gc_id)?;

conn.create_window(
let _ = conn.create_window(
screen.root_depth,
win_id,
screen.root,
Expand All @@ -57,9 +57,9 @@ fn create_window(
0,
&CreateWindowAux::default().background_pixmap(pixmap_id),
)?;
conn.free_pixmap(pixmap_id)?;
let _ = conn.free_pixmap(pixmap_id)?;

conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
win_id,
atoms.WM_PROTOCOLS,
Expand Down Expand Up @@ -137,7 +137,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let atoms = Atoms::new(conn)?.reply()?;
let win_id = create_window(conn, screen, &atoms, &image)?;
conn.map_window(win_id)?;
let _ = conn.map_window(win_id)?;

util::start_timeout_thread(conn1.clone(), win_id);

Expand Down
6 changes: 3 additions & 3 deletions x11rb/examples/generic_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a window
let win_id = conn.generate_id()?;
let win_aux = CreateWindowAux::new().background_pixel(screen.white_pixel);
conn.create_window(
let _ = conn.create_window(
COPY_DEPTH_FROM_PARENT,
win_id,
screen.root,
Expand All @@ -41,15 +41,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// Ask for present ConfigureNotify events
let event_id = conn.generate_id()?;
present::select_input(
let _ = present::select_input(
&conn,
event_id,
win_id,
present::EventMask::CONFIGURE_NOTIFY,
)?;

// Cause an event
conn.configure_window(win_id, &ConfigureWindowAux::new().width(20))?;
let _ = conn.configure_window(win_id, &ConfigureWindowAux::new().width(20))?;

// Wait for the event
conn.flush()?;
Expand Down
22 changes: 11 additions & 11 deletions x11rb/examples/hypnomoire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let white = conn.generate_id()?;
let black = conn.generate_id()?;

conn.create_gc(
let _ = conn.create_gc(
white,
screen.root,
&CreateGCAux::new()
.graphics_exposures(0)
.foreground(screen.white_pixel),
)?;
conn.create_gc(
let _ = conn.create_gc(
black,
screen.root,
&CreateGCAux::new()
Expand Down Expand Up @@ -93,7 +93,7 @@ fn run<C: Connection>(
guard.angle_velocity = 0.05;
}

conn.create_window(
let _ = conn.create_window(
COPY_DEPTH_FROM_PARENT,
window,
screen.root,
Expand All @@ -111,16 +111,16 @@ fn run<C: Connection>(
)
.do_not_propogate_mask(EventMask::BUTTON_PRESS),
)?;
conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
window,
wm_protocols,
AtomEnum::ATOM,
&[wm_delete_window],
)?;
conn.map_window(window)?;
let _ = conn.map_window(window)?;

conn.create_pixmap(
let _ = conn.create_pixmap(
screen.root_depth,
pixmap,
window,
Expand All @@ -133,7 +133,7 @@ fn run<C: Connection>(
width: default_size,
height: default_size,
};
conn.poly_fill_rectangle(pixmap, white, &[rect])?;
let _ = conn.poly_fill_rectangle(pixmap, white, &[rect])?;

let mut theta: f64 = 0.0;
let radius = f64::from(default_size) + 1.0;
Expand All @@ -151,7 +151,7 @@ fn run<C: Connection>(
},
Point { x, y },
];
conn.poly_line(CoordMode::PREVIOUS, pixmap, black, &lines)?;
let _ = conn.poly_line(CoordMode::PREVIOUS, pixmap, black, &lines)?;

let (sin, cos) = (theta + LAG).sin_cos();
let (x, y) = ((radius * cos) as i16, (radius * sin) as i16);
Expand All @@ -162,9 +162,9 @@ fn run<C: Connection>(
},
Point { x, y },
];
conn.poly_line(CoordMode::PREVIOUS, pixmap, white, &lines)?;
let _ = conn.poly_line(CoordMode::PREVIOUS, pixmap, white, &lines)?;

conn.copy_area(
let _ = conn.copy_area(
pixmap,
window,
white,
Expand Down Expand Up @@ -209,7 +209,7 @@ where
Event::Expose(event) => {
if let Some(state) = find_window_by_id(&windows, event.window) {
let state = state.lock().unwrap();
conn.copy_area(
let _ = conn.copy_area(
state.pixmap,
state.window,
white,
Expand Down
2 changes: 1 addition & 1 deletion x11rb/examples/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Some(timeout) => {
std::thread::spawn(move || {
std::thread::sleep(std::time::Duration::from_secs(timeout));
ctrl_conn.record_disable_context(rc).unwrap();
let _ = ctrl_conn.record_disable_context(rc).unwrap();
ctrl_conn.sync().unwrap();
});
}
Expand Down
12 changes: 6 additions & 6 deletions x11rb/examples/shared_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn get_shared_memory_content_at_offset<C: Connection>(
_ => panic!("I do not know how to handle depth {}", screen.root_depth),
};
let pixmap = conn.generate_id()?;
conn.shm_create_pixmap(
let _ = conn.shm_create_pixmap(
pixmap,
screen.root,
width,
Expand All @@ -64,7 +64,7 @@ fn get_shared_memory_content_at_offset<C: Connection>(
1,
!0,
)?
.reply()?;
.reply()?;
Ok(image.data)
}

Expand Down Expand Up @@ -100,11 +100,11 @@ fn make_file() -> IOResult<File> {

fn send_fd<C: Connection>(conn: &C, screen_num: usize, file: File) -> Result<(), ReplyOrIdError> {
let shmseg = conn.generate_id()?;
conn.shm_attach_fd(shmseg, OwnedFd::from(file), false)?;
let _ = conn.shm_attach_fd(shmseg, OwnedFd::from(file), false)?;

use_shared_mem(conn, screen_num, shmseg)?;

conn.shm_detach(shmseg)?;
let _ = conn.shm_detach(shmseg)?;

Ok(())
}
Expand All @@ -128,7 +128,7 @@ fn receive_fd<C: Connection>(conn: &C, screen_num: usize) -> Result<(), ReplyOrI
)
};
if addr == MAP_FAILED {
conn.shm_detach(shmseg)?;
let _ = conn.shm_detach(shmseg)?;
return Err(ConnectionError::InsufficientMemory.into());
}

Expand All @@ -139,7 +139,7 @@ fn receive_fd<C: Connection>(conn: &C, screen_num: usize) -> Result<(), ReplyOrI

use_shared_mem(conn, screen_num, shmseg)?;

conn.shm_detach(shmseg)?;
let _ = conn.shm_detach(shmseg)?;
// Let's ignore the munmap() that we should do here

Ok(())
Expand Down
18 changes: 9 additions & 9 deletions x11rb/examples/simple_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let (mut width, mut height) = (100, 100);

conn.create_window(
let _ = conn.create_window(
screen.root_depth,
win_id,
screen.root,
Expand All @@ -71,35 +71,35 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
util::start_timeout_thread(conn1.clone(), win_id);

let title = "Simple Window";
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
win_id,
AtomEnum::WM_NAME,
AtomEnum::STRING,
title.as_bytes(),
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
win_id,
atoms._NET_WM_NAME,
atoms.UTF8_STRING,
title.as_bytes(),
)?;
conn.change_property32(
let _ = conn.change_property32(
PropMode::REPLACE,
win_id,
atoms.WM_PROTOCOLS,
AtomEnum::ATOM,
&[atoms.WM_DELETE_WINDOW],
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
win_id,
AtomEnum::WM_CLASS,
AtomEnum::STRING,
b"simple_window\0simple_window\0",
)?;
conn.change_property8(
let _ = conn.change_property8(
PropMode::REPLACE,
win_id,
AtomEnum::WM_CLIENT_MACHINE,
Expand All @@ -116,9 +116,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.reply()?;
assert_eq!(reply.value, title.as_bytes());

conn.create_gc(gc_id, win_id, &gc_aux)?;
let _ = conn.create_gc(gc_id, win_id, &gc_aux)?;

conn.map_window(win_id)?;
let _ = conn.map_window(win_id)?;

conn.flush()?;

Expand Down Expand Up @@ -146,7 +146,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
y: -10,
},
];
conn.poly_line(CoordMode::ORIGIN, win_id, gc_id, &points)?;
let _ = conn.poly_line(CoordMode::ORIGIN, win_id, gc_id, &points)?;
conn.flush()?;
}
}
Expand Down
Loading

0 comments on commit fcf9388

Please sign in to comment.