Skip to content

Commit a501442

Browse files
author
Sangho Lee
committed
addressed feedbacks
1 parent 68b8aef commit a501442

5 files changed

Lines changed: 48 additions & 43 deletions

File tree

litebox_shim_optee/src/lib.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ impl Task {
393393
{
394394
let mut prop_buf = vec![0u8; buf_length as usize];
395395
if name.as_usize() != 0 || name_len.as_usize() != 0 {
396-
if cfg!(debug_assertions) {
397-
todo!("return the name of a given property index");
398-
}
396+
#[cfg(debug_assertions)]
397+
todo!("return the name of a given property index");
398+
#[cfg(not(debug_assertions))]
399399
Err(TeeResult::NotSupported)
400400
} else {
401401
self.sys_get_property(
@@ -539,9 +539,9 @@ impl Task {
539539
}
540540
}
541541
_ => {
542-
if cfg!(debug_assertions) {
543-
todo!();
544-
}
542+
#[cfg(debug_assertions)]
543+
todo!("unsupported syscall request");
544+
#[cfg(not(debug_assertions))]
545545
Err(TeeResult::NotSupported)
546546
}
547547
};
@@ -1002,12 +1002,12 @@ impl TeeObjMap {
10021002
};
10031003
tee_obj.set_key(&key_box);
10041004
} else {
1005-
if cfg!(debug_assertions) {
1006-
todo!(
1007-
"handle attribute ID: {}",
1008-
user_attrs[0].attribute_id.value()
1009-
);
1010-
}
1005+
#[cfg(debug_assertions)]
1006+
todo!(
1007+
"handle attribute ID: {}",
1008+
user_attrs[0].attribute_id.value()
1009+
);
1010+
#[cfg(not(debug_assertions))]
10111011
return Err(TeeResult::NotSupported);
10121012
}
10131013

litebox_shim_optee/src/syscalls/cryp.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,16 @@ impl Task {
119119
if let Some(handle) = cryp_state.get_object_handle(false)
120120
&& tee_obj_map.exists(handle)
121121
{
122-
if cfg!(debug_assertions) {
123-
todo!("support two-key algorithms");
124-
}
122+
#[cfg(debug_assertions)]
123+
todo!("support two-key algorithms");
124+
#[cfg(not(debug_assertions))]
125125
return Err(TeeResult::NotSupported);
126126
}
127127

128128
let Some(cipher) = create_cipher(cryp_state.algorithm(), key, iv) else {
129-
if cfg!(debug_assertions) {
130-
todo!("implement algorithm {}", cryp_state.algorithm() as u32);
131-
}
129+
#[cfg(debug_assertions)]
130+
todo!("implement algorithm {}", cryp_state.algorithm() as u32);
131+
#[cfg(not(debug_assertions))]
132132
return Err(TeeResult::NotSupported);
133133
};
134134
tee_cryp_state_map.set_cipher(state, &cipher)?;
@@ -174,9 +174,9 @@ impl Task {
174174
// Check last_block before applying the cipher so we don't mutate
175175
// dst_slice and then return an error.
176176
if last_block {
177-
if cfg!(debug_assertions) {
178-
todo!("support algorithms which have a certain finalization logic");
179-
}
177+
#[cfg(debug_assertions)]
178+
todo!("support algorithms which have a certain finalization logic");
179+
#[cfg(not(debug_assertions))]
180180
return Err(TeeResult::NotSupported);
181181
}
182182
if let Some(state_entry) = map.get_mut(&state)
@@ -195,8 +195,13 @@ impl Task {
195195
}
196196
}
197197
*dst_len = src_slice.len();
198+
Ok(())
199+
} else {
200+
#[cfg(debug_assertions)]
201+
todo!("handle unimplemented cipher");
202+
#[cfg(not(debug_assertions))]
203+
Err(TeeResult::NotImplemented)
198204
}
199-
Ok(())
200205
} else {
201206
Err(TeeResult::BadParameters)
202207
}
@@ -260,9 +265,9 @@ impl Task {
260265
) -> Result<(), TeeResult> {
261266
let tee_obj_map = &self.tee_obj_map;
262267
if attrs.len() > 1 {
263-
if cfg!(debug_assertions) {
264-
todo!("handle multiple attributes");
265-
}
268+
#[cfg(debug_assertions)]
269+
todo!("handle multiple attributes");
270+
#[cfg(not(debug_assertions))]
266271
return Err(TeeResult::NotSupported);
267272
}
268273
if !tee_obj_map.exists(obj) {

litebox_shim_optee/src/syscalls/mm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ impl Task {
6060
| MapFlags::MAP_HUGE_2MB
6161
| MapFlags::MAP_HUGE_1GB,
6262
) {
63-
if cfg!(debug_assertions) {
64-
todo!("Unsupported flags {:?}", flags);
65-
}
63+
#[cfg(debug_assertions)]
64+
todo!("Unsupported flags {:?}", flags);
65+
#[cfg(not(debug_assertions))]
6666
return Err(Errno::EINVAL);
6767
}
6868

litebox_shim_optee/src/syscalls/pta.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ impl Task {
137137
}
138138
}
139139
_ => {
140-
if cfg!(debug_assertions) {
141-
todo!("support other system PTA commands {cmd_id}");
142-
}
140+
#[cfg(debug_assertions)]
141+
todo!("support other system PTA commands {cmd_id}");
142+
#[cfg(not(debug_assertions))]
143143
Err(TeeResult::NotSupported)
144144
}
145145
}

litebox_shim_optee/src/syscalls/tee.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ impl Task {
7474
prop_type: UserMutPtr<u32>,
7575
) -> Result<(), TeeResult> {
7676
if name_buf.is_some() && name_len.is_some() {
77-
if cfg!(debug_assertions) {
78-
todo!("return the name of a given property index");
79-
}
77+
#[cfg(debug_assertions)]
78+
todo!("return the name of a given property index");
79+
#[cfg(not(debug_assertions))]
8080
return Err(TeeResult::NotSupported);
8181
}
8282
match GpdPropertyIndex::try_from(index).unwrap_or(GpdPropertyIndex::None) {
@@ -178,9 +178,9 @@ impl Task {
178178
// (using its UUID) to leverage its functions.
179179
// TODO: if this TA hasn't been loaded, we need to load its ELF and prepare its stack (hopefully
180180
// in a separate page table). We can do this here or at `sys_invoke_ta_command` (in a lazy manner).
181-
if cfg!(debug_assertions) {
182-
todo!("support inter TA interaction");
183-
}
181+
#[cfg(debug_assertions)]
182+
todo!("support inter TA interaction");
183+
#[cfg(not(debug_assertions))]
184184
Err(TeeResult::NotSupported)
185185
}
186186
}
@@ -192,9 +192,9 @@ impl Task {
192192
close_pta_session(ta_sess_id);
193193
Ok(())
194194
} else {
195-
if cfg!(debug_assertions) {
196-
todo!("support inter TA interaction");
197-
}
195+
#[cfg(debug_assertions)]
196+
todo!("support inter TA interaction");
197+
#[cfg(not(debug_assertions))]
198198
Err(TeeResult::NotSupported)
199199
}
200200
}
@@ -216,9 +216,9 @@ impl Task {
216216
// TODO: check whether `ta_sess_id` is associated with the system PTA.
217217
self.handle_system_pta_command(cmd_id, &params)
218218
} else {
219-
if cfg!(debug_assertions) {
220-
todo!("support inter TA interaction");
221-
}
219+
#[cfg(debug_assertions)]
220+
todo!("support inter TA interaction");
221+
#[cfg(not(debug_assertions))]
222222
Err(TeeResult::NotSupported)
223223
}
224224
}

0 commit comments

Comments
 (0)