Skip to content

Commit 1a0a309

Browse files
committed
Updated dependencies.
1 parent 0327a4c commit 1a0a309

File tree

4 files changed

+41
-38
lines changed

4 files changed

+41
-38
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## [1.0.11] - 2024-09-12
6+
7+
### Changed
8+
9+
- Updated dependencies.
10+
511
## [1.0.10] - 2024-01-19
612

713
### Changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "process_vm_io"
3-
version = "1.0.10" # Remember to update `html_root_url` and `dependency status` link.
3+
version = "1.0.11" # Remember to update `html_root_url` and `dependency status` link.
44
description = "I/O access to virtual memory contents of processes"
55
authors = [
66
"Koutheir Attouchi <[email protected]>"
@@ -26,10 +26,10 @@ keywords = [
2626
]
2727

2828
[dev-dependencies]
29-
assert_matches = { version = "1.5" }
29+
assert_matches = { version = "1" }
3030

3131
[dependencies]
3232
backtrace = { version = "0.3" }
33-
lazy_static = { version = "1.4" }
33+
lazy_static = { version = "1" }
3434
libc = { version = "0.2" }
35-
smallvec = { version = "1.13" }
35+
smallvec = { version = "1" }

src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// TODO: https://rust-lang.github.io/api-guidelines/checklist.html
88

99
#![doc = include_str!("../README.md")]
10-
#![doc(html_root_url = "https://docs.rs/process_vm_io/1.0.10")]
10+
#![doc(html_root_url = "https://docs.rs/process_vm_io/1.0.11")]
1111

1212
#![warn(
1313
unsafe_op_in_unsafe_fn,
@@ -49,7 +49,7 @@ lazy_static! {
4949
/// of `u64::max_value()`.
5050
static ref MIN_SYSTEM_PAGE_SIZE: u64 =
5151
match unsafe { libc::sysconf(libc::_SC_PAGE_SIZE) } {
52-
-1 => u64::max_value(),
52+
-1 => u64::MAX,
5353
result => result as u64,
5454
};
5555

@@ -360,10 +360,7 @@ impl ProcessVirtualMemoryIO {
360360
let address = self.address.unwrap();
361361

362362
// Do not overflow the address space.
363-
let mut max_remaining_bytes = u64::max_value() - address;
364-
if max_remaining_bytes < u64::max_value() {
365-
max_remaining_bytes += 1;
366-
}
363+
let max_remaining_bytes = (u64::MAX - address).saturating_add(1);
367364
byte_count = cmp::min(byte_count, max_remaining_bytes);
368365

369366
let (remote_io_vectors, _size_of_not_covered_suffix) =
@@ -422,11 +419,11 @@ impl Seek for ProcessVirtualMemoryIO {
422419

423420
(None, SeekFrom::Current(n)) /* if n < 0 */ => {
424421
let backward = n.wrapping_neg() as u64;
425-
Some((u64::max_value() - backward) + 1)
422+
Some((u64::MAX - backward) + 1)
426423
}
427424
(_, SeekFrom::End(n)) /* if n < 0 */ => {
428425
let backward = n.wrapping_neg() as u64;
429-
Some((u64::max_value() - backward) + 1)
426+
Some((u64::MAX - backward) + 1)
430427
}
431428

432429
(Some(address), SeekFrom::Current(n)) /* if n < 0 */ => {
@@ -435,7 +432,7 @@ impl Seek for ProcessVirtualMemoryIO {
435432
}
436433
};
437434

438-
Ok(self.address.unwrap_or(u64::max_value()))
435+
Ok(self.address.unwrap_or(u64::MAX))
439436
}
440437
}
441438

src/tests.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::*;
1212
fn sensible_virtual_memory_page_size() {
1313
let size = *MIN_SYSTEM_PAGE_SIZE;
1414
assert!(size > 0);
15-
assert!(size < u64::max_value());
15+
assert!(size < u64::MAX);
1616
assert!(size.is_power_of_two());
1717
}
1818

@@ -36,9 +36,9 @@ fn new_page_aware_address_range_1page() {
3636
}
3737
);
3838
assert_eq!(
39-
PageAwareAddressRange::new(u64::max_value(), 0),
39+
PageAwareAddressRange::new(u64::MAX, 0),
4040
PageAwareAddressRange {
41-
start_address: u64::max_value(),
41+
start_address: u64::MAX,
4242
..Default::default()
4343
}
4444
);
@@ -66,25 +66,25 @@ fn new_page_aware_address_range_1page() {
6666
}
6767
);
6868
assert_eq!(
69-
PageAwareAddressRange::new(u64::max_value() - 16, 13),
69+
PageAwareAddressRange::new(u64::MAX - 16, 13),
7070
PageAwareAddressRange {
71-
start_address: u64::max_value() - 16,
71+
start_address: u64::MAX - 16,
7272
size_in_first_page: 13,
7373
..Default::default()
7474
}
7575
);
7676
assert_eq!(
77-
PageAwareAddressRange::new(u64::max_value() - 16, 16),
77+
PageAwareAddressRange::new(u64::MAX - 16, 16),
7878
PageAwareAddressRange {
79-
start_address: u64::max_value() - 16,
79+
start_address: u64::MAX - 16,
8080
size_in_first_page: 16,
8181
..Default::default()
8282
}
8383
);
8484
assert_eq!(
85-
PageAwareAddressRange::new(u64::max_value() - 16, 17),
85+
PageAwareAddressRange::new(u64::MAX - 16, 17),
8686
PageAwareAddressRange {
87-
start_address: u64::max_value() - 16,
87+
start_address: u64::MAX - 16,
8888
size_in_first_page: 17,
8989
..Default::default()
9090
}
@@ -114,11 +114,11 @@ fn new_page_aware_address_range_1page() {
114114
);
115115
assert_eq!(
116116
PageAwareAddressRange::new(
117-
u64::max_value() - *MIN_SYSTEM_PAGE_SIZE + 1,
117+
u64::MAX - *MIN_SYSTEM_PAGE_SIZE + 1,
118118
*MIN_SYSTEM_PAGE_SIZE
119119
),
120120
PageAwareAddressRange {
121-
start_address: u64::max_value() - *MIN_SYSTEM_PAGE_SIZE + 1,
121+
start_address: u64::MAX - *MIN_SYSTEM_PAGE_SIZE + 1,
122122
size_of_inner_pages: *MIN_SYSTEM_PAGE_SIZE,
123123
..Default::default()
124124
}
@@ -128,7 +128,7 @@ fn new_page_aware_address_range_1page() {
128128
#[test]
129129
fn new_page_aware_address_range_2pages() {
130130
for addr in &[
131-
u64::max_value() - 7,
131+
u64::MAX - 7,
132132
*MIN_SYSTEM_PAGE_SIZE - 8,
133133
0x1000_0000 - 8,
134134
] {
@@ -147,51 +147,51 @@ fn new_page_aware_address_range_2pages() {
147147
#[test]
148148
fn new_page_aware_address_range_manypages() {
149149
assert_eq!(
150-
PageAwareAddressRange::new(u64::max_value() - 7, 32 + *MIN_SYSTEM_PAGE_SIZE * 5),
150+
PageAwareAddressRange::new(u64::MAX - 7, 32 + *MIN_SYSTEM_PAGE_SIZE * 5),
151151
PageAwareAddressRange {
152-
start_address: u64::max_value() - 7,
152+
start_address: u64::MAX - 7,
153153
size_in_first_page: 8,
154154
size_of_inner_pages: *MIN_SYSTEM_PAGE_SIZE * 5,
155155
size_in_last_page: 24,
156156
}
157157
);
158158
assert_eq!(
159-
PageAwareAddressRange::new(u64::max_value() - 7, 32 + *MIN_SYSTEM_PAGE_SIZE),
159+
PageAwareAddressRange::new(u64::MAX - 7, 32 + *MIN_SYSTEM_PAGE_SIZE),
160160
PageAwareAddressRange {
161-
start_address: u64::max_value() - 7,
161+
start_address: u64::MAX - 7,
162162
size_in_first_page: 8,
163163
size_of_inner_pages: *MIN_SYSTEM_PAGE_SIZE,
164164
size_in_last_page: 24,
165165
}
166166
);
167167
assert_eq!(
168-
PageAwareAddressRange::new(u64::max_value() - 7, 32 + *MIN_SYSTEM_PAGE_SIZE * 2),
168+
PageAwareAddressRange::new(u64::MAX - 7, 32 + *MIN_SYSTEM_PAGE_SIZE * 2),
169169
PageAwareAddressRange {
170-
start_address: u64::max_value() - 7,
170+
start_address: u64::MAX - 7,
171171
size_in_first_page: 8,
172172
size_of_inner_pages: *MIN_SYSTEM_PAGE_SIZE * 2,
173173
size_in_last_page: 24,
174174
}
175175
);
176176
assert_eq!(
177177
PageAwareAddressRange::new(
178-
u64::max_value() - *MIN_SYSTEM_PAGE_SIZE - 7,
178+
u64::MAX - *MIN_SYSTEM_PAGE_SIZE - 7,
179179
32 + *MIN_SYSTEM_PAGE_SIZE
180180
),
181181
PageAwareAddressRange {
182-
start_address: u64::max_value() - *MIN_SYSTEM_PAGE_SIZE - 7,
182+
start_address: u64::MAX - *MIN_SYSTEM_PAGE_SIZE - 7,
183183
size_in_first_page: 8,
184184
size_of_inner_pages: *MIN_SYSTEM_PAGE_SIZE,
185185
size_in_last_page: 24,
186186
}
187187
);
188188
assert_eq!(
189189
PageAwareAddressRange::new(
190-
u64::max_value() - *MIN_SYSTEM_PAGE_SIZE - 7,
190+
u64::MAX - *MIN_SYSTEM_PAGE_SIZE - 7,
191191
32 + *MIN_SYSTEM_PAGE_SIZE * 2
192192
),
193193
PageAwareAddressRange {
194-
start_address: u64::max_value() - *MIN_SYSTEM_PAGE_SIZE - 7,
194+
start_address: u64::MAX - *MIN_SYSTEM_PAGE_SIZE - 7,
195195
size_in_first_page: 8,
196196
size_of_inner_pages: *MIN_SYSTEM_PAGE_SIZE * 2,
197197
size_in_last_page: 24,
@@ -221,13 +221,13 @@ fn new_page_aware_address_range_manypages() {
221221
fn new_invalid_process_id() {
222222
assert_matches!(
223223
unsafe { ProcessVirtualMemoryIO::new(1, 0) }.unwrap_err().kind(),
224-
ErrorKind::Io { error, process_id: Some(1), .. } if error.kind() == std::io::ErrorKind::PermissionDenied
224+
ErrorKind::Io { error, process_id: Some(1), .. } if error.kind() == io::ErrorKind::PermissionDenied
225225
);
226226

227227
for pid in -2_i32..=0 {
228228
assert_matches!(
229229
unsafe { ProcessVirtualMemoryIO::new(pid as u32, 0) }.unwrap_err().kind(),
230-
ErrorKind::Io { error, .. } if error.kind() == std::io::ErrorKind::InvalidInput
230+
ErrorKind::Io { error, .. } if error.kind() == io::ErrorKind::InvalidInput
231231
);
232232
}
233233
}
@@ -236,7 +236,7 @@ fn new_invalid_process_id() {
236236
fn new_invalid_address() {
237237
let process_id = std::process::id();
238238
assert!(unsafe { ProcessVirtualMemoryIO::new(process_id, 0) }.is_ok());
239-
assert!(unsafe { ProcessVirtualMemoryIO::new(process_id, u64::max_value()) }.is_ok());
239+
assert!(unsafe { ProcessVirtualMemoryIO::new(process_id, u64::MAX) }.is_ok());
240240
}
241241

242242
#[test]

0 commit comments

Comments
 (0)