summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryant Mairs <bryant@mai.rs>2019-05-27 08:45:28 -0700
committerBryant Mairs <bryant@mai.rs>2019-05-27 08:45:28 -0700
commit0b345018793778f0687b5c08c78b16ca48698a08 (patch)
tree24f16a85d460d5dfe48fc5a6d3623056d852a9d8
parent7d235af8c5953fca88c6ac6688d5a0da724e7163 (diff)
downloadrust-libc-0b345018793778f0687b5c08c78b16ca48698a08.tar.gz
Ignore padding for `sockaddr_nl` struct
`nl_pad` field does not contain any actual data, so using it for comparison or hashing doesn't make sense. Instead manually implement extra traits ignoring this field.
-rw-r--r--src/fuchsia/mod.rs39
-rw-r--r--src/unix/notbsd/mod.rs39
-rw-r--r--src/unix/uclibc/mod.rs39
3 files changed, 96 insertions, 21 deletions
diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs
index 91cf53a2bf..2ce2f408c0 100644
--- a/src/fuchsia/mod.rs
+++ b/src/fuchsia/mod.rs
@@ -366,13 +366,6 @@ s! {
pub ai_next: *mut addrinfo,
}
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-
pub struct sockaddr_ll {
pub sll_family: ::c_ushort,
pub sll_protocol: ::c_ushort,
@@ -971,6 +964,13 @@ s_no_extra_traits! {
#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
pad: [::c_long; 4],
}
+
+ pub struct sockaddr_nl {
+ pub nl_family: ::sa_family_t,
+ nl_pad: ::c_ushort,
+ pub nl_pid: u32,
+ pub nl_groups: u32
+ }
}
cfg_if! {
@@ -1239,6 +1239,31 @@ cfg_if! {
self.mq_curmsgs.hash(state);
}
}
+
+ impl PartialEq for sockaddr_nl {
+ fn eq(&self, other: &sockaddr_nl) -> bool {
+ self.nl_family == other.nl_family &&
+ self.nl_pid == other.nl_pid &&
+ self.nl_groups == other.nl_groups
+ }
+ }
+ impl Eq for sockaddr_nl {}
+ impl ::fmt::Debug for sockaddr_nl {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_nl")
+ .field("nl_family", &self.nl_family)
+ .field("nl_pid", &self.nl_pid)
+ .field("nl_groups", &self.nl_groups)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sockaddr_nl {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.nl_family.hash(state);
+ self.nl_pid.hash(state);
+ self.nl_groups.hash(state);
+ }
+ }
}
}
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index ea1e7c69bb..3d388cc579 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -61,13 +61,6 @@ s! {
pub ai_next: *mut addrinfo,
}
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-
pub struct sockaddr_ll {
pub sll_family: ::c_ushort,
pub sll_protocol: ::c_ushort,
@@ -249,6 +242,13 @@ s_no_extra_traits!{
pub machine: [::c_char; 65],
pub domainname: [::c_char; 65]
}
+
+ pub struct sockaddr_nl {
+ pub nl_family: ::sa_family_t,
+ nl_pad: ::c_ushort,
+ pub nl_pid: u32,
+ pub nl_groups: u32
+ }
}
cfg_if! {
@@ -394,6 +394,31 @@ cfg_if! {
self.domainname.hash(state);
}
}
+
+ impl PartialEq for sockaddr_nl {
+ fn eq(&self, other: &sockaddr_nl) -> bool {
+ self.nl_family == other.nl_family &&
+ self.nl_pid == other.nl_pid &&
+ self.nl_groups == other.nl_groups
+ }
+ }
+ impl Eq for sockaddr_nl {}
+ impl ::fmt::Debug for sockaddr_nl {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_nl")
+ .field("nl_family", &self.nl_family)
+ .field("nl_pid", &self.nl_pid)
+ .field("nl_groups", &self.nl_groups)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sockaddr_nl {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.nl_family.hash(state);
+ self.nl_pid.hash(state);
+ self.nl_groups.hash(state);
+ }
+ }
}
}
diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs
index e500c7a32f..9c8b08d8ee 100644
--- a/src/unix/uclibc/mod.rs
+++ b/src/unix/uclibc/mod.rs
@@ -80,13 +80,6 @@ s! {
pub ai_next: *mut addrinfo,
}
- pub struct sockaddr_nl {
- pub nl_family: ::sa_family_t,
- nl_pad: ::c_ushort,
- pub nl_pid: u32,
- pub nl_groups: u32
- }
-
pub struct sockaddr_ll {
pub sll_family: ::c_ushort,
pub sll_protocol: ::c_ushort,
@@ -368,6 +361,13 @@ s_no_extra_traits! {
pub mq_curmsgs: ::c_long,
pad: [::c_long; 4]
}
+
+ pub struct sockaddr_nl {
+ pub nl_family: ::sa_family_t,
+ nl_pad: ::c_ushort,
+ pub nl_pid: u32,
+ pub nl_groups: u32
+ }
}
cfg_if! {
@@ -399,6 +399,31 @@ cfg_if! {
self.mq_curmsgs.hash(state);
}
}
+
+ impl PartialEq for sockaddr_nl {
+ fn eq(&self, other: &sockaddr_nl) -> bool {
+ self.nl_family == other.nl_family &&
+ self.nl_pid == other.nl_pid &&
+ self.nl_groups == other.nl_groups
+ }
+ }
+ impl Eq for sockaddr_nl {}
+ impl ::fmt::Debug for sockaddr_nl {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_nl")
+ .field("nl_family", &self.nl_family)
+ .field("nl_pid", &self.nl_pid)
+ .field("nl_groups", &self.nl_groups)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sockaddr_nl {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.nl_family.hash(state);
+ self.nl_pid.hash(state);
+ self.nl_groups.hash(state);
+ }
+ }
}
}