Skip to content

Commit f73e2a4

Browse files
committed
Blind shot a identifying the possible statuses a proxy_get_property could return
Signed-off-by: Alex Snaps <[email protected]>
1 parent 64712b3 commit f73e2a4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/hostcalls.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
use crate::dispatcher;
16+
use crate::types::Status::SerializationFailure;
1617
use crate::types::*;
1718
use std::ptr::{null, null_mut};
1819
use std::time::{Duration, SystemTime, UNIX_EPOCH};
@@ -398,12 +399,13 @@ pub fn get_property(path: Vec<&str>) -> Result<Option<Bytes>, Status> {
398399
let mut return_data: *mut u8 = null_mut();
399400
let mut return_size: usize = 0;
400401
unsafe {
401-
match proxy_get_property(
402+
let status = proxy_get_property(
402403
serialized_path.as_ptr(),
403404
serialized_path.len(),
404405
&mut return_data,
405406
&mut return_size,
406-
) {
407+
);
408+
match status {
407409
Status::Ok => {
408410
if !return_data.is_null() {
409411
Ok(Some(Vec::from_raw_parts(
@@ -415,8 +417,12 @@ pub fn get_property(path: Vec<&str>) -> Result<Option<Bytes>, Status> {
415417
Ok(None)
416418
}
417419
}
418-
Status::NotFound => Ok(None),
419-
status => Err(status),
420+
Status::NotFound | Status::Empty => Ok(None),
421+
Status::SerializationFailure
422+
| Status::BadArgument
423+
| Status::BadExpression
424+
| Status::Unimplemented => Err(status),
425+
status => panic!("unexpected status: {}", status as u32),
420426
}
421427
}
422428
}

0 commit comments

Comments
 (0)