Skip to content

Commit 91d3219

Browse files
authored
Remove return value from wmemcheck libcalls (#9676)
This isn't used in the compiled code so don't bake it in.
1 parent 6c97d5e commit 91d3219

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

crates/environ/src/builtin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ macro_rules! foreach_builtin_function {
4343
new_epoch(vmctx: vmctx) -> i64;
4444
// Invoked before malloc returns.
4545
#[cfg(feature = "wmemcheck")]
46-
check_malloc(vmctx: vmctx, addr: i32, len: i32) -> i32;
46+
check_malloc(vmctx: vmctx, addr: i32, len: i32);
4747
// Invoked before the free returns.
4848
#[cfg(feature = "wmemcheck")]
49-
check_free(vmctx: vmctx, addr: i32) -> i32;
49+
check_free(vmctx: vmctx, addr: i32);
5050
// Invoked before a load is executed.
5151
#[cfg(feature = "wmemcheck")]
52-
check_load(vmctx: vmctx, num_bytes: i32, addr: i32, offset: i32) -> i32;
52+
check_load(vmctx: vmctx, num_bytes: i32, addr: i32, offset: i32);
5353
// Invoked before a store is executed.
5454
#[cfg(feature = "wmemcheck")]
55-
check_store(vmctx: vmctx, num_bytes: i32, addr: i32, offset: i32) -> i32;
55+
check_store(vmctx: vmctx, num_bytes: i32, addr: i32, offset: i32);
5656
// Invoked after malloc is called.
5757
#[cfg(feature = "wmemcheck")]
5858
malloc_start(vmctx: vmctx);

crates/wasmtime/src/runtime/vm/libcalls.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,14 +1110,12 @@ unsafe fn check_malloc(
11101110
instance: &mut Instance,
11111111
addr: u32,
11121112
len: u32,
1113-
) -> Result<u32> {
1113+
) -> Result<()> {
11141114
if let Some(wmemcheck_state) = &mut instance.wmemcheck_state {
11151115
let result = wmemcheck_state.malloc(addr as usize, len as usize);
11161116
wmemcheck_state.memcheck_on();
11171117
match result {
1118-
Ok(()) => {
1119-
return Ok(0);
1120-
}
1118+
Ok(()) => {}
11211119
Err(DoubleMalloc { addr, len }) => {
11221120
bail!("Double malloc at addr {:#x} of size {}", addr, len)
11231121
}
@@ -1129,19 +1127,17 @@ unsafe fn check_malloc(
11291127
}
11301128
}
11311129
}
1132-
Ok(0)
1130+
Ok(())
11331131
}
11341132

11351133
// Hook for validating free using wmemcheck_state.
11361134
#[cfg(feature = "wmemcheck")]
1137-
unsafe fn check_free(_store: &mut dyn VMStore, instance: &mut Instance, addr: u32) -> Result<u32> {
1135+
unsafe fn check_free(_store: &mut dyn VMStore, instance: &mut Instance, addr: u32) -> Result<()> {
11381136
if let Some(wmemcheck_state) = &mut instance.wmemcheck_state {
11391137
let result = wmemcheck_state.free(addr as usize);
11401138
wmemcheck_state.memcheck_on();
11411139
match result {
1142-
Ok(()) => {
1143-
return Ok(0);
1144-
}
1140+
Ok(()) => {}
11451141
Err(InvalidFree { addr }) => {
11461142
bail!("Invalid free at addr {:#x}", addr)
11471143
}
@@ -1150,7 +1146,7 @@ unsafe fn check_free(_store: &mut dyn VMStore, instance: &mut Instance, addr: u3
11501146
}
11511147
}
11521148
}
1153-
Ok(0)
1149+
Ok(())
11541150
}
11551151

11561152
// Hook for validating load using wmemcheck_state.
@@ -1161,13 +1157,11 @@ fn check_load(
11611157
num_bytes: u32,
11621158
addr: u32,
11631159
offset: u32,
1164-
) -> Result<u32> {
1160+
) -> Result<()> {
11651161
if let Some(wmemcheck_state) = &mut instance.wmemcheck_state {
11661162
let result = wmemcheck_state.read(addr as usize + offset as usize, num_bytes as usize);
11671163
match result {
1168-
Ok(()) => {
1169-
return Ok(0);
1170-
}
1164+
Ok(()) => {}
11711165
Err(InvalidRead { addr, len }) => {
11721166
bail!("Invalid load at addr {:#x} of size {}", addr, len);
11731167
}
@@ -1179,7 +1173,7 @@ fn check_load(
11791173
}
11801174
}
11811175
}
1182-
Ok(0)
1176+
Ok(())
11831177
}
11841178

11851179
// Hook for validating store using wmemcheck_state.
@@ -1190,13 +1184,11 @@ fn check_store(
11901184
num_bytes: u32,
11911185
addr: u32,
11921186
offset: u32,
1193-
) -> Result<u32> {
1187+
) -> Result<()> {
11941188
if let Some(wmemcheck_state) = &mut instance.wmemcheck_state {
11951189
let result = wmemcheck_state.write(addr as usize + offset as usize, num_bytes as usize);
11961190
match result {
1197-
Ok(()) => {
1198-
return Ok(0);
1199-
}
1191+
Ok(()) => {}
12001192
Err(InvalidWrite { addr, len }) => {
12011193
bail!("Invalid store at addr {:#x} of size {}", addr, len)
12021194
}
@@ -1208,7 +1200,7 @@ fn check_store(
12081200
}
12091201
}
12101202
}
1211-
Ok(0)
1203+
Ok(())
12121204
}
12131205

12141206
// Hook for turning wmemcheck load/store validation off when entering a malloc function.

0 commit comments

Comments
 (0)