Skip to content

Commit

Permalink
Merge pull request #275 from rtbo/rm_warnings
Browse files Browse the repository at this point in the history
remove compilation warnings
  • Loading branch information
rtbo authored Nov 10, 2024
2 parents 8a61bb1 + ae8d97c commit 8623b9e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 68 deletions.
3 changes: 3 additions & 0 deletions build/cg/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ impl DocField {
}
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct DocError {
pub typ: String,
pub text: String,
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct DocSee {
pub typ: String,
pub name: String,
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Doc {
pub brief: Option<String>,
Expand Down
24 changes: 2 additions & 22 deletions build/cg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,13 @@ enum Field {
Expr {
name: String,
typ: String,
wire_off: Expr,
wire_sz: Expr,
expr: Expr,
},
Pad {
wire_off: Expr,
wire_sz: Expr,
},
AlignPad {
wire_off: Expr,
wire_sz: Expr,
},
}
Expand Down Expand Up @@ -560,7 +557,7 @@ impl CodeGen {
writeln!(out, " unsafe {{")?;
writeln!(
out,
" xcb_prefetch_extension_data(conn.get_raw_conn(), &mut FFI_EXT as *mut _);"
" xcb_prefetch_extension_data(conn.get_raw_conn(), std::ptr::addr_of_mut!(FFI_EXT));"
)?;
writeln!(out, " }}")?;
writeln!(out, "}}")?;
Expand Down Expand Up @@ -588,7 +585,7 @@ impl CodeGen {
writeln!(out, " unsafe {{")?;
writeln!(
out,
" let reply = xcb_get_extension_data(conn.get_raw_conn(), &mut FFI_EXT as *mut _);"
" let reply = xcb_get_extension_data(conn.get_raw_conn(), std::ptr::addr_of_mut!(FFI_EXT));"
)?;
writeln!(
out,
Expand Down Expand Up @@ -1124,10 +1121,6 @@ trait WireSz {
fn wire_sz(&self) -> Expr;
}

trait WireOff {
fn wire_off(&self) -> Expr;
}

trait HasWireLayout {
fn has_wire_layout(&self) -> bool;
}
Expand Down Expand Up @@ -1216,19 +1209,6 @@ impl WireSz for TypeInfo {
}
}

impl WireOff for Field {
fn wire_off(&self) -> Expr {
match self {
Field::Field { wire_off, .. }
| Field::List { wire_off, .. }
| Field::Switch { wire_off, .. }
| Field::Expr { wire_off, .. }
| Field::Pad { wire_off, .. }
| Field::AlignPad { wire_off, .. } => wire_off.clone(),
}
}
}

impl HasWireLayout for TypeInfo {
fn has_wire_layout(&self) -> bool {
match self {
Expand Down
2 changes: 1 addition & 1 deletion build/cg/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl CodeGen {
if self.xcb_mod == "xproto" {
writeln!(out, "{}ext: std::ptr::null_mut(),", cg::ind(3))?;
} else {
writeln!(out, "{}ext: (&mut FFI_EXT) as *mut _,", cg::ind(3))?;
writeln!(out, "{}ext: std::ptr::addr_of_mut!(FFI_EXT),", cg::ind(3))?;
}
writeln!(out, "{}opcode: {},", cg::ind(3), opcode)?;
writeln!(
Expand Down
6 changes: 1 addition & 5 deletions build/cg/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,16 @@ impl CodeGen {
}
ir::Field::Pad(wire_sz) => {
has_wire_layout = false;
let wire_off = wire_off.clone().reduce();
vec.push(Field::Pad {
wire_off,
wire_sz: Expr::Value(*wire_sz),
});
Expr::Value(*wire_sz)
}
ir::Field::AlignPad(sz) => {
has_wire_layout = false;
let wire_off = wire_off.clone().reduce();
let wire_sz = Expr::AlignPad(*sz, Box::new(wire_off.clone())).reduce();
let wire_sz = Expr::AlignPad(*sz, Box::new(wire_off)).reduce();
vec.push(Field::AlignPad {
wire_off,
wire_sz: wire_sz.clone(),
});
wire_sz
Expand Down Expand Up @@ -357,7 +354,6 @@ impl CodeGen {
vec.push(Field::Expr {
name,
typ,
wire_off: wire_off.clone(),
wire_sz: wire_sz.clone(),
expr,
});
Expand Down
10 changes: 5 additions & 5 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,9 +1324,9 @@ impl Connection {
unsafe {
let ext: *mut xcb_extension_t = match XGE::EXTENSION {
#[cfg(feature = "xinput")]
Extension::Input => &mut xinput::FFI_EXT as *mut _,
Extension::Input => ptr::addr_of_mut!(xinput::FFI_EXT),
#[cfg(feature = "present")]
Extension::Present => &mut present::FFI_EXT as *mut _,
Extension::Present => ptr::addr_of_mut!(present::FFI_EXT),
_ => unreachable!("only Input and Present have XGE events"),
};

Expand Down Expand Up @@ -1385,10 +1385,10 @@ impl Connection {
unsafe {
let ext: *mut xcb_extension_t = match extension {
#[cfg(feature = "xinput")]
Extension::Input => &mut xinput::FFI_EXT as *mut _,
Extension::Input => ptr::addr_of_mut!(xinput::FFI_EXT),
#[cfg(feature = "present")]
Extension::Present => &mut present::FFI_EXT as *mut _,
_ => panic!("only Input and Present have XGE events"),
Extension::Present => ptr::addr_of_mut!(present::FFI_EXT),
_ => unreachable!("only Input and Present have XGE events"),
};

let raw = xcb_register_for_special_xge(self.c, ext, eid.resource_id(), ptr::null_mut());
Expand Down
71 changes: 36 additions & 35 deletions src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::x;

use std::fmt;
use std::mem;
use std::ptr;

/// Refers to a X protocol extension.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -283,18 +284,18 @@ pub fn cache_extensions_data(
unsafe {
for ext in mandatory {
let ext_id = get_extension_id(*ext);
xcb_prefetch_extension_data(conn, ext_id as *mut _);
xcb_prefetch_extension_data(conn, ext_id);
}
for ext in optional {
let ext_id = get_extension_id(*ext);
xcb_prefetch_extension_data(conn, ext_id as *mut _);
xcb_prefetch_extension_data(conn, ext_id);
}

let mut ext_data = Vec::new();

for ext in mandatory {
let ext_id = get_extension_id(*ext);
let raw = xcb_get_extension_data(conn, ext_id as *mut _);
let raw = xcb_get_extension_data(conn, ext_id);
let reply = x::QueryExtensionReply::from_raw(raw);

assert!(
Expand All @@ -313,7 +314,7 @@ pub fn cache_extensions_data(

for ext in optional {
let ext_id = get_extension_id(*ext);
let raw = xcb_get_extension_data(conn, ext_id as *mut _);
let raw = xcb_get_extension_data(conn, ext_id);
let reply = x::QueryExtensionReply::from_raw(raw);

if !reply.present() {
Expand All @@ -337,93 +338,93 @@ pub fn cache_extensions_data(
}
}

unsafe fn get_extension_id(ext: Extension) -> &'static mut xcb_extension_t {
unsafe fn get_extension_id(ext: Extension) -> *mut xcb_extension_t {
match ext {
Extension::BigRequests => &mut crate::bigreq::FFI_EXT,
Extension::XcMisc => &mut crate::xc_misc::FFI_EXT,
Extension::BigRequests => ptr::addr_of_mut!(crate::bigreq::FFI_EXT),
Extension::XcMisc => ptr::addr_of_mut!(crate::xc_misc::FFI_EXT),

#[cfg(feature = "composite")]
Extension::Composite => &mut crate::composite::FFI_EXT,
Extension::Composite => ptr::addr_of_mut!(crate::composite::FFI_EXT),

#[cfg(feature = "damage")]
Extension::Damage => &mut crate::damage::FFI_EXT,
Extension::Damage => ptr::addr_of_mut!(crate::damage::FFI_EXT),

#[cfg(feature = "dpms")]
Extension::Dpms => &mut crate::dpms::FFI_EXT,
Extension::Dpms => ptr::addr_of_mut!(crate::dpms::FFI_EXT),

#[cfg(feature = "dri2")]
Extension::Dri2 => &mut crate::dri2::FFI_EXT,
Extension::Dri2 => ptr::addr_of_mut!(crate::dri2::FFI_EXT),

#[cfg(feature = "dri3")]
Extension::Dri3 => &mut crate::dri3::FFI_EXT,
Extension::Dri3 => ptr::addr_of_mut!(crate::dri3::FFI_EXT),

#[cfg(feature = "ge")]
Extension::GenericEvent => &mut crate::ge::FFI_EXT,
Extension::GenericEvent => ptr::addr_of_mut!(crate::ge::FFI_EXT),

#[cfg(feature = "glx")]
Extension::Glx => &mut crate::glx::FFI_EXT,
Extension::Glx => ptr::addr_of_mut!(crate::glx::FFI_EXT),

#[cfg(feature = "present")]
Extension::Present => &mut crate::present::FFI_EXT,
Extension::Present => ptr::addr_of_mut!(crate::present::FFI_EXT),

#[cfg(feature = "randr")]
Extension::RandR => &mut crate::randr::FFI_EXT,
Extension::RandR => ptr::addr_of_mut!(crate::randr::FFI_EXT),

#[cfg(feature = "record")]
Extension::Record => &mut crate::record::FFI_EXT,
Extension::Record => ptr::addr_of_mut!(crate::record::FFI_EXT),

#[cfg(feature = "render")]
Extension::Render => &mut crate::render::FFI_EXT,
Extension::Render => ptr::addr_of_mut!(crate::render::FFI_EXT),

#[cfg(feature = "res")]
Extension::Res => &mut crate::res::FFI_EXT,
Extension::Res => ptr::addr_of_mut!(crate::res::FFI_EXT),

#[cfg(feature = "screensaver")]
Extension::ScreenSaver => &mut crate::screensaver::FFI_EXT,
Extension::ScreenSaver => ptr::addr_of_mut!(crate::screensaver::FFI_EXT),

#[cfg(feature = "shape")]
Extension::Shape => &mut crate::shape::FFI_EXT,
Extension::Shape => ptr::addr_of_mut!(crate::shape::FFI_EXT),

#[cfg(feature = "shm")]
Extension::Shm => &mut crate::shm::FFI_EXT,
Extension::Shm => ptr::addr_of_mut!(crate::shm::FFI_EXT),

#[cfg(feature = "sync")]
Extension::Sync => &mut crate::sync::FFI_EXT,
Extension::Sync => ptr::addr_of_mut!(crate::sync::FFI_EXT),

#[cfg(feature = "xevie")]
Extension::Xevie => &mut crate::xevie::FFI_EXT,
Extension::Xevie => ptr::addr_of_mut!(crate::xevie::FFI_EXT),

#[cfg(feature = "xf86dri")]
Extension::Xf86Dri => &mut crate::xf86dri::FFI_EXT,
Extension::Xf86Dri => ptr::addr_of_mut!(crate::xf86dri::FFI_EXT),

#[cfg(feature = "xf86vidmode")]
Extension::Xf86VidMode => &mut crate::xf86vidmode::FFI_EXT,
Extension::Xf86VidMode => ptr::addr_of_mut!(crate::xf86vidmode::FFI_EXT),

#[cfg(feature = "xfixes")]
Extension::XFixes => &mut crate::xfixes::FFI_EXT,
Extension::XFixes => ptr::addr_of_mut!(crate::xfixes::FFI_EXT),

#[cfg(feature = "xinerama")]
Extension::Xinerama => &mut crate::xinerama::FFI_EXT,
Extension::Xinerama => ptr::addr_of_mut!(crate::xinerama::FFI_EXT),

#[cfg(feature = "xinput")]
Extension::Input => &mut crate::xinput::FFI_EXT,
Extension::Input => ptr::addr_of_mut!(crate::xinput::FFI_EXT),

#[cfg(feature = "xkb")]
Extension::Xkb => &mut crate::xkb::FFI_EXT,
Extension::Xkb => ptr::addr_of_mut!(crate::xkb::FFI_EXT),

#[cfg(feature = "xprint")]
Extension::XPrint => &mut crate::xprint::FFI_EXT,
Extension::XPrint => ptr::addr_of_mut!(crate::xprint::FFI_EXT),

#[cfg(feature = "xselinux")]
Extension::SeLinux => &mut crate::xselinux::FFI_EXT,
Extension::SeLinux => ptr::addr_of_mut!(crate::xselinux::FFI_EXT),

#[cfg(feature = "xtest")]
Extension::Test => &mut crate::xtest::FFI_EXT,
Extension::Test => ptr::addr_of_mut!(crate::xtest::FFI_EXT),

#[cfg(feature = "xv")]
Extension::Xv => &mut crate::xv::FFI_EXT,
Extension::Xv => ptr::addr_of_mut!(crate::xv::FFI_EXT),

#[cfg(feature = "xvmc")]
Extension::XvMc => &mut crate::xvmc::FFI_EXT,
Extension::XvMc => ptr::addr_of_mut!(crate::xvmc::FFI_EXT),
}
}

0 comments on commit 8623b9e

Please sign in to comment.