Skip to content

Commit 953c615

Browse files
authored
Merge pull request #541 from CosmWasm/chipshort/workaround-optimizer-bug
Avoid checking `errOut.is_none` for unused errOut
2 parents 8bf2938 + 973cc64 commit 953c615

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

internal/api/callbacks.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ func cGet(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *cu64, key C.U8SliceView
157157
// we received an invalid pointer
158158
return C.GoError_BadArgument
159159
}
160-
if !(*val).is_none || !(*errOut).is_none {
160+
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
161+
if !(*val).is_none {
161162
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
162163
}
163164

@@ -185,9 +186,7 @@ func cSet(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *cu64, key C.U8SliceView
185186
// we received an invalid pointer
186187
return C.GoError_BadArgument
187188
}
188-
if !(*errOut).is_none {
189-
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
190-
}
189+
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
191190

192191
gm := *(*types.GasMeter)(unsafe.Pointer(gasMeter))
193192
kv := *(*types.KVStore)(unsafe.Pointer(ptr))
@@ -210,9 +209,7 @@ func cDelete(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *cu64, key C.U8SliceV
210209
// we received an invalid pointer
211210
return C.GoError_BadArgument
212211
}
213-
if !(*errOut).is_none {
214-
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
215-
}
212+
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
216213

217214
gm := *(*types.GasMeter)(unsafe.Pointer(gasMeter))
218215
kv := *(*types.KVStore)(unsafe.Pointer(ptr))
@@ -286,7 +283,8 @@ func cNext(ref C.IteratorReference, gasMeter *C.gas_meter_t, usedGas *cu64, key
286283
// we received an invalid pointer
287284
return C.GoError_BadArgument
288285
}
289-
if !(*key).is_none || !(*val).is_none || !(*errOut).is_none {
286+
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
287+
if !(*key).is_none || !(*val).is_none {
290288
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
291289
}
292290

@@ -337,7 +335,8 @@ func nextPart(ref C.IteratorReference, gasMeter *C.gas_meter_t, usedGas *cu64, o
337335
// we received an invalid pointer
338336
return C.GoError_BadArgument
339337
}
340-
if !(*output).is_none || !(*errOut).is_none {
338+
// errOut is unused and we don't check `is_none` because of https://github.com/CosmWasm/wasmvm/issues/536
339+
if !(*output).is_none {
341340
panic("Got a non-none UnmanagedVector we're about to override. This is a bug because someone has to drop the old one.")
342341
}
343342

0 commit comments

Comments
 (0)