Skip to content

Commit

Permalink
Fix compile error: reference to packed field is unaligned.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
emkw committed Jan 22, 2023
1 parent 861fd7e commit 5e2408f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "p0f_api"
version = "0.1.1"
version = "0.1.2"
authors = ["emk <rust@emk.one.pl>"]
license = "WTFPL OR MIT OR Apache-2.0"
description = "Interface for querying p0f unix socket API."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It has been developed with p0f version 3.09b.
### Cargo.toml:
```toml
[dependencies]
p0f_api = "~0.1.1"
p0f_api = "~0.1.2"
```

### Code:
Expand Down
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl P0f {
io::ErrorKind::InvalidData,
format!(
"p0f: invalid magic number received: 0x{:x}. Should be: 0x{:x}.",
resp.magic,
{resp.magic},
raw::P0F_RESP_MAGIC
)
));
Expand All @@ -107,14 +107,15 @@ impl P0f {
return Ok(None),
raw::P0F_STATUS_OK =>
return Ok(Some(P0fResponse::from_raw_response(&resp))),
_ =>
_ => {
return Err(io::Error::new(
io::ErrorKind::InvalidData,
format!(
"p0f: Unknown status received: 0x{:x}. [Please report this to p0f_api crate author].",
resp.status
{resp.status}
)
)),
))
}
}

}
Expand Down Expand Up @@ -186,8 +187,8 @@ pub struct P0fResponse {
impl P0fResponse {
/// Conversion from `raw::p0f_api_response`.
fn from_raw_response(resp: &raw::p0f_api_response) -> Self {
debug_assert_eq!(resp.magic, raw::P0F_RESP_MAGIC);
debug_assert_eq!(resp.status, raw::P0F_STATUS_OK);
debug_assert_eq!({resp.magic}, raw::P0F_RESP_MAGIC);
debug_assert_eq!({resp.status}, raw::P0F_STATUS_OK);

P0fResponse {
first_seen: resp.first_seen as i64,
Expand Down

0 comments on commit 5e2408f

Please sign in to comment.