Skip to content

Commit 4745d81

Browse files
committed
Improve timezone handling in 'localtime_r()' using 'allocate_bytes()'
Signed-off-by: shamb0 <[email protected]>
1 parent 33f6ce9 commit 4745d81

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/shims/time.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
198198
write!(tm_zone, "{:02}", offset_min).unwrap();
199199
}
200200

201-
// Add null terminator for C string compatibility
201+
// Add null terminator for C string compatibility.
202202
tm_zone.push('\0');
203203

204204
// Deduplicate and allocate the string.
@@ -208,9 +208,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
208208
MiriMemoryKind::Machine.into(),
209209
Mutability::Not,
210210
)?;
211-
211+
212212
// Write the timezone pointer and offset into the result structure.
213-
this.write_pointer(*tm_zone_ptr, &this.project_field_named(&result, "tm_zone")?)?;
213+
this.write_pointer(tm_zone_ptr, &this.project_field_named(&result, "tm_zone")?)?;
214214
this.write_int_fields_named(&[("tm_gmtoff", tm_gmtoff.into())], &result)?;
215215
}
216216
interp_ok(result.ptr())

tests/pass-dep/libc/libc-time.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn main() {
88
test_localtime_r_gmt();
99
test_localtime_r_pst();
1010
test_localtime_r_epoch();
11-
// Architecture-specific tests
11+
// Architecture-specific tests.
1212
#[cfg(target_pointer_width = "32")]
1313
test_localtime_r_future_32b();
1414
#[cfg(target_pointer_width = "64")]
@@ -53,7 +53,7 @@ fn test_posix_gettimeofday() {
5353
assert_eq!(is_error, -1);
5454
}
5555

56-
// Helper function to create an empty tm struct
56+
// Helper function to create an empty tm struct.
5757
fn create_empty_tm() -> libc::tm {
5858
libc::tm {
5959
tm_sec: 0,
@@ -121,7 +121,7 @@ fn test_localtime_r_gmt() {
121121
env::remove_var(key);
122122
}
123123

124-
// PST timezone test (testing different timezone handling)
124+
// PST timezone test (testing different timezone handling).
125125
fn test_localtime_r_pst() {
126126
let key = "TZ";
127127
env::set_var(key, "PST8PDT");
@@ -158,7 +158,7 @@ fn test_localtime_r_pst() {
158158
env::remove_var(key);
159159
}
160160

161-
// Unix epoch test (edge case testing)
161+
// Unix epoch test (edge case testing).
162162
fn test_localtime_r_epoch() {
163163
let key = "TZ";
164164
env::set_var(key, "GMT");
@@ -195,7 +195,7 @@ fn test_localtime_r_epoch() {
195195
env::remove_var(key);
196196
}
197197

198-
// Future date test (testing large values)
198+
// Future date test (testing large values).
199199
#[cfg(target_pointer_width = "64")]
200200
fn test_localtime_r_future_64b() {
201201
let key = "TZ";

0 commit comments

Comments
 (0)