Skip to content

Commit 5e2408f

Browse files
committed
Fix compile error: reference to packed field is unaligned.
This was previously accepted by the compiler, then it was being phased out, and finally it became a hard error. For more information, see Rust issue #82523 rust-lang/rust#82523
1 parent 861fd7e commit 5e2408f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "p0f_api"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
authors = ["emk <[email protected]>"]
55
license = "WTFPL OR MIT OR Apache-2.0"
66
description = "Interface for querying p0f unix socket API."

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ It has been developed with p0f version 3.09b.
1111
### Cargo.toml:
1212
```toml
1313
[dependencies]
14-
p0f_api = "~0.1.1"
14+
p0f_api = "~0.1.2"
1515
```
1616

1717
### Code:

src/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl P0f {
9191
io::ErrorKind::InvalidData,
9292
format!(
9393
"p0f: invalid magic number received: 0x{:x}. Should be: 0x{:x}.",
94-
resp.magic,
94+
{resp.magic},
9595
raw::P0F_RESP_MAGIC
9696
)
9797
));
@@ -107,14 +107,15 @@ impl P0f {
107107
return Ok(None),
108108
raw::P0F_STATUS_OK =>
109109
return Ok(Some(P0fResponse::from_raw_response(&resp))),
110-
_ =>
110+
_ => {
111111
return Err(io::Error::new(
112112
io::ErrorKind::InvalidData,
113113
format!(
114114
"p0f: Unknown status received: 0x{:x}. [Please report this to p0f_api crate author].",
115-
resp.status
115+
{resp.status}
116116
)
117-
)),
117+
))
118+
}
118119
}
119120

120121
}
@@ -186,8 +187,8 @@ pub struct P0fResponse {
186187
impl P0fResponse {
187188
/// Conversion from `raw::p0f_api_response`.
188189
fn from_raw_response(resp: &raw::p0f_api_response) -> Self {
189-
debug_assert_eq!(resp.magic, raw::P0F_RESP_MAGIC);
190-
debug_assert_eq!(resp.status, raw::P0F_STATUS_OK);
190+
debug_assert_eq!({resp.magic}, raw::P0F_RESP_MAGIC);
191+
debug_assert_eq!({resp.status}, raw::P0F_STATUS_OK);
191192

192193
P0fResponse {
193194
first_seen: resp.first_seen as i64,

0 commit comments

Comments
 (0)